Merge branch 'master' into no-did-you-mean-to-call-error-on-casts

This commit is contained in:
Nathan Shively-Sanders
2021-02-12 08:53:12 -08:00
561 changed files with 5207 additions and 7838 deletions
+151 -205
View File
@@ -1,6 +1,6 @@
{
"name": "typescript",
"version": "4.2.0",
"version": "4.3.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -324,9 +324,9 @@
}
},
"@octokit/openapi-types": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-4.0.0.tgz",
"integrity": "sha512-o4Q9VPYaIdzxskfVuWk7Dcb6Ldq2xbd1QKmPCRx29nFdFxm+2Py74QLfbB3CgankZerHnNJ9wgINOkwa/O2qRg==",
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-4.0.2.tgz",
"integrity": "sha512-quqmeGTjcVks8YaatVGCpt7QpUTs2PK0D3mW5aEQqmFKOuIZ/CxwWrgnggPjqP3CNp6eALdQRgf0jUpcG8X1/Q==",
"dev": true
},
"@octokit/plugin-paginate-rest": {
@@ -402,12 +402,12 @@
}
},
"@octokit/types": {
"version": "6.8.2",
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.8.2.tgz",
"integrity": "sha512-RpG0NJd7OKSkWptiFhy1xCLkThs5YoDIKM21lEtDmUvSpbaIEfrxzckWLUGDFfF8RydSyngo44gDv8m2hHruUg==",
"version": "6.8.3",
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.8.3.tgz",
"integrity": "sha512-ZNAy8z77ewKZ5LCX0KaUm4tWdgloWQ6FWJCh06qgahq/MH13sQefIPKSo0dBdPU3bcioltyZUcC0k8oHHfjvnQ==",
"dev": true,
"requires": {
"@octokit/openapi-types": "^4.0.0",
"@octokit/openapi-types": "^4.0.2",
"@types/node": ">= 8"
}
},
@@ -422,9 +422,9 @@
}
},
"@types/chai": {
"version": "4.2.14",
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.14.tgz",
"integrity": "sha512-G+ITQPXkwTrslfG5L/BksmbLUA0M1iybEsmCWPqzSxsRRhJZimBKJkoMi8fr/CPygPTj4zO5pJH7I2/cm9M7SQ==",
"version": "4.2.15",
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.15.tgz",
"integrity": "sha512-rYff6FI+ZTKAPkJUoyz7Udq3GaoDZnxYDEvdEdFZASiA7PoErltHezDishqQiSDWrGxvxmplH304jyzQmjp0AQ==",
"dev": true
},
"@types/convert-source-map": {
@@ -585,9 +585,9 @@
"dev": true
},
"@types/node": {
"version": "14.14.22",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.22.tgz",
"integrity": "sha512-g+f/qj/cNcqKkc3tFqlXOYjrmZA+jNBiDzbP3kH+B+otKFqAdPgVTGP1IeKRdMml/aE69as5S4FqtxAbl+LaMw==",
"version": "14.14.26",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.26.tgz",
"integrity": "sha512-skWxepWOs+VArEBWd2S/VR3wUavioIIx9/HzW+UJiIjtwa6+kNXdsOeq7FfxDXf56hIcL0ieo2brwMgBJ1+lhw==",
"dev": true
},
"@types/node-fetch": {
@@ -1555,12 +1555,12 @@
},
"dependencies": {
"resolve": {
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz",
"integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==",
"version": "1.20.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz",
"integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==",
"dev": true,
"requires": {
"is-core-module": "^2.1.0",
"is-core-module": "^2.2.0",
"path-parse": "^1.0.6"
}
}
@@ -1759,9 +1759,9 @@
"dev": true
},
"chai": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz",
"integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==",
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/chai/-/chai-4.3.0.tgz",
"integrity": "sha512-/BFd2J30EcOwmdOgXvVsmM48l0Br0nmZPlO0uOW4XKh6kpsUumRXBgPV+IlaqFaqr9cYbeoZAM1Npx0i4A+aiA==",
"dev": true,
"requires": {
"assertion-error": "^1.1.0",
@@ -2748,6 +2748,12 @@
"es6-symbol": "^3.1.1"
}
},
"escalade": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
"integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==",
"dev": true
},
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
@@ -3751,9 +3757,9 @@
"dev": true
},
"get-intrinsic": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.0.tgz",
"integrity": "sha512-M11rgtQp5GZMZzDL7jLTNxbDfurpzuau5uqRWDPvlHjfvg3TdScAZo96GLvhMjImrmR8uAt0FS2RLoMrfWGKlg==",
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz",
"integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==",
"dev": true,
"requires": {
"function-bind": "^1.1.1",
@@ -5335,35 +5341,35 @@
"dev": true
},
"mocha": {
"version": "8.2.1",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-8.2.1.tgz",
"integrity": "sha512-cuLBVfyFfFqbNR0uUKbDGXKGk+UDFe6aR4os78XIrMQpZl/nv7JYHcvP5MFIAb374b2zFXsdgEGwmzMtP0Xg8w==",
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-8.3.0.tgz",
"integrity": "sha512-TQqyC89V1J/Vxx0DhJIXlq9gbbL9XFNdeLQ1+JsnZsVaSOV1z3tWfw0qZmQJGQRIfkvZcs7snQnZnOCKoldq1Q==",
"dev": true,
"requires": {
"@ungap/promise-all-settled": "1.1.2",
"ansi-colors": "4.1.1",
"browser-stdout": "1.3.1",
"chokidar": "3.4.3",
"debug": "4.2.0",
"diff": "4.0.2",
"chokidar": "3.5.1",
"debug": "4.3.1",
"diff": "5.0.0",
"escape-string-regexp": "4.0.0",
"find-up": "5.0.0",
"glob": "7.1.6",
"growl": "1.10.5",
"he": "1.2.0",
"js-yaml": "3.14.0",
"js-yaml": "4.0.0",
"log-symbols": "4.0.0",
"minimatch": "3.0.4",
"ms": "2.1.2",
"nanoid": "3.1.12",
"ms": "2.1.3",
"nanoid": "3.1.20",
"serialize-javascript": "5.0.1",
"strip-json-comments": "3.1.1",
"supports-color": "7.2.0",
"supports-color": "8.1.1",
"which": "2.0.2",
"wide-align": "1.1.3",
"workerpool": "6.0.2",
"yargs": "13.3.2",
"yargs-parser": "13.1.2",
"workerpool": "6.1.0",
"yargs": "16.2.0",
"yargs-parser": "20.2.4",
"yargs-unparser": "2.0.0"
},
"dependencies": {
@@ -5373,21 +5379,6 @@
"integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==",
"dev": true
},
"ansi-regex": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
"dev": true
},
"ansi-styles": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"dev": true,
"requires": {
"color-convert": "^1.9.0"
}
},
"anymatch": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz",
@@ -5398,6 +5389,12 @@
"picomatch": "^2.0.4"
}
},
"argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"dev": true
},
"binary-extensions": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
@@ -5413,21 +5410,15 @@
"fill-range": "^7.0.1"
}
},
"camelcase": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
"dev": true
},
"chokidar": {
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.3.tgz",
"integrity": "sha512-DtM3g7juCXQxFVSNPNByEC2+NImtBuxQQvWlHunpJIS5Ocr0lG306cC7FCi7cEA0fzmybPUIl4txBIobk1gGOQ==",
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz",
"integrity": "sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw==",
"dev": true,
"requires": {
"anymatch": "~3.1.1",
"braces": "~3.0.2",
"fsevents": "~2.1.2",
"fsevents": "~2.3.1",
"glob-parent": "~5.1.0",
"is-binary-path": "~2.1.0",
"is-glob": "~4.0.1",
@@ -5436,40 +5427,45 @@
}
},
"cliui": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz",
"integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==",
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz",
"integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==",
"dev": true,
"requires": {
"string-width": "^3.1.0",
"strip-ansi": "^5.2.0",
"wrap-ansi": "^5.1.0"
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^7.0.0"
}
},
"color-convert": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
"dev": true,
"requires": {
"color-name": "1.1.3"
}
},
"color-name": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
"dev": true
},
"debug": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.2.0.tgz",
"integrity": "sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg==",
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
"dev": true,
"requires": {
"ms": "2.1.2"
},
"dependencies": {
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
}
}
},
"diff": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz",
"integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==",
"dev": true
},
"emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"dev": true
},
"escape-string-regexp": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
@@ -5496,9 +5492,9 @@
}
},
"fsevents": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz",
"integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==",
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"optional": true
},
@@ -5526,12 +5522,27 @@
"binary-extensions": "^2.0.0"
}
},
"is-fullwidth-code-point": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
"dev": true
},
"is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true
},
"js-yaml": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.0.0.tgz",
"integrity": "sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q==",
"dev": true,
"requires": {
"argparse": "^2.0.1"
}
},
"locate-path": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
@@ -5541,12 +5552,6 @@
"p-locate": "^5.0.0"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
"p-limit": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
@@ -5565,12 +5570,6 @@
"p-limit": "^3.0.2"
}
},
"p-try": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
"dev": true
},
"path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
@@ -5586,19 +5585,24 @@
"picomatch": "^2.2.1"
}
},
"require-main-filename": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
"dev": true
},
"strip-ansi": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
"integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
"string-width": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz",
"integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==",
"dev": true,
"requires": {
"ansi-regex": "^4.1.0"
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.0"
}
},
"supports-color": {
"version": "8.1.1",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
"integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
"dev": true,
"requires": {
"has-flag": "^4.0.0"
}
},
"to-regex-range": {
@@ -5619,101 +5623,43 @@
"isexe": "^2.0.0"
}
},
"which-module": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz",
"integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=",
"dev": true
},
"wrap-ansi": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz",
"integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==",
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
"dev": true,
"requires": {
"ansi-styles": "^3.2.0",
"string-width": "^3.0.0",
"strip-ansi": "^5.0.0"
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
}
},
"y18n": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz",
"integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==",
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.5.tgz",
"integrity": "sha512-hsRUr4FFrvhhRH12wOdfs38Gy7k2FFzB9qgN9v3aLykRq0dRcdcpz5C9FxdS2NuhOrI/628b/KSTJ3rwHysYSg==",
"dev": true
},
"yargs": {
"version": "13.3.2",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz",
"integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==",
"version": "16.2.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz",
"integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==",
"dev": true,
"requires": {
"cliui": "^5.0.0",
"find-up": "^3.0.0",
"get-caller-file": "^2.0.1",
"cliui": "^7.0.2",
"escalade": "^3.1.1",
"get-caller-file": "^2.0.5",
"require-directory": "^2.1.1",
"require-main-filename": "^2.0.0",
"set-blocking": "^2.0.0",
"string-width": "^3.0.0",
"which-module": "^2.0.0",
"y18n": "^4.0.0",
"yargs-parser": "^13.1.2"
},
"dependencies": {
"find-up": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz",
"integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==",
"dev": true,
"requires": {
"locate-path": "^3.0.0"
}
},
"locate-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz",
"integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==",
"dev": true,
"requires": {
"p-locate": "^3.0.0",
"path-exists": "^3.0.0"
}
},
"p-limit": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
"integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
"dev": true,
"requires": {
"p-try": "^2.0.0"
}
},
"p-locate": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz",
"integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==",
"dev": true,
"requires": {
"p-limit": "^2.0.0"
}
},
"path-exists": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
"integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=",
"dev": true
}
"string-width": "^4.2.0",
"y18n": "^5.0.5",
"yargs-parser": "^20.2.2"
}
},
"yargs-parser": {
"version": "13.1.2",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz",
"integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==",
"dev": true,
"requires": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
}
"version": "20.2.4",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz",
"integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==",
"dev": true
}
}
},
@@ -5765,12 +5711,12 @@
}
},
"resolve": {
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz",
"integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==",
"version": "1.20.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz",
"integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==",
"dev": true,
"requires": {
"is-core-module": "^2.1.0",
"is-core-module": "^2.2.0",
"path-parse": "^1.0.6"
}
},
@@ -5806,9 +5752,9 @@
"optional": true
},
"nanoid": {
"version": "3.1.12",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.12.tgz",
"integrity": "sha512-1qstj9z5+x491jfiC4Nelk+f8XBad7LN20PmyWINJEMRSf3wcAjAWysw1qaA8z6NSKe2sjq1hRSDpBH5paCb6A==",
"version": "3.1.20",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.20.tgz",
"integrity": "sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==",
"dev": true
},
"nanomatch": {
@@ -7942,9 +7888,9 @@
"dev": true
},
"uglify-js": {
"version": "3.12.6",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.6.tgz",
"integrity": "sha512-aqWHe3DfQmZUDGWBbabZ2eQnJlQd1fKlMUu7gV+MiTuDzdgDw31bI3wA2jLLsV/hNcDP26IfyEgSVoft5+0SVw==",
"version": "3.12.7",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.7.tgz",
"integrity": "sha512-SIZhkoh+U/wjW+BHGhVwE9nt8tWJspncloBcFapkpGRwNPqcH8pzX36BXe3TPBjzHWPMUZotpCigak/udWNr1Q==",
"dev": true,
"optional": true
},
@@ -8428,9 +8374,9 @@
"dev": true
},
"workerpool": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.0.2.tgz",
"integrity": "sha512-DSNyvOpFKrNusaaUwk+ej6cBj1bmhLcBfj80elGk+ZIo5JSkq+unB1dLKEOcNfJDZgjGICfhQ0Q5TbP0PvF4+Q==",
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.0.tgz",
"integrity": "sha512-toV7q9rWNYha963Pl/qyeZ6wG+3nnsyvolaNUS8+R5Wtw6qJPTxIlOP1ZSvcGhEJw+l3HMMmtiNo9Gl61G4GVg==",
"dev": true
},
"wrap-ansi": {
+4 -1
View File
@@ -2,7 +2,7 @@
"name": "typescript",
"author": "Microsoft Corp.",
"homepage": "https://www.typescriptlang.org/",
"version": "4.2.0",
"version": "4.3.0",
"license": "Apache-2.0",
"description": "TypeScript is a language for application scale JavaScript development",
"keywords": [
@@ -127,5 +127,8 @@
"source-map-support": false,
"inspector": false
},
"volta": {
"node": "14.15.5"
},
"dependencies": {}
}
+2 -2
View File
@@ -174,14 +174,14 @@ namespace ts {
const binder = createBinder();
export function bindSourceFile(file: SourceFile, options: CompilerOptions) {
tracing.push(tracing.Phase.Bind, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
tracing?.push(tracing.Phase.Bind, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
performance.mark("beforeBind");
perfLogger.logStartBindFile("" + file.fileName);
binder(file, options);
perfLogger.logStopBindFile();
performance.mark("afterBind");
performance.measure("Bind", "beforeBind", "afterBind");
tracing.pop();
tracing?.pop();
}
function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
+136 -145
View File
@@ -3846,13 +3846,16 @@ namespace ts {
}
function setStructuredTypeMembers(type: StructuredType, members: SymbolTable, callSignatures: readonly Signature[], constructSignatures: readonly Signature[], stringIndexInfo: IndexInfo | undefined, numberIndexInfo: IndexInfo | undefined): ResolvedType {
(<ResolvedType>type).members = members;
(<ResolvedType>type).properties = members === emptySymbols ? emptyArray : getNamedMembers(members);
(<ResolvedType>type).callSignatures = callSignatures;
(<ResolvedType>type).constructSignatures = constructSignatures;
(<ResolvedType>type).stringIndexInfo = stringIndexInfo;
(<ResolvedType>type).numberIndexInfo = numberIndexInfo;
return <ResolvedType>type;
const resolved = <ResolvedType>type;
resolved.members = members;
resolved.properties = emptyArray;
resolved.callSignatures = callSignatures;
resolved.constructSignatures = constructSignatures;
resolved.stringIndexInfo = stringIndexInfo;
resolved.numberIndexInfo = numberIndexInfo;
// This can loop back to getPropertyOfType() which would crash if `callSignatures` & `constructSignatures` are not initialized.
if (members !== emptySymbols) resolved.properties = getNamedMembers(members);
return resolved;
}
function createAnonymousType(symbol: Symbol | undefined, members: SymbolTable, callSignatures: readonly Signature[], constructSignatures: readonly Signature[], stringIndexInfo: IndexInfo | undefined, numberIndexInfo: IndexInfo | undefined): ResolvedType {
@@ -8768,8 +8771,15 @@ namespace ts {
}
if (symbol.flags & SymbolFlags.ModuleExports) {
const fileSymbol = getSymbolOfNode(getSourceFileOfNode(symbol.valueDeclaration));
const result = createSymbol(fileSymbol.flags, "exports" as __String);
result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : [];
result.parent = symbol;
result.target = fileSymbol;
if (fileSymbol.valueDeclaration) result.valueDeclaration = fileSymbol.valueDeclaration;
if (fileSymbol.members) result.members = new Map(fileSymbol.members);
if (fileSymbol.exports) result.exports = new Map(fileSymbol.exports);
const members = createSymbolTable();
members.set("exports" as __String, fileSymbol);
members.set("exports" as __String, result);
return createAnonymousType(symbol, members, emptyArray, emptyArray, undefined, undefined);
}
// Handle catch clause variables
@@ -13310,54 +13320,40 @@ namespace ts {
return includes;
}
function isSetOfLiteralsFromSameEnum(types: readonly Type[]): boolean {
const first = types[0];
if (first.flags & TypeFlags.EnumLiteral) {
const firstEnum = getParentOfSymbol(first.symbol);
for (let i = 1; i < types.length; i++) {
const other = types[i];
if (!(other.flags & TypeFlags.EnumLiteral) || (firstEnum !== getParentOfSymbol(other.symbol))) {
return false;
}
}
return true;
}
return false;
}
function removeSubtypes(types: Type[], primitivesOnly: boolean): boolean {
function removeSubtypes(types: Type[], hasObjectTypes: boolean): boolean {
// We assume that redundant primitive types have already been removed from the types array and that there
// are no any and unknown types in the array. Thus, the only possible supertypes for primitive types are empty
// object types, and if none of those are present we can exclude primitive types from the subtype check.
const hasEmptyObject = hasObjectTypes && some(types, t => !!(t.flags & TypeFlags.Object) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(<ObjectType>t)));
const len = types.length;
if (len === 0 || isSetOfLiteralsFromSameEnum(types)) {
return true;
}
let i = len;
let count = 0;
while (i > 0) {
i--;
const source = types[i];
for (const target of types) {
if (source !== target) {
if (count === 100000) {
// After 100000 subtype checks we estimate the remaining amount of work by assuming the
// same ratio of checks per element. If the estimated number of remaining type checks is
// greater than an upper limit we deem the union type too complex to represent. The
// upper limit is 25M for unions of primitives only, and 1M otherwise. This for example
// caps union types at 5000 unique literal types and 1000 unique object types.
const estimatedCount = (count / (len - i)) * len;
if (estimatedCount > (primitivesOnly ? 25000000 : 1000000)) {
tracing.instant(tracing.Phase.CheckTypes, "removeSubtypes_DepthLimit", { typeIds: types.map(t => t.id) });
error(currentNode, Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
return false;
if (hasEmptyObject || source.flags & TypeFlags.StructuredOrInstantiable) {
for (const target of types) {
if (source !== target) {
if (count === 100000) {
// After 100000 subtype checks we estimate the remaining amount of work by assuming the
// same ratio of checks per element. If the estimated number of remaining type checks is
// greater than 1M we deem the union type too complex to represent. This for example
// caps union types at 1000 unique object types.
const estimatedCount = (count / (len - i)) * len;
if (estimatedCount > 1000000) {
tracing?.instant(tracing.Phase.CheckTypes, "removeSubtypes_DepthLimit", { typeIds: types.map(t => t.id) });
error(currentNode, Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
return false;
}
}
count++;
if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (
!(getObjectFlags(getTargetType(source)) & ObjectFlags.Class) ||
!(getObjectFlags(getTargetType(target)) & ObjectFlags.Class) ||
isTypeDerivedFrom(source, target))) {
orderedRemoveItemAt(types, i);
break;
}
}
count++;
if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (
!(getObjectFlags(getTargetType(source)) & ObjectFlags.Class) ||
!(getObjectFlags(getTargetType(target)) & ObjectFlags.Class) ||
isTypeDerivedFrom(source, target))) {
orderedRemoveItemAt(types, i);
break;
}
}
}
@@ -13370,11 +13366,13 @@ namespace ts {
while (i > 0) {
i--;
const t = types[i];
const flags = t.flags;
const remove =
t.flags & TypeFlags.StringLikeLiteral && includes & TypeFlags.String ||
t.flags & TypeFlags.NumberLiteral && includes & TypeFlags.Number ||
t.flags & TypeFlags.BigIntLiteral && includes & TypeFlags.BigInt ||
t.flags & TypeFlags.UniqueESSymbol && includes & TypeFlags.ESSymbol ||
flags & TypeFlags.StringLiteral && includes & TypeFlags.String ||
flags & TypeFlags.NumberLiteral && includes & TypeFlags.Number ||
flags & TypeFlags.BigIntLiteral && includes & TypeFlags.BigInt ||
flags & TypeFlags.UniqueESSymbol && includes & TypeFlags.ESSymbol ||
flags & TypeFlags.Undefined && includes & TypeFlags.Void ||
isFreshLiteralType(t) && containsType(types, (<LiteralType>t).regularType);
if (remove) {
orderedRemoveItemAt(types, i);
@@ -13440,20 +13438,18 @@ namespace ts {
if (includes & TypeFlags.AnyOrUnknown) {
return includes & TypeFlags.Any ? includes & TypeFlags.IncludesWildcard ? wildcardType : anyType : unknownType;
}
switch (unionReduction) {
case UnionReduction.Literal:
if (includes & (TypeFlags.FreshableLiteral | TypeFlags.UniqueESSymbol)) {
removeRedundantLiteralTypes(typeSet, includes);
}
if (includes & TypeFlags.StringLiteral && includes & TypeFlags.TemplateLiteral) {
removeStringLiteralsMatchedByTemplateLiterals(typeSet);
}
break;
case UnionReduction.Subtype:
if (!removeSubtypes(typeSet, !(includes & TypeFlags.IncludesStructuredOrInstantiable))) {
return errorType;
}
break;
if (unionReduction & (UnionReduction.Literal | UnionReduction.Subtype)) {
if (includes & (TypeFlags.Literal | TypeFlags.UniqueESSymbol) || includes & TypeFlags.Void && includes & TypeFlags.Undefined) {
removeRedundantLiteralTypes(typeSet, includes);
}
if (includes & TypeFlags.StringLiteral && includes & TypeFlags.TemplateLiteral) {
removeStringLiteralsMatchedByTemplateLiterals(typeSet);
}
}
if (unionReduction & UnionReduction.Subtype) {
if (!removeSubtypes(typeSet, !!(includes & TypeFlags.Object))) {
return errorType;
}
}
if (typeSet.length === 0) {
return includes & TypeFlags.Null ? includes & TypeFlags.IncludesNonWideningType ? nullType : nullWideningType :
@@ -13824,7 +13820,7 @@ namespace ts {
function checkCrossProductUnion(types: readonly Type[]) {
const size = getCrossProductUnionSize(types);
if (size >= 100000) {
tracing.instant(tracing.Phase.CheckTypes, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(t => t.id), size });
tracing?.instant(tracing.Phase.CheckTypes, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(t => t.id), size });
error(currentNode, Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
return false;
}
@@ -14041,7 +14037,6 @@ namespace ts {
let type = templateLiteralTypes.get(id);
if (!type) {
templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes));
type.regularType = type;
}
return type;
@@ -15098,28 +15093,26 @@ namespace ts {
}
function getFreshTypeOfLiteralType(type: Type): Type {
if (type.flags & TypeFlags.FreshableLiteral) {
if (!(<FreshableLiteralType>type).freshType) {
const freshType = type.flags & TypeFlags.TemplateLiteral ?
createTemplateLiteralType((<TemplateLiteralType>type).texts, (<TemplateLiteralType>type).types) :
createLiteralType(type.flags, (<LiteralType>type).value, (<LiteralType>type).symbol);
freshType.regularType = <FreshableLiteralType>type;
if (type.flags & TypeFlags.Literal) {
if (!(<LiteralType>type).freshType) {
const freshType = createLiteralType(type.flags, (<LiteralType>type).value, (<LiteralType>type).symbol);
freshType.regularType = <LiteralType>type;
freshType.freshType = freshType;
(<FreshableLiteralType>type).freshType = freshType;
(<LiteralType>type).freshType = freshType;
}
return (<FreshableLiteralType>type).freshType;
return (<LiteralType>type).freshType;
}
return type;
}
function getRegularTypeOfLiteralType(type: Type): Type {
return type.flags & TypeFlags.FreshableLiteral ? (<FreshableLiteralType>type).regularType :
return type.flags & TypeFlags.Literal ? (<LiteralType>type).regularType :
type.flags & TypeFlags.Union ? ((<UnionType>type).regularType || ((<UnionType>type).regularType = mapType(type, getRegularTypeOfLiteralType) as UnionType)) :
type;
}
function isFreshLiteralType(type: Type) {
return !!(type.flags & TypeFlags.FreshableLiteral) && (<FreshableLiteralType>type).freshType === type;
return !!(type.flags & TypeFlags.Literal) && (<LiteralType>type).freshType === type;
}
function getLiteralType(value: string): StringLiteralType;
@@ -15761,7 +15754,7 @@ namespace ts {
// We have reached 50 recursive type instantiations and there is a very high likelyhood we're dealing
// with a combination of infinite generic types that perpetually generate new type identities. We stop
// the recursion here by yielding the error type.
tracing.instant(tracing.Phase.CheckTypes, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth, instantiationCount });
tracing?.instant(tracing.Phase.CheckTypes, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth, instantiationCount });
error(currentNode, Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
return errorType;
}
@@ -16891,7 +16884,7 @@ namespace ts {
reportIncompatibleStack();
}
if (overflow) {
tracing.instant(tracing.Phase.CheckTypes, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth });
tracing?.instant(tracing.Phase.CheckTypes, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth });
const diag = error(errorNode || currentNode, Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
if (errorOutputContainer) {
(errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
@@ -17378,7 +17371,7 @@ namespace ts {
}
function traceUnionsOrIntersectionsTooLarge(source: Type, target: Type): void {
if (!tracing.isTracing()) {
if (!tracing) {
return;
}
@@ -17740,7 +17733,7 @@ namespace ts {
}
if (expandingFlags === ExpandingFlags.Both) {
tracing.instant(tracing.Phase.CheckTypes, "recursiveTypeRelatedTo_DepthLimit", {
tracing?.instant(tracing.Phase.CheckTypes, "recursiveTypeRelatedTo_DepthLimit", {
sourceId: source.id,
sourceIdStack: sourceStack.map(t => t.id),
targetId: target.id,
@@ -17777,9 +17770,9 @@ namespace ts {
}
function structuredTypeRelatedTo(source: Type, target: Type, reportErrors: boolean, intersectionState: IntersectionState): Ternary {
tracing.push(tracing.Phase.CheckTypes, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
tracing?.push(tracing.Phase.CheckTypes, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
const result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState);
tracing.pop();
tracing?.pop();
return result;
}
@@ -18030,20 +18023,17 @@ namespace ts {
}
}
else if (source.flags & TypeFlags.TemplateLiteral) {
if (target.flags & TypeFlags.TemplateLiteral) {
if ((source as TemplateLiteralType).texts.length === (target as TemplateLiteralType).texts.length &&
(source as TemplateLiteralType).types.length === (target as TemplateLiteralType).types.length &&
every((source as TemplateLiteralType).texts, (t, i) => t === (target as TemplateLiteralType).texts[i]) &&
every((instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)) as TemplateLiteralType).types, (t, i) => !!((target as TemplateLiteralType).types[i].flags & (TypeFlags.Any | TypeFlags.String)) || !!isRelatedTo(t, (target as TemplateLiteralType).types[i], /*reportErrors*/ false))) {
return Ternary.True;
}
if (target.flags & TypeFlags.TemplateLiteral &&
(source as TemplateLiteralType).texts.length === (target as TemplateLiteralType).texts.length &&
(source as TemplateLiteralType).types.length === (target as TemplateLiteralType).types.length &&
every((source as TemplateLiteralType).texts, (t, i) => t === (target as TemplateLiteralType).texts[i]) &&
every((instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)) as TemplateLiteralType).types, (t, i) => !!((target as TemplateLiteralType).types[i].flags & (TypeFlags.Any | TypeFlags.String)) || !!isRelatedTo(t, (target as TemplateLiteralType).types[i], /*reportErrors*/ false))) {
return Ternary.True;
}
else {
const constraint = getBaseConstraintOfType(source);
if (result = isRelatedTo(constraint && constraint !== source ? constraint : stringType, target, reportErrors)) {
resetErrorInfo(saveErrorInfo);
return result;
}
const constraint = getBaseConstraintOfType(source);
if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, reportErrors))) {
resetErrorInfo(saveErrorInfo);
return result;
}
}
else if (source.flags & TypeFlags.StringMapping) {
@@ -18307,7 +18297,7 @@ namespace ts {
numCombinations *= countTypes(getTypeOfSymbol(sourceProperty));
if (numCombinations > 25) {
// We've reached the complexity limit.
tracing.instant(tracing.Phase.CheckTypes, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations });
tracing?.instant(tracing.Phase.CheckTypes, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations });
return Ternary.False;
}
}
@@ -19086,7 +19076,7 @@ namespace ts {
function getVariancesWorker<TCache extends { variances?: VarianceFlags[] }>(typeParameters: readonly TypeParameter[] = emptyArray, cache: TCache, createMarkerType: (input: TCache, param: TypeParameter, marker: Type) => Type): VarianceFlags[] {
let variances = cache.variances;
if (!variances) {
tracing.push(tracing.Phase.CheckTypes, "getVariancesWorker", { arity: typeParameters.length, id: (cache as any).id ?? (cache as any).declaredType?.id ?? -1 });
tracing?.push(tracing.Phase.CheckTypes, "getVariancesWorker", { arity: typeParameters.length, id: (cache as any).id ?? (cache as any).declaredType?.id ?? -1 });
// The emptyArray singleton is used to signal a recursive invocation.
cache.variances = emptyArray;
variances = [];
@@ -19121,7 +19111,7 @@ namespace ts {
variances.push(variance);
}
cache.variances = variances;
tracing.pop();
tracing?.pop();
}
return variances;
}
@@ -19499,8 +19489,8 @@ namespace ts {
}
function isEmptyArrayLiteralType(type: Type): boolean {
const elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined;
return elementType === undefinedWideningType || elementType === implicitNeverType;
const elementType = getElementTypeOfArrayType(type);
return strictNullChecks ? elementType === implicitNeverType : elementType === undefinedWideningType;
}
function isTupleLikeType(type: Type): boolean {
@@ -19538,7 +19528,7 @@ namespace ts {
function getBaseTypeOfLiteralType(type: Type): Type {
return type.flags & TypeFlags.EnumLiteral ? getBaseTypeOfEnumLiteralType(<LiteralType>type) :
type.flags & TypeFlags.StringLikeLiteral ? stringType :
type.flags & TypeFlags.StringLiteral ? stringType :
type.flags & TypeFlags.NumberLiteral ? numberType :
type.flags & TypeFlags.BigIntLiteral ? bigintType :
type.flags & TypeFlags.BooleanLiteral ? booleanType :
@@ -19548,7 +19538,7 @@ namespace ts {
function getWidenedLiteralType(type: Type): Type {
return type.flags & TypeFlags.EnumLiteral && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(<LiteralType>type) :
type.flags & TypeFlags.StringLikeLiteral && isFreshLiteralType(type) ? stringType :
type.flags & TypeFlags.StringLiteral && isFreshLiteralType(type) ? stringType :
type.flags & TypeFlags.NumberLiteral && isFreshLiteralType(type) ? numberType :
type.flags & TypeFlags.BigIntLiteral && isFreshLiteralType(type) ? bigintType :
type.flags & TypeFlags.BooleanLiteral && isFreshLiteralType(type) ? booleanType :
@@ -21042,7 +21032,7 @@ namespace ts {
}
function isTypeOrBaseIdenticalTo(s: Type, t: Type) {
return isTypeIdenticalTo(s, t) || !!(t.flags & TypeFlags.String && s.flags & TypeFlags.StringLikeLiteral || t.flags & TypeFlags.Number && s.flags & TypeFlags.NumberLiteral);
return isTypeIdenticalTo(s, t) || !!(t.flags & TypeFlags.String && s.flags & TypeFlags.StringLiteral || t.flags & TypeFlags.Number && s.flags & TypeFlags.NumberLiteral);
}
function isTypeCloselyMatchedBy(s: Type, t: Type) {
@@ -22212,7 +22202,7 @@ namespace ts {
if (flowDepth === 2000) {
// We have made 2000 recursive invocations. To avoid overflowing the call stack we report an error
// and disable further control flow analysis in the containing function or module body.
tracing.instant(tracing.Phase.CheckTypes, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id });
tracing?.instant(tracing.Phase.CheckTypes, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id });
flowAnalysisDisabled = true;
reportFlowControlError(reference);
return errorType;
@@ -23107,10 +23097,15 @@ namespace ts {
}
}
// If the candidate type is a subtype of the target type, narrow to the candidate type,
// if the target type is a subtype of the candidate type, narrow to the target type,
// otherwise, narrow to an intersection of the two types.
return isTypeSubtypeOf(candidate, type) ? candidate : isTypeSubtypeOf(type, candidate) ? type : getIntersectionType([type, candidate]);
// If the candidate type is a subtype of the target type, narrow to the candidate type.
// Otherwise, if the target type is assignable to the candidate type, keep the target type.
// Otherwise, if the candidate type is assignable to the target type, narrow to the candidate
// type. Otherwise, the types are completely unrelated, so narrow to an intersection of the
// two types.
return isTypeSubtypeOf(candidate, type) ? candidate :
isTypeAssignableTo(type, candidate) ? type :
isTypeAssignableTo(candidate, type) ? candidate :
getIntersectionType([type, candidate]);
}
function narrowTypeByCallExpression(type: Type, callExpression: CallExpression, assumeTrue: boolean): Type {
@@ -27166,6 +27161,16 @@ namespace ts {
return getInferredTypes(context);
}
function getThisArgumentType(thisArgumentNode: LeftHandSideExpression | undefined) {
if (!thisArgumentNode) {
return voidType;
}
const thisArgumentType = checkExpression(thisArgumentNode);
return isOptionalChainRoot(thisArgumentNode.parent) ? getNonNullableType(thisArgumentType) :
isOptionalChain(thisArgumentNode.parent) ? removeOptionalTypeMarker(thisArgumentType) :
thisArgumentType;
}
function inferTypeArguments(node: CallLikeExpression, signature: Signature, args: readonly Expression[], checkMode: CheckMode, context: InferenceContext): Type[] {
if (isJsxOpeningLikeElement(node)) {
return inferJsxTypeArguments(node, signature, checkMode, context);
@@ -27221,8 +27226,7 @@ namespace ts {
const thisType = getThisTypeOfSignature(signature);
if (thisType) {
const thisArgumentNode = getThisArgumentOfCall(node);
const thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType;
inferTypes(context.inferences, thisArgumentType, thisType);
inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType);
}
for (let i = 0; i < argCount; i++) {
@@ -27463,20 +27467,7 @@ namespace ts {
// 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.
const thisArgumentNode = getThisArgumentOfCall(node);
let thisArgumentType: Type;
if (thisArgumentNode) {
thisArgumentType = checkExpression(thisArgumentNode);
if (isOptionalChainRoot(thisArgumentNode.parent)) {
thisArgumentType = getNonNullableType(thisArgumentType);
}
else if (isOptionalChain(thisArgumentNode.parent)) {
thisArgumentType = removeOptionalTypeMarker(thisArgumentType);
}
}
else {
thisArgumentType = voidType;
}
const thisArgumentType = getThisArgumentType(thisArgumentNode);
const errorNode = reportErrors ? (thisArgumentNode || node) : undefined;
const headMessage = Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1;
if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer)) {
@@ -27721,6 +27712,10 @@ namespace ts {
max = Math.max(max, maxCount);
}
if (min < argCount && argCount < max) {
return getDiagnosticForCallNode(node, Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount);
}
const hasRestParameter = some(signatures, hasEffectiveRestParameter);
const paramRange = hasRestParameter ? min :
min < max ? min + "-" + max :
@@ -27754,9 +27749,6 @@ namespace ts {
);
}
}
if (min < argCount && argCount < max) {
return getDiagnosticForCallNode(node, Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount);
}
if (!hasSpreadArgument && argCount < min) {
const diagnostic = getDiagnosticForCallNode(node, error, paramRange, argCount);
@@ -28995,7 +28987,7 @@ namespace ts {
if (returnType.flags & TypeFlags.ESSymbolLike && isSymbolOrSymbolForCall(node)) {
return getESSymbolLikeTypeForNode(walkUpParenthesizedExpressions(node.parent));
}
if (node.kind === SyntaxKind.CallExpression && node.parent.kind === SyntaxKind.ExpressionStatement &&
if (node.kind === SyntaxKind.CallExpression && !node.questionDotToken && node.parent.kind === SyntaxKind.ExpressionStatement &&
returnType.flags & TypeFlags.Void && getTypePredicateOfSignature(signature)) {
if (!isDottedName(node.expression)) {
error(node.expression, Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name);
@@ -31300,7 +31292,7 @@ namespace ts {
texts.push(span.literal.text);
types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
}
return getFreshTypeOfLiteralType(getTemplateLiteralType(texts, types));
return isConstContext(node) ? getTemplateLiteralType(texts, types) : stringType;
}
function getContextNode(node: Expression): Node {
@@ -31321,7 +31313,7 @@ namespace ts {
// We strip literal freshness when an appropriate contextual type is present such that contextually typed
// literals always preserve their literal types (otherwise they might widen during type inference). An alternative
// here would be to not mark contextually typed literals as fresh in the first place.
const result = maybeTypeOfKind(type, TypeFlags.FreshableLiteral) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
const result = maybeTypeOfKind(type, TypeFlags.Literal) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
getRegularTypeOfLiteralType(type) : type;
return result;
}
@@ -31411,7 +31403,7 @@ namespace ts {
// this a literal context for literals of that primitive type. For example, given a
// type parameter 'T extends string', infer string literal types for T.
const constraint = getBaseConstraintOfType(contextualType) || unknownType;
return maybeTypeOfKind(constraint, TypeFlags.String) && maybeTypeOfKind(candidateType, TypeFlags.StringLikeLiteral) ||
return maybeTypeOfKind(constraint, TypeFlags.String) && maybeTypeOfKind(candidateType, TypeFlags.StringLiteral) ||
maybeTypeOfKind(constraint, TypeFlags.Number) && maybeTypeOfKind(candidateType, TypeFlags.NumberLiteral) ||
maybeTypeOfKind(constraint, TypeFlags.BigInt) && maybeTypeOfKind(candidateType, TypeFlags.BigIntLiteral) ||
maybeTypeOfKind(constraint, TypeFlags.ESSymbol) && maybeTypeOfKind(candidateType, TypeFlags.UniqueESSymbol) ||
@@ -31419,7 +31411,7 @@ namespace ts {
}
// If the contextual type is a literal of a particular primitive type, we consider this a
// literal context for all literals of that primitive type.
return !!(contextualType.flags & (TypeFlags.StringLikeLiteral | TypeFlags.Index | TypeFlags.StringMapping) && maybeTypeOfKind(candidateType, TypeFlags.StringLikeLiteral) ||
return !!(contextualType.flags & (TypeFlags.StringLiteral | TypeFlags.Index | TypeFlags.TemplateLiteral | TypeFlags.StringMapping) && maybeTypeOfKind(candidateType, TypeFlags.StringLiteral) ||
contextualType.flags & TypeFlags.NumberLiteral && maybeTypeOfKind(candidateType, TypeFlags.NumberLiteral) ||
contextualType.flags & TypeFlags.BigIntLiteral && maybeTypeOfKind(candidateType, TypeFlags.BigIntLiteral) ||
contextualType.flags & TypeFlags.BooleanLiteral && maybeTypeOfKind(candidateType, TypeFlags.BooleanLiteral) ||
@@ -31690,7 +31682,7 @@ namespace ts {
}
function checkExpression(node: Expression | QualifiedName, checkMode?: CheckMode, forceTuple?: boolean): Type {
tracing.push(tracing.Phase.Check, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end });
tracing?.push(tracing.Phase.Check, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end });
const saveCurrentNode = currentNode;
currentNode = node;
instantiationCount = 0;
@@ -31700,7 +31692,7 @@ namespace ts {
checkConstEnumAccess(node, type);
}
currentNode = saveCurrentNode;
tracing.pop();
tracing?.pop();
return type;
}
@@ -34506,10 +34498,10 @@ namespace ts {
}
function checkVariableDeclaration(node: VariableDeclaration) {
tracing.push(tracing.Phase.Check, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end });
tracing?.push(tracing.Phase.Check, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end });
checkGrammarVariableDeclaration(node);
checkVariableLikeDeclaration(node);
tracing.pop();
tracing?.pop();
}
function checkBindingElement(node: BindingElement) {
@@ -37590,7 +37582,7 @@ namespace ts {
}
function checkDeferredNode(node: Node) {
tracing.push(tracing.Phase.Check, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end });
tracing?.push(tracing.Phase.Check, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end });
const saveCurrentNode = currentNode;
currentNode = node;
instantiationCount = 0;
@@ -37626,16 +37618,16 @@ namespace ts {
break;
}
currentNode = saveCurrentNode;
tracing.pop();
tracing?.pop();
}
function checkSourceFile(node: SourceFile) {
tracing.push(tracing.Phase.Check, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true);
tracing?.push(tracing.Phase.Check, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true);
performance.mark("beforeCheck");
checkSourceFileWorker(node);
performance.mark("afterCheck");
performance.measure("Check", "beforeCheck", "afterCheck");
tracing.pop();
tracing?.pop();
}
function unusedIsError(kind: UnusedKind, isAmbient: boolean): boolean {
@@ -38966,8 +38958,7 @@ namespace ts {
function isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean {
if (isDeclarationReadonly(node) || isVariableDeclaration(node) && isVarConst(node)) {
const type = getTypeOfSymbol(getSymbolOfNode(node));
return !!(type.flags & TypeFlags.Literal) && isFreshLiteralType(type);
return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node)));
}
return false;
}
+8 -23
View File
@@ -2617,14 +2617,17 @@ namespace ts {
if (ownConfig.extendedConfigPath) {
// copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios.
resolutionStack = resolutionStack.concat([resolvedPath]);
const extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors, extendedConfigCache);
const extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, resolutionStack, errors, extendedConfigCache);
if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) {
const baseRaw = extendedConfig.raw;
const raw = ownConfig.raw;
let relativeDifference: string | undefined ;
const setPropertyInRawIfNotUndefined = (propertyName: string) => {
const value = raw[propertyName] || baseRaw[propertyName];
if (value) {
raw[propertyName] = value;
if (!raw[propertyName] && baseRaw[propertyName]) {
raw[propertyName] = map(baseRaw[propertyName], (path: string) => isRootedDiskPath(path) ? path : combinePaths(
relativeDifference ||= convertToRelativePath(getDirectoryPath(ownConfig.extendedConfigPath!), basePath, createGetCanonicalFileName(host.useCaseSensitiveFileNames)),
path
));
}
};
setPropertyInRawIfNotUndefined("include");
@@ -2786,7 +2789,6 @@ namespace ts {
sourceFile: TsConfigSourceFile | undefined,
extendedConfigPath: string,
host: ParseConfigHost,
basePath: string,
resolutionStack: string[],
errors: Push<Diagnostic>,
extendedConfigCache?: ESMap<string, ExtendedConfigCacheEntry>
@@ -2801,25 +2803,8 @@ namespace ts {
else {
extendedResult = readJsonConfigFile(extendedConfigPath, path => host.readFile(path));
if (!extendedResult.parseDiagnostics.length) {
const extendedDirname = getDirectoryPath(extendedConfigPath);
extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, extendedDirname,
extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, getDirectoryPath(extendedConfigPath),
getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache);
if (isSuccessfulParsedTsconfig(extendedConfig)) {
// Update the paths to reflect base path
const relativeDifference = convertToRelativePath(extendedDirname, basePath, identity);
const updatePath = (path: string) => isRootedDiskPath(path) ? path : combinePaths(relativeDifference, path);
const mapPropertiesInRawIfNotUndefined = (propertyName: string) => {
if (raw[propertyName]) {
raw[propertyName] = map(raw[propertyName], updatePath);
}
};
const { raw } = extendedConfig;
mapPropertiesInRawIfNotUndefined("include");
mapPropertiesInRawIfNotUndefined("exclude");
mapPropertiesInRawIfNotUndefined("files");
}
}
if (extendedConfigCache) {
extendedConfigCache.set(path, { extendedResult, extendedConfig });
+1 -1
View File
@@ -1,7 +1,7 @@
namespace ts {
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
// If changing the text in this section, be sure to test `configurePrerelease` too.
export const versionMajorMinor = "4.2";
export const versionMajorMinor = "4.3";
// The following is baselined as a literal template type without intervention
/** The version of the TypeScript compiler release */
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
+6 -6
View File
@@ -340,17 +340,17 @@ namespace ts {
sourceFiles: sourceFileOrBundle.sourceFiles.map(file => relativeToBuildInfo(getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())))
};
}
tracing.push(tracing.Phase.Emit, "emitJsFileOrBundle", { jsFilePath });
tracing?.push(tracing.Phase.Emit, "emitJsFileOrBundle", { jsFilePath });
emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
tracing.pop();
tracing?.pop();
tracing.push(tracing.Phase.Emit, "emitDeclarationFileOrBundle", { declarationFilePath });
tracing?.push(tracing.Phase.Emit, "emitDeclarationFileOrBundle", { declarationFilePath });
emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
tracing.pop();
tracing?.pop();
tracing.push(tracing.Phase.Emit, "emitBuildInfo", { buildInfoPath });
tracing?.push(tracing.Phase.Emit, "emitBuildInfo", { buildInfoPath });
emitBuildInfo(bundleBuildInfo, buildInfoPath);
tracing.pop();
tracing?.pop();
if (!emitSkipped && emittedFilesList) {
if (!emitOnlyDtsFiles) {
+2 -2
View File
@@ -607,7 +607,7 @@ namespace ts {
}
export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes = false, scriptKind?: ScriptKind): SourceFile {
tracing.push(tracing.Phase.Parse, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true);
tracing?.push(tracing.Phase.Parse, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true);
performance.mark("beforeParse");
let result: SourceFile;
@@ -622,7 +622,7 @@ namespace ts {
performance.mark("afterParse");
performance.measure("Parse", "beforeParse", "afterParse");
tracing.pop();
tracing?.pop();
return result;
}
+23 -23
View File
@@ -407,7 +407,7 @@ namespace ts {
const lineEnd = i < lastLineInFile ? getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
let lineContent = file.text.slice(lineStart, lineEnd);
lineContent = lineContent.replace(/\s+$/g, ""); // trim from end
lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces
lineContent = lineContent.replace(/\t/g, " "); // convert tabs to single spaces
// Output the gutter and the actual contents of the line.
context += indent + formatColorAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
@@ -833,7 +833,7 @@ namespace ts {
// Track source files that are source files found by searching under node_modules, as these shouldn't be compiled.
const sourceFilesFoundSearchingNodeModules = new Map<string, boolean>();
tracing.push(tracing.Phase.Program, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true);
tracing?.push(tracing.Phase.Program, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true);
performance.mark("beforeProgram");
const host = createProgramOptions.host || createCompilerHost(options);
@@ -919,15 +919,15 @@ namespace ts {
forEachResolvedProjectReference
});
tracing.push(tracing.Phase.Program, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
tracing?.push(tracing.Phase.Program, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
tracing.pop();
tracing?.pop();
// 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`.
let structureIsReused: StructureIsReused;
tracing.push(tracing.Phase.Program, "tryReuseStructureFromOldProgram", {});
tracing?.push(tracing.Phase.Program, "tryReuseStructureFromOldProgram", {});
structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const
tracing.pop();
tracing?.pop();
if (structureIsReused !== StructureIsReused.Completely) {
processingDefaultLibFiles = [];
processingOtherFiles = [];
@@ -964,15 +964,15 @@ namespace ts {
}
}
tracing.push(tracing.Phase.Program, "processRootFiles", { count: rootNames.length });
tracing?.push(tracing.Phase.Program, "processRootFiles", { count: rootNames.length });
forEach(rootNames, (name, index) => processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: FileIncludeKind.RootFile, index }));
tracing.pop();
tracing?.pop();
// load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
const typeReferences: string[] = rootNames.length ? getAutomaticTypeDirectiveNames(options, host) : emptyArray;
if (typeReferences.length) {
tracing.push(tracing.Phase.Program, "processTypeReferences", { count: typeReferences.length });
tracing?.push(tracing.Phase.Program, "processTypeReferences", { count: typeReferences.length });
// This containingFilename needs to match with the one used in managed-side
const containingDirectory = options.configFilePath ? getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
const containingFilename = combinePaths(containingDirectory, inferredTypesContainingFile);
@@ -980,7 +980,7 @@ namespace ts {
for (let i = 0; i < typeReferences.length; i++) {
processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: resolutions[i]?.packageId });
}
tracing.pop();
tracing?.pop();
}
// Do not process the default library if:
@@ -1108,7 +1108,7 @@ namespace ts {
verifyCompilerOptions();
performance.mark("afterProgram");
performance.measure("Program", "beforeProgram", "afterProgram");
tracing.pop();
tracing?.pop();
return program;
@@ -1116,12 +1116,12 @@ namespace ts {
if (!moduleNames.length) return emptyArray;
const containingFileName = getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
const redirectedReference = getRedirectReferenceForResolution(containingFile);
tracing.push(tracing.Phase.Program, "resolveModuleNamesWorker", { containingFileName });
tracing?.push(tracing.Phase.Program, "resolveModuleNamesWorker", { containingFileName });
performance.mark("beforeResolveModule");
const result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference);
performance.mark("afterResolveModule");
performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
tracing.pop();
tracing?.pop();
return result;
}
@@ -1129,12 +1129,12 @@ namespace ts {
if (!typeDirectiveNames.length) return [];
const containingFileName = !isString(containingFile) ? getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
const redirectedReference = !isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
tracing.push(tracing.Phase.Program, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName });
tracing?.push(tracing.Phase.Program, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName });
performance.mark("beforeResolveTypeReference");
const result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference);
performance.mark("afterResolveTypeReference");
performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
tracing.pop();
tracing?.pop();
return result;
}
@@ -1655,7 +1655,7 @@ namespace ts {
function emitBuildInfo(writeFileCallback?: WriteFileCallback): EmitResult {
Debug.assert(!outFile(options));
tracing.push(tracing.Phase.Emit, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true);
tracing?.push(tracing.Phase.Emit, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true);
performance.mark("beforeEmit");
const emitResult = emitFiles(
notImplementedResolver,
@@ -1668,7 +1668,7 @@ namespace ts {
performance.mark("afterEmit");
performance.measure("Emit", "beforeEmit", "afterEmit");
tracing.pop();
tracing?.pop();
return emitResult;
}
@@ -1729,9 +1729,9 @@ namespace ts {
}
function emit(sourceFile?: SourceFile, writeFileCallback?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, transformers?: CustomTransformers, forceDtsEmit?: boolean): EmitResult {
tracing.push(tracing.Phase.Emit, "emit", { path: sourceFile?.path }, /*separateBeginAndEnd*/ true);
tracing?.push(tracing.Phase.Emit, "emit", { path: sourceFile?.path }, /*separateBeginAndEnd*/ true);
const result = runWithCancellationToken(() => emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit));
tracing.pop();
tracing?.pop();
return result;
}
@@ -2485,13 +2485,13 @@ namespace ts {
// Get source file from normalized fileName
function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, ignoreNoDefaultLib: boolean, reason: FileIncludeReason, packageId: PackageId | undefined): SourceFile | undefined {
tracing.push(tracing.Phase.Program, "findSourceFile", {
tracing?.push(tracing.Phase.Program, "findSourceFile", {
fileName,
isDefaultLib: isDefaultLib || undefined,
fileIncludeKind: (FileIncludeKind as any)[reason.kind],
});
const result = findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId);
tracing.pop();
tracing?.pop();
return result;
}
@@ -2792,9 +2792,9 @@ namespace ts {
resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined,
reason: FileIncludeReason
): void {
tracing.push(tracing.Phase.Program, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
tracing?.push(tracing.Phase.Program, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason);
tracing.pop();
tracing?.pop();
}
function processTypeReferenceDirectiveWorker(
+1 -1
View File
@@ -1560,7 +1560,7 @@ namespace ts {
return event === "rename" &&
(!relativeName ||
relativeName === lastDirectoryPart ||
relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator!) === relativeName.length - lastDirectoryPartWithDirectorySeparator!.length) &&
(relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator!) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator!) === relativeName.length - lastDirectoryPartWithDirectorySeparator!.length)) &&
!fileSystemEntryExists(fileOrDirectory, entryKind) ?
invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
callback(event, relativeName);
+263 -274
View File
@@ -1,306 +1,295 @@
/* Tracing events for the compiler. */
/*@internal*/
/** Tracing events for the compiler. */
namespace ts.tracing {
export const enum Mode {
Project,
Build,
Server,
}
namespace ts { // eslint-disable-line one-namespace-per-file
// should be used as tracing?.___
export let tracing: typeof tracingEnabled | undefined;
// enable the above using startTracing()
let fs: typeof import("fs") | false | undefined;
// `tracingEnabled` should never be used directly, only through the above
namespace tracingEnabled { // eslint-disable-line one-namespace-per-file
type Mode = "project" | "build" | "server";
let traceCount = 0;
let traceFd: number | undefined;
let fs: typeof import("fs");
let mode: Mode;
let traceCount = 0;
let traceFd = 0;
let legendPath: string | undefined;
const legend: TraceRecord[] = [];
let mode: Mode;
// The actual constraint is that JSON.stringify be able to serialize it without throwing.
interface Args {
[key: string]: string | number | boolean | null | undefined | Args | readonly (string | number | boolean | null | undefined | Args)[];
};
let legendPath: string | undefined;
const legend: TraceRecord[] = [];
/** Starts tracing for the given project (unless the `fs` module is unavailable). */
export function startTracing(tracingMode: Mode, traceDir: string, configFilePath?: string) {
Debug.assert(!traceFd, "Tracing already started");
if (fs === undefined) {
try {
fs = require("fs");
}
catch {
fs = false;
}
}
if (!fs) {
return;
}
mode = tracingMode;
if (legendPath === undefined) {
legendPath = combinePaths(traceDir, "legend.json");
}
// Note that writing will fail later on if it exists and is not a directory
if (!fs.existsSync(traceDir)) {
fs.mkdirSync(traceDir, { recursive: true });
}
const countPart =
mode === Mode.Build ? `.${process.pid}-${++traceCount}` :
mode === Mode.Server ? `.${process.pid}` :
``;
const tracePath = combinePaths(traceDir, `trace${countPart}.json`);
const typesPath = combinePaths(traceDir, `types${countPart}.json`);
legend.push({
configFilePath,
tracePath,
typesPath,
});
traceFd = fs.openSync(tracePath, "w");
// Start with a prefix that contains some metadata that the devtools profiler expects (also avoids a warning on import)
const meta = { cat: "__metadata", ph: "M", ts: 1000 * timestamp(), pid: 1, tid: 1 };
fs.writeSync(traceFd,
"[\n"
+ [{ name: "process_name", args: { name: "tsc" }, ...meta },
{ name: "thread_name", args: { name: "Main" }, ...meta },
{ name: "TracingStartedInBrowser", ...meta, cat: "disabled-by-default-devtools.timeline" }]
.map(v => JSON.stringify(v)).join(",\n"));
}
/** Stops tracing for the in-progress project and dumps the type catalog (unless the `fs` module is unavailable). */
export function stopTracing(typeCatalog?: readonly Type[]) {
if (!traceFd) {
Debug.assert(!fs, "Tracing is not in progress");
return;
}
Debug.assert(fs);
Debug.assert(!!typeCatalog === (mode !== Mode.Server)); // Have a type catalog iff not in server mode
fs.writeSync(traceFd, `\n]\n`);
fs.closeSync(traceFd);
traceFd = undefined;
if (typeCatalog) {
dumpTypes(typeCatalog);
}
else {
// We pre-computed this path for convenience, but clear it
// now that the file won't be created.
legend[legend.length - 1].typesPath = undefined;
}
}
export function isTracing() {
return !!traceFd;
}
export const enum Phase {
Parse = "parse",
Program = "program",
Bind = "bind",
Check = "check", // Before we get into checking types (e.g. checkSourceFile)
CheckTypes = "checkTypes",
Emit = "emit",
Session = "session",
}
export function instant(phase: Phase, name: string, args?: Args) {
if (!traceFd) return;
writeEvent("I", phase, name, args, `"s":"g"`);
}
const eventStack: { phase: Phase, name: string, args?: Args, time: number, separateBeginAndEnd: boolean }[] = [];
/**
* @param separateBeginAndEnd - used for special cases where we need the trace point even if the event
* never terminates (typically for reducing a scenario too big to trace to one that can be completed).
* In the future we might implement an exit handler to dump unfinished events which would deprecate
* these operations.
*/
export function push(phase: Phase, name: string, args?: Args, separateBeginAndEnd = false) {
if (!traceFd) return;
if (separateBeginAndEnd) {
writeEvent("B", phase, name, args);
}
eventStack.push({ phase, name, args, time: 1000 * timestamp(), separateBeginAndEnd });
}
export function pop() {
if (!traceFd) return;
Debug.assert(eventStack.length > 0);
writeStackEvent(eventStack.length - 1, 1000 * timestamp());
eventStack.length--;
}
export function popAll() {
if (!traceFd) return;
const endTime = 1000 * timestamp();
for (let i = eventStack.length - 1; i >= 0; i--) {
writeStackEvent(i, endTime);
}
eventStack.length = 0;
}
function writeStackEvent(index: number, endTime: number) {
const { phase, name, args, time, separateBeginAndEnd } = eventStack[index];
if (separateBeginAndEnd) {
writeEvent("E", phase, name, args, /*extras*/ undefined, endTime);
}
else {
writeEvent("X", phase, name, args, `"dur":${endTime - time}`, time);
}
}
function writeEvent(eventType: string, phase: Phase, name: string, args: Args | undefined, extras?: string,
time: number = 1000 * timestamp()) {
Debug.assert(traceFd);
Debug.assert(fs);
// In server mode, there's no easy way to dump type information, so we drop events that would require it.
if (mode === Mode.Server && phase === Phase.CheckTypes) return;
performance.mark("beginTracing");
fs.writeSync(traceFd, `,\n{"pid":1,"tid":1,"ph":"${eventType}","cat":"${phase}","ts":${time},"name":"${name}"`);
if (extras) fs.writeSync(traceFd, `,${extras}`);
if (args) fs.writeSync(traceFd, `,"args":${JSON.stringify(args)}`);
fs.writeSync(traceFd, `}`);
performance.mark("endTracing");
performance.measure("Tracing", "beginTracing", "endTracing");
}
function indexFromOne(lc: LineAndCharacter): LineAndCharacter {
return {
line: lc.line + 1,
character: lc.character + 1,
// The actual constraint is that JSON.stringify be able to serialize it without throwing.
interface Args {
[key: string]: string | number | boolean | null | undefined | Args | readonly (string | number | boolean | null | undefined | Args)[];
};
}
function dumpTypes(types: readonly Type[]) {
Debug.assert(fs);
/** Starts tracing for the given project. */
export function startTracing(tracingMode: Mode, traceDir: string, configFilePath?: string) {
Debug.assert(!tracing, "Tracing already started");
performance.mark("beginDumpTypes");
const typesPath = legend[legend.length - 1].typesPath!;
const typesFd = fs.openSync(typesPath, "w");
const recursionIdentityMap = new Map<object, number>();
// Cleverness: no line break here so that the type ID will match the line number
fs.writeSync(typesFd, "[");
const numTypes = types.length;
for (let i = 0; i < numTypes; i++) {
const type = types[i];
const objectFlags = (type as any).objectFlags;
const symbol = type.aliasSymbol ?? type.symbol;
const firstDeclaration = symbol?.declarations?.[0];
const firstFile = firstDeclaration && getSourceFileOfNode(firstDeclaration);
// It's slow to compute the display text, so skip it unless it's really valuable (or cheap)
let display: string | undefined;
if ((objectFlags & ObjectFlags.Anonymous) | (type.flags & TypeFlags.Literal)) {
if (fs === undefined) {
try {
display = type.checker?.typeToString(type);
fs = require("fs");
}
catch {
display = undefined;
catch (e) {
throw new Error(`tracing requires having fs\n(original error: ${e.message || e})`);
}
}
let indexedAccessProperties: object = {};
if (type.flags & TypeFlags.IndexedAccess) {
const indexedAccessType = type as IndexedAccessType;
indexedAccessProperties = {
indexedAccessObjectType: indexedAccessType.objectType?.id,
indexedAccessIndexType: indexedAccessType.indexType?.id,
};
mode = tracingMode;
if (legendPath === undefined) {
legendPath = combinePaths(traceDir, "legend.json");
}
let referenceProperties: object = {};
if (objectFlags & ObjectFlags.Reference) {
const referenceType = type as TypeReference;
referenceProperties = {
instantiatedType: referenceType.target?.id,
typeArguments: referenceType.resolvedTypeArguments?.map(t => t.id),
};
// Note that writing will fail later on if it exists and is not a directory
if (!fs.existsSync(traceDir)) {
fs.mkdirSync(traceDir, { recursive: true });
}
let conditionalProperties: object = {};
if (type.flags & TypeFlags.Conditional) {
const conditionalType = type as ConditionalType;
conditionalProperties = {
conditionalCheckType: conditionalType.checkType?.id,
conditionalExtendsType: conditionalType.extendsType?.id,
conditionalTrueType: conditionalType.resolvedTrueType?.id ?? -1,
conditionalFalseType: conditionalType.resolvedFalseType?.id ?? -1,
};
}
const countPart =
mode === "build" ? `.${process.pid}-${++traceCount}`
: mode === "server" ? `.${process.pid}`
: ``;
const tracePath = combinePaths(traceDir, `trace${countPart}.json`);
const typesPath = combinePaths(traceDir, `types${countPart}.json`);
// We can't print out an arbitrary object, so just assign each one a unique number.
// Don't call it an "id" so people don't treat it as a type id.
let recursionToken: number | undefined;
const recursionIdentity = type.checker.getRecursionIdentity(type);
if (recursionIdentity) {
recursionToken = recursionIdentityMap.get(recursionIdentity);
if (!recursionToken) {
recursionToken = recursionIdentityMap.size;
recursionIdentityMap.set(recursionIdentity, recursionToken);
}
}
legend.push({
configFilePath,
tracePath,
typesPath,
});
const descriptor = {
id: type.id,
intrinsicName: (type as any).intrinsicName,
symbolName: symbol?.escapedName && unescapeLeadingUnderscores(symbol.escapedName),
recursionId: recursionToken,
unionTypes: (type.flags & TypeFlags.Union) ? (type as UnionType).types?.map(t => t.id) : undefined,
intersectionTypes: (type.flags & TypeFlags.Intersection) ? (type as IntersectionType).types.map(t => t.id) : undefined,
aliasTypeArguments: type.aliasTypeArguments?.map(t => t.id),
keyofType: (type.flags & TypeFlags.Index) ? (type as IndexType).type?.id : undefined,
...indexedAccessProperties,
...referenceProperties,
...conditionalProperties,
firstDeclaration: firstDeclaration && {
path: firstFile.path,
start: indexFromOne(getLineAndCharacterOfPosition(firstFile, firstDeclaration.pos)),
end: indexFromOne(getLineAndCharacterOfPosition(getSourceFileOfNode(firstDeclaration), firstDeclaration.end)),
},
flags: Debug.formatTypeFlags(type.flags).split("|"),
display,
traceFd = fs.openSync(tracePath, "w");
tracing = tracingEnabled; // only when traceFd is properly set
// Start with a prefix that contains some metadata that the devtools profiler expects (also avoids a warning on import)
const meta = { cat: "__metadata", ph: "M", ts: 1000 * timestamp(), pid: 1, tid: 1 };
fs.writeSync(traceFd,
"[\n"
+ [{ name: "process_name", args: { name: "tsc" }, ...meta },
{ name: "thread_name", args: { name: "Main" }, ...meta },
{ name: "TracingStartedInBrowser", ...meta, cat: "disabled-by-default-devtools.timeline" }]
.map(v => JSON.stringify(v)).join(",\n"));
}
/** Stops tracing for the in-progress project and dumps the type catalog. */
export function stopTracing(typeCatalog?: readonly Type[]) {
Debug.assert(tracing, "Tracing is not in progress");
Debug.assert(!!typeCatalog === (mode !== "server")); // Have a type catalog iff not in server mode
fs.writeSync(traceFd, `\n]\n`);
fs.closeSync(traceFd);
tracing = undefined;
if (typeCatalog) {
dumpTypes(typeCatalog);
}
else {
// We pre-computed this path for convenience, but clear it
// now that the file won't be created.
legend[legend.length - 1].typesPath = undefined;
}
}
export const enum Phase {
Parse = "parse",
Program = "program",
Bind = "bind",
Check = "check", // Before we get into checking types (e.g. checkSourceFile)
CheckTypes = "checkTypes",
Emit = "emit",
Session = "session",
}
export function instant(phase: Phase, name: string, args?: Args) {
writeEvent("I", phase, name, args, `"s":"g"`);
}
const eventStack: { phase: Phase, name: string, args?: Args, time: number, separateBeginAndEnd: boolean }[] = [];
/**
* @param separateBeginAndEnd - used for special cases where we need the trace point even if the event
* never terminates (typically for reducing a scenario too big to trace to one that can be completed).
* In the future we might implement an exit handler to dump unfinished events which would deprecate
* these operations.
*/
export function push(phase: Phase, name: string, args?: Args, separateBeginAndEnd = false) {
if (separateBeginAndEnd) {
writeEvent("B", phase, name, args);
}
eventStack.push({ phase, name, args, time: 1000 * timestamp(), separateBeginAndEnd });
}
export function pop() {
Debug.assert(eventStack.length > 0);
writeStackEvent(eventStack.length - 1, 1000 * timestamp());
eventStack.length--;
}
export function popAll() {
const endTime = 1000 * timestamp();
for (let i = eventStack.length - 1; i >= 0; i--) {
writeStackEvent(i, endTime);
}
eventStack.length = 0;
}
// sample every 10ms
const sampleInterval = 1000 * 10;
function writeStackEvent(index: number, endTime: number) {
const { phase, name, args, time, separateBeginAndEnd } = eventStack[index];
if (separateBeginAndEnd) {
writeEvent("E", phase, name, args, /*extras*/ undefined, endTime);
}
// test if [time,endTime) straddles a sampling point
else if (sampleInterval - (time % sampleInterval) <= endTime - time) {
writeEvent("X", phase, name, args, `"dur":${endTime - time}`, time);
}
}
function writeEvent(eventType: string, phase: Phase, name: string, args: Args | undefined, extras?: string,
time: number = 1000 * timestamp()) {
// In server mode, there's no easy way to dump type information, so we drop events that would require it.
if (mode === "server" && phase === Phase.CheckTypes) return;
performance.mark("beginTracing");
fs.writeSync(traceFd, `,\n{"pid":1,"tid":1,"ph":"${eventType}","cat":"${phase}","ts":${time},"name":"${name}"`);
if (extras) fs.writeSync(traceFd, `,${extras}`);
if (args) fs.writeSync(traceFd, `,"args":${JSON.stringify(args)}`);
fs.writeSync(traceFd, `}`);
performance.mark("endTracing");
performance.measure("Tracing", "beginTracing", "endTracing");
}
function indexFromOne(lc: LineAndCharacter): LineAndCharacter {
return {
line: lc.line + 1,
character: lc.character + 1,
};
}
fs.writeSync(typesFd, JSON.stringify(descriptor));
if (i < numTypes - 1) {
fs.writeSync(typesFd, ",\n");
function dumpTypes(types: readonly Type[]) {
performance.mark("beginDumpTypes");
const typesPath = legend[legend.length - 1].typesPath!;
const typesFd = fs.openSync(typesPath, "w");
const recursionIdentityMap = new Map<object, number>();
// Cleverness: no line break here so that the type ID will match the line number
fs.writeSync(typesFd, "[");
const numTypes = types.length;
for (let i = 0; i < numTypes; i++) {
const type = types[i];
const objectFlags = (type as any).objectFlags;
const symbol = type.aliasSymbol ?? type.symbol;
const firstDeclaration = symbol?.declarations?.[0];
const firstFile = firstDeclaration && getSourceFileOfNode(firstDeclaration);
// It's slow to compute the display text, so skip it unless it's really valuable (or cheap)
let display: string | undefined;
if ((objectFlags & ObjectFlags.Anonymous) | (type.flags & TypeFlags.Literal)) {
try {
display = type.checker?.typeToString(type);
}
catch {
display = undefined;
}
}
let indexedAccessProperties: object = {};
if (type.flags & TypeFlags.IndexedAccess) {
const indexedAccessType = type as IndexedAccessType;
indexedAccessProperties = {
indexedAccessObjectType: indexedAccessType.objectType?.id,
indexedAccessIndexType: indexedAccessType.indexType?.id,
};
}
let referenceProperties: object = {};
if (objectFlags & ObjectFlags.Reference) {
const referenceType = type as TypeReference;
referenceProperties = {
instantiatedType: referenceType.target?.id,
typeArguments: referenceType.resolvedTypeArguments?.map(t => t.id),
};
}
let conditionalProperties: object = {};
if (type.flags & TypeFlags.Conditional) {
const conditionalType = type as ConditionalType;
conditionalProperties = {
conditionalCheckType: conditionalType.checkType?.id,
conditionalExtendsType: conditionalType.extendsType?.id,
conditionalTrueType: conditionalType.resolvedTrueType?.id ?? -1,
conditionalFalseType: conditionalType.resolvedFalseType?.id ?? -1,
};
}
// We can't print out an arbitrary object, so just assign each one a unique number.
// Don't call it an "id" so people don't treat it as a type id.
let recursionToken: number | undefined;
const recursionIdentity = type.checker.getRecursionIdentity(type);
if (recursionIdentity) {
recursionToken = recursionIdentityMap.get(recursionIdentity);
if (!recursionToken) {
recursionToken = recursionIdentityMap.size;
recursionIdentityMap.set(recursionIdentity, recursionToken);
}
}
const descriptor = {
id: type.id,
intrinsicName: (type as any).intrinsicName,
symbolName: symbol?.escapedName && unescapeLeadingUnderscores(symbol.escapedName),
recursionId: recursionToken,
unionTypes: (type.flags & TypeFlags.Union) ? (type as UnionType).types?.map(t => t.id) : undefined,
intersectionTypes: (type.flags & TypeFlags.Intersection) ? (type as IntersectionType).types.map(t => t.id) : undefined,
aliasTypeArguments: type.aliasTypeArguments?.map(t => t.id),
keyofType: (type.flags & TypeFlags.Index) ? (type as IndexType).type?.id : undefined,
...indexedAccessProperties,
...referenceProperties,
...conditionalProperties,
firstDeclaration: firstDeclaration && {
path: firstFile.path,
start: indexFromOne(getLineAndCharacterOfPosition(firstFile, firstDeclaration.pos)),
end: indexFromOne(getLineAndCharacterOfPosition(getSourceFileOfNode(firstDeclaration), firstDeclaration.end)),
},
flags: Debug.formatTypeFlags(type.flags).split("|"),
display,
};
fs.writeSync(typesFd, JSON.stringify(descriptor));
if (i < numTypes - 1) {
fs.writeSync(typesFd, ",\n");
}
}
fs.writeSync(typesFd, "]\n");
fs.closeSync(typesFd);
performance.mark("endDumpTypes");
performance.measure("Dump types", "beginDumpTypes", "endDumpTypes");
}
fs.writeSync(typesFd, "]\n");
export function dumpLegend() {
if (!legendPath) {
return;
}
fs.closeSync(typesFd);
performance.mark("endDumpTypes");
performance.measure("Dump types", "beginDumpTypes", "endDumpTypes");
}
export function dumpLegend() {
if (!legendPath) {
return;
fs.writeFileSync(legendPath, JSON.stringify(legend));
}
Debug.assert(fs);
fs.writeFileSync(legendPath, JSON.stringify(legend));
interface TraceRecord {
configFilePath?: string;
tracePath: string;
typesPath?: string;
}
}
interface TraceRecord {
configFilePath?: string;
tracePath: string;
typesPath?: string;
}
// define after tracingEnabled is initialized
export const startTracing = tracingEnabled.startTracing;
}
+2 -2
View File
@@ -223,9 +223,9 @@ namespace ts {
// Transform each node.
const transformed: T[] = [];
for (const node of nodes) {
tracing.push(tracing.Phase.Emit, "transformNodes", node.kind === SyntaxKind.SourceFile ? { path: (node as any as SourceFile).path } : { kind: node.kind, pos: node.pos, end: node.end });
tracing?.push(tracing.Phase.Emit, "transformNodes", node.kind === SyntaxKind.SourceFile ? { path: (node as any as SourceFile).path } : { kind: node.kind, pos: node.pos, end: node.end });
transformed.push((allowDtsFiles ? transformation : transformRoot)(node));
tracing.pop();
tracing?.pop();
}
// prevent modification of the lexical environment.
+11 -4
View File
@@ -80,6 +80,7 @@ namespace ts {
reportNonlocalAugmentation
};
let errorNameNode: DeclarationName | undefined;
let errorFallbackNode: Declaration | undefined;
let currentSourceFile: SourceFile;
let refs: ESMap<NodeId, SourceFile>;
@@ -161,9 +162,9 @@ namespace ts {
}
function reportPrivateInBaseOfClassExpression(propertyName: string) {
if (errorNameNode) {
if (errorNameNode || errorFallbackNode) {
context.addDiagnostic(
createDiagnosticForNode(errorNameNode, Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName));
createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName));
}
}
@@ -199,8 +200,8 @@ namespace ts {
}
function reportTruncationError() {
if (errorNameNode) {
context.addDiagnostic(createDiagnosticForNode(errorNameNode, Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed));
if (errorNameNode || errorFallbackNode) {
context.addDiagnostic(createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed));
}
}
@@ -1102,7 +1103,9 @@ namespace ts {
diagnosticMessage: Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
errorNode: input
});
errorFallbackNode = input;
const varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined);
errorFallbackNode = undefined;
const statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(SyntaxKind.DeclareKeyword)] : [], factory.createVariableDeclarationList([varDecl], NodeFlags.Const));
return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
}
@@ -1326,6 +1329,8 @@ namespace ts {
}
}
case SyntaxKind.ClassDeclaration: {
errorNameNode = input.name;
errorFallbackNode = input;
const modifiers = factory.createNodeArray(ensureModifiers(input));
const typeParameters = ensureTypeParams(input, input.typeParameters);
const ctor = getFirstConstructorWithBody(input);
@@ -1462,6 +1467,8 @@ namespace ts {
if (node as Node === input) {
return node;
}
errorFallbackNode = undefined;
errorNameNode = undefined;
return node && setOriginalNode(preserveJsDoc(node, input), input);
}
}
+1 -2
View File
@@ -1874,9 +1874,8 @@ namespace ts {
for (const exportName of exportedNames) {
// Mark the node to prevent triggering this rule again.
noSubstitution[getNodeId(expression)] = true;
expression = createExportExpression(exportName, expression);
expression = factory.createParenthesizedExpression(createExportExpression(exportName, expression));
}
return expression;
}
}
+1 -9
View File
@@ -4972,10 +4972,6 @@ namespace ts {
Unit = Literal | UniqueESSymbol | Nullable,
StringOrNumberLiteral = StringLiteral | NumberLiteral,
/* @internal */
StringLikeLiteral = StringLiteral | TemplateLiteral,
/* @internal */
FreshableLiteral = Literal | TemplateLiteral,
/* @internal */
StringOrNumberLiteralOrUnique = StringLiteral | NumberLiteral | UniqueESSymbol,
/* @internal */
DefinitelyFalsy = StringLiteral | NumberLiteral | BigIntLiteral | BooleanLiteral | Void | Undefined | Null,
@@ -5069,9 +5065,7 @@ namespace ts {
}
/* @internal */
export type FreshableLiteralType = LiteralType | TemplateLiteralType;
/* @internal */
export type FreshableType = FreshableLiteralType | FreshableIntrinsicType;
export type FreshableType = LiteralType | FreshableIntrinsicType;
// String literal types (TypeFlags.StringLiteral)
// Numeric literal types (TypeFlags.NumberLiteral)
@@ -5475,8 +5469,6 @@ namespace ts {
export interface TemplateLiteralType extends InstantiableType {
texts: readonly string[]; // Always one element longer than types
types: readonly Type[]; // Always at least one element
freshType: TemplateLiteralType; // Fresh version of type
regularType: TemplateLiteralType; // Regular version of type
}
export interface StringMappingType extends InstantiableType {
+1 -1
View File
@@ -5643,7 +5643,7 @@ namespace ts {
function Type(this: Type, checker: TypeChecker, flags: TypeFlags) {
this.flags = flags;
if (Debug.isDebugging || tracing.isTracing()) {
if (Debug.isDebugging || tracing) {
this.checker = checker;
}
}
+4 -3
View File
@@ -501,7 +501,7 @@ namespace ts {
updateSolutionBuilderHost(sys, cb, buildHost);
const builder = createSolutionBuilder(buildHost, projects, buildOptions);
const exitStatus = buildOptions.clean ? builder.clean() : builder.build();
tracing.dumpLegend();
tracing?.dumpLegend();
return sys.exit(exitStatus);
}
@@ -666,7 +666,8 @@ namespace ts {
}
if (canTrace(system, compilerOptions)) {
tracing.startTracing(isBuildMode ? tracing.Mode.Build : tracing.Mode.Project, compilerOptions.generateTrace!, compilerOptions.configFilePath);
startTracing(isBuildMode ? "build" : "project",
compilerOptions.generateTrace!, compilerOptions.configFilePath);
}
}
@@ -674,7 +675,7 @@ namespace ts {
const compilerOptions = program.getCompilerOptions();
if (canTrace(sys, compilerOptions)) {
tracing.stopTracing(program.getTypeCatalog());
tracing?.stopTracing(program.getTypeCatalog());
}
let statistics: Statistic[];
+1 -1
View File
@@ -605,7 +605,7 @@ namespace ts.server {
return notImplemented();
}
getDocCommentTemplateAtPosition(_fileName: string, _position: number): TextInsertion {
getDocCommentTemplateAtPosition(_fileName: string, _position: number, _options?: DocCommentTemplateOptions): TextInsertion {
return notImplemented();
}
+3 -3
View File
@@ -2802,7 +2802,7 @@ namespace FourSlash {
const matchingName = completions?.filter(e => e.name === options.name);
const detailMessage = matchingName?.length
? `\n Found ${matchingName.length} with name '${options.name}' from source(s) ${matchingName.map(e => `'${e.source}'`).join(", ")}.`
: "";
: ` (In fact, there were no completions with name '${options.name}' at all.)`;
return this.raiseError(`No completions were found for the given name, source, and preferences.` + detailMessage);
}
const codeActions = details.codeActions;
@@ -3048,9 +3048,9 @@ namespace FourSlash {
assert.deepEqual(actualModuleSpecifiers, moduleSpecifiers);
}
public verifyDocCommentTemplate(expected: ts.TextInsertion | undefined) {
public verifyDocCommentTemplate(expected: ts.TextInsertion | undefined, options?: ts.DocCommentTemplateOptions) {
const name = "verifyDocCommentTemplate";
const actual = this.languageService.getDocCommentTemplateAtPosition(this.activeFile.fileName, this.currentCaretPosition)!;
const actual = this.languageService.getDocCommentTemplateAtPosition(this.activeFile.fileName, this.currentCaretPosition, options || { generateReturnInDocTemplate: true })!;
if (expected === undefined) {
if (actual) {
+2 -2
View File
@@ -432,9 +432,9 @@ namespace FourSlashInterface {
this.state.verifyNoMatchingBracePosition(bracePosition);
}
public docCommentTemplateAt(marker: string | FourSlash.Marker, expectedOffset: number, expectedText: string) {
public docCommentTemplateAt(marker: string | FourSlash.Marker, expectedOffset: number, expectedText: string, options?: ts.DocCommentTemplateOptions) {
this.state.goToMarker(marker);
this.state.verifyDocCommentTemplate({ newText: expectedText.replace(/\r?\n/g, "\r\n"), caretOffset: expectedOffset });
this.state.verifyDocCommentTemplate({ newText: expectedText.replace(/\r?\n/g, "\r\n"), caretOffset: expectedOffset }, options);
}
public noDocCommentTemplateAt(marker: string | FourSlash.Marker) {
+2 -2
View File
@@ -558,8 +558,8 @@ namespace Harness.LanguageService {
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: ts.FormatCodeOptions): ts.TextChange[] {
return unwrapJSONCallResult(this.shim.getFormattingEditsAfterKeystroke(fileName, position, key, JSON.stringify(options)));
}
getDocCommentTemplateAtPosition(fileName: string, position: number): ts.TextInsertion {
return unwrapJSONCallResult(this.shim.getDocCommentTemplateAtPosition(fileName, position));
getDocCommentTemplateAtPosition(fileName: string, position: number, options?: ts.DocCommentTemplateOptions): ts.TextInsertion {
return unwrapJSONCallResult(this.shim.getDocCommentTemplateAtPosition(fileName, position, options));
}
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean {
return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace));
+2 -2
View File
@@ -4331,8 +4331,8 @@ declare namespace Intl {
interface DateTimeFormatOptions {
localeMatcher?: "best fit" | "lookup";
weekday?:"long" | "short" | "narrow";
era?:"long" | "short" | "narrow";
weekday?: "long" | "short" | "narrow";
era?: "long" | "short" | "narrow";
year?: "numeric" | "2-digit";
month?: "numeric" | "2-digit" | "long" | "short" | "narrow";
day?: "numeric" | "2-digit";
+1 -1
View File
@@ -207,7 +207,7 @@ namespace ts.server {
const defaultTypeSafeList: SafeList = {
"jquery": {
// jquery files can have names like "jquery-1.10.2.min.js" (or "jquery.intellisense.js")
match: /jquery(-(\.?\d+)+)?(\.intellisense)?(\.min)?\.js$/i,
match: /jquery(-[\d\.]+)?(\.intellisense)?(\.min)?\.js$/i,
types: ["jquery"]
},
"WinJS": {
+4
View File
@@ -1581,6 +1581,10 @@ namespace ts.server {
protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[], pluginConfigOverrides: Map<any> | undefined) {
this.projectService.logger.info(`Enabling plugin ${pluginConfigEntry.name} from candidate paths: ${searchPaths.join(",")}`);
if (!pluginConfigEntry.name || parsePackageName(pluginConfigEntry.name).rest) {
this.projectService.logger.info(`Skipped loading plugin ${pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)} because only package name is allowed plugin name`);
return;
}
const log = (message: string) => this.projectService.logger.info(message);
let errorLogs: string[] | undefined;
+2
View File
@@ -3273,6 +3273,8 @@ namespace ts.server.protocol {
readonly provideRefactorNotApplicableReason?: boolean;
readonly allowRenameOfImportPath?: boolean;
readonly includePackageJsonAutoImports?: "auto" | "on" | "off";
readonly generateReturnInDocTemplate?: boolean;
}
export interface CompilerOptions {
+15 -15
View File
@@ -208,25 +208,25 @@ namespace ts.server {
try {
if (this.operationHost.isCancellationRequested()) {
stop = true;
tracing.instant(tracing.Phase.Session, "stepCanceled", { seq: this.requestId, early: true });
tracing?.instant(tracing.Phase.Session, "stepCanceled", { seq: this.requestId, early: true });
}
else {
tracing.push(tracing.Phase.Session, "stepAction", { seq: this.requestId });
tracing?.push(tracing.Phase.Session, "stepAction", { seq: this.requestId });
action(this);
tracing.pop();
tracing?.pop();
}
}
catch (e) {
// Cancellation or an error may have left incomplete events on the tracing stack.
tracing.popAll();
tracing?.popAll();
stop = true;
// ignore cancellation request
if (e instanceof OperationCanceledException) {
tracing.instant(tracing.Phase.Session, "stepCanceled", { seq: this.requestId });
tracing?.instant(tracing.Phase.Session, "stepCanceled", { seq: this.requestId });
}
else {
tracing.instant(tracing.Phase.Session, "stepError", { seq: this.requestId, message: (<Error>e).message });
tracing?.instant(tracing.Phase.Session, "stepError", { seq: this.requestId, message: (<Error>e).message });
this.operationHost.logError(e, `delayed processing of request ${this.requestId}`);
}
}
@@ -947,7 +947,7 @@ namespace ts.server {
}
public event<T extends object>(body: T, eventName: string): void {
tracing.instant(tracing.Phase.Session, "event", { eventName });
tracing?.instant(tracing.Phase.Session, "event", { eventName });
this.send(toEvent(eventName, body));
}
@@ -1641,7 +1641,7 @@ namespace ts.server {
private getDocCommentTemplate(args: protocol.FileLocationRequestArgs) {
const { file, languageService } = this.getFileAndLanguageServiceForSyntacticOperation(args);
const position = this.getPositionInFile(args, file);
return languageService.getDocCommentTemplateAtPosition(file, position);
return languageService.getDocCommentTemplateAtPosition(file, position, this.getPreferences(file));
}
private getSpanOfEnclosingComment(args: protocol.SpanOfEnclosingCommentRequestArgs) {
@@ -2962,12 +2962,12 @@ namespace ts.server {
request = this.parseMessage(message);
relevantFile = request.arguments && (request as protocol.FileRequest).arguments.file ? (request as protocol.FileRequest).arguments : undefined;
tracing.instant(tracing.Phase.Session, "request", { seq: request.seq, command: request.command });
tracing?.instant(tracing.Phase.Session, "request", { seq: request.seq, command: request.command });
perfLogger.logStartCommand("" + request.command, this.toStringMessage(message).substring(0, 100));
tracing.push(tracing.Phase.Session, "executeCommand", { seq: request.seq, command: request.command }, /*separateBeginAndEnd*/ true);
tracing?.push(tracing.Phase.Session, "executeCommand", { seq: request.seq, command: request.command }, /*separateBeginAndEnd*/ true);
const { response, responseRequired } = this.executeCommand(request);
tracing.pop();
tracing?.pop();
if (this.logger.hasLevel(LogLevel.requestTime)) {
const elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4);
@@ -2981,7 +2981,7 @@ namespace ts.server {
// Note: Log before writing the response, else the editor can complete its activity before the server does
perfLogger.logStopCommand("" + request.command, "Success");
tracing.instant(tracing.Phase.Session, "response", { seq: request.seq, command: request.command, success: !!response });
tracing?.instant(tracing.Phase.Session, "response", { seq: request.seq, command: request.command, success: !!response });
if (response) {
this.doOutput(response, request.command, request.seq, /*success*/ true);
}
@@ -2991,19 +2991,19 @@ namespace ts.server {
}
catch (err) {
// Cancellation or an error may have left incomplete events on the tracing stack.
tracing.popAll();
tracing?.popAll();
if (err instanceof OperationCanceledException) {
// Handle cancellation exceptions
perfLogger.logStopCommand("" + (request && request.command), "Canceled: " + err);
tracing.instant(tracing.Phase.Session, "commandCanceled", { seq: request?.seq, command: request?.command });
tracing?.instant(tracing.Phase.Session, "commandCanceled", { seq: request?.seq, command: request?.command });
this.doOutput({ canceled: true }, request!.command, request!.seq, /*success*/ true);
return;
}
this.logErrorWorker(err, this.toStringMessage(message), relevantFile);
perfLogger.logStopCommand("" + (request && request.command), "Error: " + err);
tracing.instant(tracing.Phase.Session, "commandError", { seq: request?.seq, command: request?.command, message: (<Error>err).message });
tracing?.instant(tracing.Phase.Session, "commandError", { seq: request?.seq, command: request?.command, message: (<Error>err).message });
this.doOutput(
/*info*/ undefined,
+1 -1
View File
@@ -321,7 +321,7 @@ namespace ts.codefix {
return typeNode;
}
function createDummyParameters(argCount: number, names: (string | undefined)[] | undefined, types: (TypeNode | undefined)[] | undefined, minArgumentCount: number | undefined, inJs: boolean): ParameterDeclaration[] {
function createDummyParameters(argCount: number, names: (string | undefined)[] | undefined, types: (TypeNode | undefined)[] | undefined, minArgumentCount: number | undefined, inJs: boolean): ParameterDeclaration[] {
const parameters: ParameterDeclaration[] = [];
for (let i = 0; i < argCount; i++) {
const newParameter = factory.createParameterDeclaration(
+5 -7
View File
@@ -609,7 +609,7 @@ namespace ts.codefix {
const exported = getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions);
if (!exported) return undefined;
const { symbol, kind } = exported;
const info = getDefaultExportInfoWorker(symbol, moduleSymbol, checker, compilerOptions);
const info = getDefaultExportInfoWorker(symbol, checker, compilerOptions);
return info && { symbol, kind, ...info };
}
@@ -645,7 +645,7 @@ namespace ts.codefix {
return allowSyntheticDefaults ? ImportKind.Default : ImportKind.CommonJS;
}
function getDefaultExportInfoWorker(defaultExport: Symbol, moduleSymbol: Symbol, checker: TypeChecker, compilerOptions: CompilerOptions): { readonly symbolForMeaning: Symbol, readonly name: string } | undefined {
function getDefaultExportInfoWorker(defaultExport: Symbol, checker: TypeChecker, compilerOptions: CompilerOptions): { readonly symbolForMeaning: Symbol, readonly name: string } | undefined {
const localSymbol = getLocalSymbolForExportDefault(defaultExport);
if (localSymbol) return { symbolForMeaning: localSymbol, name: localSymbol.name };
@@ -659,7 +659,7 @@ namespace ts.codefix {
// but we can still offer completions for it.
// - `aliased.parent` will be undefined if the module is exporting `globalThis.something`,
// or another expression that resolves to a global.
return getDefaultExportInfoWorker(aliased, aliased.parent, checker, compilerOptions);
return getDefaultExportInfoWorker(aliased, checker, compilerOptions);
}
}
@@ -667,15 +667,13 @@ namespace ts.codefix {
defaultExport.escapedName !== InternalSymbolName.ExportEquals) {
return { symbolForMeaning: defaultExport, name: defaultExport.getName() };
}
return { symbolForMeaning: defaultExport, name: moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) };
return { symbolForMeaning: defaultExport, name: getNameForExportedSymbol(defaultExport, compilerOptions.target) };
}
function getNameForExportDefault(symbol: Symbol): string | undefined {
return symbol.declarations && firstDefined(symbol.declarations, declaration => {
if (isExportAssignment(declaration)) {
if (isIdentifier(declaration.expression)) {
return declaration.expression.text;
}
return tryCast(skipOuterExpressions(declaration.expression), isIdentifier)?.text;
}
else if (isExportSpecifier(declaration)) {
Debug.assert(declaration.name.text === InternalSymbolName.Default, "Expected the specifier to be a default export");
+1 -1
View File
@@ -732,7 +732,7 @@ namespace ts.Completions {
exportedSymbol,
moduleSymbol,
sourceFile,
getNameForExportedSymbol(symbol, compilerOptions.target!),
getNameForExportedSymbol(symbol, compilerOptions.target),
host,
program,
formatContext,
+10 -5
View File
@@ -390,7 +390,8 @@ namespace ts.formatting {
sourceFile));
}
function formatSpanWorker(originalRange: TextRange,
function formatSpanWorker(
originalRange: TextRange,
enclosingNode: Node,
initialIndentation: number,
delta: number,
@@ -424,16 +425,20 @@ namespace ts.formatting {
}
if (!formattingScanner.isOnToken()) {
const indentation = SmartIndenter.nodeWillIndentChild(options, enclosingNode, /*child*/ undefined, sourceFile, /*indentByDefault*/ false)
? initialIndentation + options.indentSize!
: initialIndentation;
const leadingTrivia = formattingScanner.getCurrentLeadingTrivia();
if (leadingTrivia) {
indentTriviaItems(leadingTrivia, initialIndentation, /*indentNextTokenOrTrivia*/ false,
indentTriviaItems(leadingTrivia, indentation, /*indentNextTokenOrTrivia*/ false,
item => processRange(item, sourceFile.getLineAndCharacterOfPosition(item.pos), enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined!));
if (options.trimTrailingWhitespace !== false) {
trimTrailingWhitespacesForRemainingRange();
}
}
}
if (options.trimTrailingWhitespace !== false) {
trimTrailingWhitespacesForRemainingRange();
}
return edits;
// local functions
+15 -14
View File
@@ -251,7 +251,7 @@ namespace ts.JsDoc {
* @param position The (character-indexed) position in the file where the check should
* be performed.
*/
export function getDocCommentTemplateAtPosition(newLine: string, sourceFile: SourceFile, position: number): TextInsertion | undefined {
export function getDocCommentTemplateAtPosition(newLine: string, sourceFile: SourceFile, position: number, options?: DocCommentTemplateOptions): TextInsertion | undefined {
const tokenAtPos = getTokenAtPosition(sourceFile, position);
const existingDocComment = findAncestor(tokenAtPos, isJSDoc);
if (existingDocComment && (existingDocComment.comment !== undefined || length(existingDocComment.tags))) {
@@ -265,7 +265,7 @@ namespace ts.JsDoc {
return undefined;
}
const commentOwnerInfo = getCommentOwnerInfo(tokenAtPos);
const commentOwnerInfo = getCommentOwnerInfo(tokenAtPos, options);
if (!commentOwnerInfo) {
return undefined;
}
@@ -325,10 +325,10 @@ namespace ts.JsDoc {
readonly parameters?: readonly ParameterDeclaration[];
readonly hasReturn?: boolean;
}
function getCommentOwnerInfo(tokenAtPos: Node): CommentOwnerInfo | undefined {
return forEachAncestor(tokenAtPos, getCommentOwnerInfoWorker);
function getCommentOwnerInfo(tokenAtPos: Node, options: DocCommentTemplateOptions | undefined): CommentOwnerInfo | undefined {
return forEachAncestor(tokenAtPos, n => getCommentOwnerInfoWorker(n, options));
}
function getCommentOwnerInfoWorker(commentOwner: Node): CommentOwnerInfo | undefined | "quit" {
function getCommentOwnerInfoWorker(commentOwner: Node, options: DocCommentTemplateOptions | undefined): CommentOwnerInfo | undefined | "quit" {
switch (commentOwner.kind) {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
@@ -337,10 +337,10 @@ namespace ts.JsDoc {
case SyntaxKind.MethodSignature:
case SyntaxKind.ArrowFunction:
const host = commentOwner as ArrowFunction | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | MethodSignature;
return { commentOwner, parameters: host.parameters, hasReturn: hasReturn(host) };
return { commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) };
case SyntaxKind.PropertyAssignment:
return getCommentOwnerInfoWorker((commentOwner as PropertyAssignment).initializer);
return getCommentOwnerInfoWorker((commentOwner as PropertyAssignment).initializer, options);
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
@@ -357,7 +357,7 @@ namespace ts.JsDoc {
? getRightHandSideOfAssignment(varDeclarations[0].initializer)
: undefined;
return host
? { commentOwner, parameters: host.parameters, hasReturn: hasReturn(host) }
? { commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) }
: { commentOwner };
}
@@ -371,27 +371,28 @@ namespace ts.JsDoc {
return commentOwner.parent.kind === SyntaxKind.ModuleDeclaration ? undefined : { commentOwner };
case SyntaxKind.ExpressionStatement:
return getCommentOwnerInfoWorker((commentOwner as ExpressionStatement).expression);
return getCommentOwnerInfoWorker((commentOwner as ExpressionStatement).expression, options);
case SyntaxKind.BinaryExpression: {
const be = commentOwner as BinaryExpression;
if (getAssignmentDeclarationKind(be) === AssignmentDeclarationKind.None) {
return "quit";
}
return isFunctionLike(be.right)
? { commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right) }
? { commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) }
: { commentOwner };
}
case SyntaxKind.PropertyDeclaration:
const init = (commentOwner as PropertyDeclaration).initializer;
if (init && (isFunctionExpression(init) || isArrowFunction(init))) {
return { commentOwner, parameters: init.parameters, hasReturn: hasReturn(init) };
return { commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) };
}
}
}
function hasReturn(node: Node) {
return isArrowFunction(node) && isExpression(node.body)
|| isFunctionLikeDeclaration(node) && node.body && isBlock(node.body) && !!forEachReturnStatement(node.body, n => n);
function hasReturn(node: Node, options: DocCommentTemplateOptions | undefined) {
return !!options?.generateReturnInDocTemplate &&
(isArrowFunction(node) && isExpression(node.body)
|| isFunctionLikeDeclaration(node) && node.body && isBlock(node.body) && !!forEachReturnStatement(node.body, n => n));
}
function getRightHandSideOfAssignment(rightHandSide: Expression): FunctionExpression | ArrowFunction | ConstructorDeclaration | undefined {
@@ -51,18 +51,14 @@ namespace ts.refactor.convertParamsToDestructuredObject {
changes: textChanges.ChangeTracker,
functionDeclaration: ValidFunctionDeclaration,
groupedReferences: GroupedReferences): void {
const newParamDeclaration = map(createNewParameters(functionDeclaration, program, host), param => getSynthesizedDeepClone(param));
changes.replaceNodeRangeWithNodes(
sourceFile,
first(functionDeclaration.parameters),
last(functionDeclaration.parameters),
newParamDeclaration,
{ joiner: ", ",
// indentation is set to 0 because otherwise the object parameter will be indented if there is a `this` parameter
indentation: 0,
leadingTriviaOption: textChanges.LeadingTriviaOption.IncludeAll,
trailingTriviaOption: textChanges.TrailingTriviaOption.Include
});
const signature = groupedReferences.signature;
const newFunctionDeclarationParams = map(createNewParameters(functionDeclaration, program, host), param => getSynthesizedDeepClone(param));
if (signature) {
const newSignatureParams = map(createNewParameters(signature, program, host), param => getSynthesizedDeepClone(param));
replaceParameters(signature, newSignatureParams);
}
replaceParameters(functionDeclaration, newFunctionDeclarationParams);
const functionCalls = sortAndDeduplicate(groupedReferences.functionCalls, /*comparer*/ (a, b) => compareValues(a.pos, b.pos));
for (const call of functionCalls) {
@@ -76,6 +72,21 @@ namespace ts.refactor.convertParamsToDestructuredObject {
{ leadingTriviaOption: textChanges.LeadingTriviaOption.IncludeAll, trailingTriviaOption: textChanges.TrailingTriviaOption.Include });
}
}
function replaceParameters(declarationOrSignature: ValidFunctionDeclaration | ValidMethodSignature, parameterDeclarations: ParameterDeclaration[]) {
changes.replaceNodeRangeWithNodes(
sourceFile,
first(declarationOrSignature.parameters),
last(declarationOrSignature.parameters),
parameterDeclarations,
{
joiner: ", ",
// indentation is set to 0 because otherwise the object parameter will be indented if there is a `this` parameter
indentation: 0,
leadingTriviaOption: textChanges.LeadingTriviaOption.IncludeAll,
trailingTriviaOption: textChanges.TrailingTriviaOption.Include
});
}
}
function getGroupedReferences(functionDeclaration: ValidFunctionDeclaration, program: Program, cancellationToken: CancellationToken): GroupedReferences {
@@ -99,13 +110,41 @@ namespace ts.refactor.convertParamsToDestructuredObject {
const functionSymbols = map(functionNames, getSymbolTargetAtLocation);
const classSymbols = map(classNames, getSymbolTargetAtLocation);
const isConstructor = isConstructorDeclaration(functionDeclaration);
const contextualSymbols = map(functionNames, name => getSymbolForContextualType(name, checker));
for (const entry of referenceEntries) {
if (entry.kind !== FindAllReferences.EntryKind.Node) {
if (entry.kind === FindAllReferences.EntryKind.Span) {
groupedReferences.valid = false;
continue;
}
/* Declarations in object literals may be implementations of method signatures which have a different symbol from the declaration
For example:
interface IFoo { m(a: number): void }
const foo: IFoo = { m(a: number): void {} }
In these cases we get the symbol for the signature from the contextual type.
*/
if (contains(contextualSymbols, getSymbolTargetAtLocation(entry.node))) {
if (isValidMethodSignature(entry.node.parent)) {
groupedReferences.signature = entry.node.parent;
continue;
}
const call = entryToFunctionCall(entry);
if (call) {
groupedReferences.functionCalls.push(call);
continue;
}
}
const contextualSymbol = getSymbolForContextualType(entry.node, checker);
if (contextualSymbol && contains(contextualSymbols, contextualSymbol)) {
const decl = entryToDeclaration(entry);
if (decl) {
groupedReferences.declarations.push(decl);
continue;
}
}
/* We compare symbols because in some cases find all references wil return a reference that may or may not be to the refactored function.
Example from the refactorConvertParamsToDestructuredObject_methodCallUnion.ts test:
class A { foo(a: number, b: number) { return a + b; } }
@@ -175,6 +214,20 @@ namespace ts.refactor.convertParamsToDestructuredObject {
}
}
/**
* Gets the symbol for the contextual type of the node if it is not a union or intersection.
*/
function getSymbolForContextualType(node: Node, checker: TypeChecker): Symbol | undefined {
const element = getContainingObjectLiteralElement(node);
if (element) {
const contextualType = checker.getContextualTypeForObjectLiteralElement(<ObjectLiteralElementLike>element);
const symbol = contextualType?.getSymbol();
if (symbol && !(getCheckFlags(symbol) & CheckFlags.Synthetic)) {
return symbol;
}
}
}
function entryToImportOrExport(entry: FindAllReferences.NodeEntry): Node | undefined {
const node = entry.node;
@@ -292,6 +345,10 @@ namespace ts.refactor.convertParamsToDestructuredObject {
return false;
}
function isValidMethodSignature(node: Node): node is ValidMethodSignature {
return isMethodSignature(node) && (isInterfaceDeclaration(node.parent) || isTypeLiteralNode(node.parent));
}
function isValidFunctionDeclaration(
functionDeclaration: FunctionLikeDeclaration,
checker: TypeChecker): functionDeclaration is ValidFunctionDeclaration {
@@ -300,6 +357,11 @@ namespace ts.refactor.convertParamsToDestructuredObject {
case SyntaxKind.FunctionDeclaration:
return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker);
case SyntaxKind.MethodDeclaration:
if (isObjectLiteralExpression(functionDeclaration.parent)) {
const contextualSymbol = getSymbolForContextualType(functionDeclaration.name, checker);
// don't offer the refactor when there are multiple signatures since we won't know which ones the user wants to change
return contextualSymbol?.declarations.length === 1 && isSingleImplementation(functionDeclaration, checker);
}
return isSingleImplementation(functionDeclaration, checker);
case SyntaxKind.Constructor:
if (isClassDeclaration(functionDeclaration.parent)) {
@@ -398,7 +460,7 @@ namespace ts.refactor.convertParamsToDestructuredObject {
return objectLiteral;
}
function createNewParameters(functionDeclaration: ValidFunctionDeclaration, program: Program, host: LanguageServiceHost): NodeArray<ParameterDeclaration> {
function createNewParameters(functionDeclaration: ValidFunctionDeclaration | ValidMethodSignature, program: Program, host: LanguageServiceHost): NodeArray<ParameterDeclaration> {
const checker = program.getTypeChecker();
const refactorableParameters = getRefactorableParameters(functionDeclaration.parameters);
const bindingElements = map(refactorableParameters, createBindingElementFromParameterDeclaration);
@@ -584,6 +646,10 @@ namespace ts.refactor.convertParamsToDestructuredObject {
parameters: NodeArray<ValidParameterDeclaration>;
}
interface ValidMethodSignature extends MethodSignature {
parameters: NodeArray<ValidParameterDeclaration>;
}
type ValidFunctionDeclaration = ValidConstructor | ValidFunction | ValidMethod | ValidArrowFunction | ValidFunctionExpression;
interface ValidParameterDeclaration extends ParameterDeclaration {
@@ -595,6 +661,7 @@ namespace ts.refactor.convertParamsToDestructuredObject {
interface GroupedReferences {
functionCalls: (CallExpression | NewExpression)[];
declarations: Node[];
signature?: ValidMethodSignature;
classReferences?: ClassReferences;
valid: boolean;
}
@@ -59,7 +59,9 @@ namespace ts.refactor.inferFunctionReturnType {
if (isInJSFile(context.file) || !refactorKindBeginsWith(inferReturnTypeAction.kind, context.kind)) return;
const token = getTokenAtPosition(context.file, context.startPosition);
const declaration = findAncestor(token, isConvertibleDeclaration);
const declaration = findAncestor(token, n =>
isBlock(n) || n.parent && isArrowFunction(n.parent) && (n.kind === SyntaxKind.EqualsGreaterThanToken || n.parent.body === n) ? "quit" :
isConvertibleDeclaration(n)) as ConvertibleDeclaration | undefined;
if (!declaration || !declaration.body || declaration.type) {
return { error: getLocaleSpecificMessage(Diagnostics.Return_type_must_be_inferred_from_a_function) };
}
@@ -68,7 +70,7 @@ namespace ts.refactor.inferFunctionReturnType {
const returnType = tryGetReturnType(typeChecker, declaration);
if (!returnType) {
return { error: getLocaleSpecificMessage(Diagnostics.Could_not_determine_function_return_type) };
};
}
const returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, NodeBuilderFlags.NoTruncation);
if (returnTypeNode) {
+4 -4
View File
@@ -1143,7 +1143,7 @@ namespace ts {
public throwIfCancellationRequested(): void {
if (this.isCancellationRequested()) {
tracing.instant(tracing.Phase.Session, "cancellationThrown", { kind: "CancellationTokenObject" });
tracing?.instant(tracing.Phase.Session, "cancellationThrown", { kind: "CancellationTokenObject" });
throw new OperationCanceledException();
}
}
@@ -1174,7 +1174,7 @@ namespace ts {
public throwIfCancellationRequested(): void {
if (this.isCancellationRequested()) {
tracing.instant(tracing.Phase.Session, "cancellationThrown", { kind: "ThrottledCancellationToken" });
tracing?.instant(tracing.Phase.Session, "cancellationThrown", { kind: "ThrottledCancellationToken" });
throw new OperationCanceledException();
}
}
@@ -2004,8 +2004,8 @@ namespace ts {
: Promise.reject("Host does not implement `installPackage`");
}
function getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion | undefined {
return JsDoc.getDocCommentTemplateAtPosition(getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position);
function getDocCommentTemplateAtPosition(fileName: string, position: number, options?: DocCommentTemplateOptions): TextInsertion | undefined {
return JsDoc.getDocCommentTemplateAtPosition(getNewLineOrDefaultFromHost(host), syntaxTreeCache.getCurrentSourceFile(fileName), position, options);
}
function isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean {
+3 -3
View File
@@ -263,7 +263,7 @@ namespace ts {
/**
* Returns JSON-encoded value of the type TextInsertion.
*/
getDocCommentTemplateAtPosition(fileName: string, position: number): string;
getDocCommentTemplateAtPosition(fileName: string, position: number, options?: DocCommentTemplateOptions): string;
/**
* Returns JSON-encoded boolean to indicate whether we should support brace location
@@ -999,10 +999,10 @@ namespace ts {
});
}
public getDocCommentTemplateAtPosition(fileName: string, position: number): string {
public getDocCommentTemplateAtPosition(fileName: string, position: number, options?: DocCommentTemplateOptions): string {
return this.forwardJSONCall(
`getDocCommentTemplateAtPosition('${fileName}', ${position})`,
() => this.languageService.getDocCommentTemplateAtPosition(fileName, position)
() => this.languageService.getDocCommentTemplateAtPosition(fileName, position, options)
);
}
+17 -6
View File
@@ -517,7 +517,6 @@ namespace ts.SignatureHelp {
if (argumentIndex !== 0) {
Debug.assertLessThan(argumentIndex, argumentCount);
}
let selectedItemIndex = 0;
let itemsSeen = 0;
for (let i = 0; i < items.length; i++) {
@@ -541,8 +540,19 @@ namespace ts.SignatureHelp {
}
Debug.assert(selectedItemIndex !== -1); // If candidates is non-empty it should always include bestSignature. We check for an empty candidates before calling this function.
return { items: flatMapToMutable(items, identity), applicableSpan, selectedItemIndex, argumentIndex, argumentCount };
const help = { items: flatMapToMutable(items, identity), applicableSpan, selectedItemIndex, argumentIndex, argumentCount };
const selected = help.items[selectedItemIndex];
if (selected.isVariadic) {
const firstRest = findIndex(selected.parameters, p => !!p.isRest);
if (-1 < firstRest && firstRest < selected.parameters.length - 1) {
// We don't have any code to get this correct; instead, don't highlight a current parameter AT ALL
help.argumentIndex = selected.parameters.length;
}
else {
help.argumentIndex = Math.min(help.argumentIndex, selected.parameters.length - 1);
}
}
return help;
}
function createTypeHelpItems(
@@ -638,8 +648,9 @@ namespace ts.SignatureHelp {
const param = checker.symbolToParameterDeclaration(parameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)!;
printer.writeNode(EmitHint.Unspecified, param, sourceFile, writer);
});
const isOptional = checker.isOptionalParameter(<ParameterDeclaration>parameter.valueDeclaration);
return { name: parameter.name, documentation: parameter.getDocumentationComment(checker), displayParts, isOptional };
const isOptional = checker.isOptionalParameter(parameter.valueDeclaration as ParameterDeclaration);
const isRest = !!((parameter as TransientSymbol).checkFlags & CheckFlags.RestParameter);
return { name: parameter.name, documentation: parameter.getDocumentationComment(checker), displayParts, isOptional, isRest };
}
function createSignatureHelpParameterForTypeParameter(typeParameter: TypeParameter, checker: TypeChecker, enclosingDeclaration: Node, sourceFile: SourceFile, printer: Printer): SignatureHelpParameter {
@@ -647,6 +658,6 @@ namespace ts.SignatureHelp {
const param = checker.typeParameterToDeclaration(typeParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)!;
printer.writeNode(EmitHint.Unspecified, param, sourceFile, writer);
});
return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts, isOptional: false };
return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts, isOptional: false, isRest: false };
}
}
+16
View File
@@ -13,10 +13,16 @@ namespace ts.SmartSelectionRange {
const prevNode: Node | undefined = children[i - 1];
const node: Node = children[i];
const nextNode: Node | undefined = children[i + 1];
if (getTokenPosOfNode(node, sourceFile, /*includeJsDoc*/ true) > pos) {
break outer;
}
const comment = singleOrUndefined(getTrailingCommentRanges(sourceFile.text, node.end));
if (comment && comment.kind === SyntaxKind.SingleLineCommentTrivia) {
pushSelectionCommentRange(comment.pos, comment.end);
}
if (positionShouldSnapToNode(sourceFile, pos, node)) {
// 1. Blocks are effectively redundant with SyntaxLists.
// 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping
@@ -89,6 +95,16 @@ namespace ts.SmartSelectionRange {
}
}
}
function pushSelectionCommentRange(start: number, end: number): void {
pushSelectionRange(start, end);
let pos = start;
while (sourceFile.text.charCodeAt(pos) === CharacterCodes.slash) {
pos++;
}
pushSelectionRange(pos, end);
}
}
/**
+6 -1
View File
@@ -490,7 +490,7 @@ namespace ts {
getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[];
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[];
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion | undefined;
getDocCommentTemplateAtPosition(fileName: string, position: number, options?: DocCommentTemplateOptions): TextInsertion | undefined;
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
/**
@@ -1073,11 +1073,16 @@ namespace ts {
readonly allowRenameOfImportPath?: boolean;
}
export interface DocCommentTemplateOptions {
readonly generateReturnInDocTemplate?: boolean;
}
export interface SignatureHelpParameter {
name: string;
documentation: SymbolDisplayPart[];
displayParts: SymbolDisplayPart[];
isOptional: boolean;
isRest?: boolean;
}
export interface SelectionRange {
+4 -4
View File
@@ -2495,7 +2495,7 @@ namespace ts {
// Editors can pass in undefined or empty string - we want to infer the preference in those cases.
const quotePreference = getQuotePreference(sourceFile, preferences);
const quoted = JSON.stringify(text);
return quotePreference === QuotePreference.Single ? `'${stripQuotes(quoted).replace("'", "\\'").replace('\\"', '"')}'` : quoted;
return quotePreference === QuotePreference.Single ? `'${stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"')}'` : quoted;
}
export function isEqualityOperatorKind(kind: SyntaxKind): kind is EqualityOperator {
@@ -2880,10 +2880,10 @@ namespace ts {
return isArray(valueOrArray) ? first(valueOrArray) : valueOrArray;
}
export function getNameForExportedSymbol(symbol: Symbol, scriptTarget: ScriptTarget) {
if (symbol.escapedName === InternalSymbolName.ExportEquals || symbol.escapedName === InternalSymbolName.Default) {
export function getNameForExportedSymbol(symbol: Symbol, scriptTarget: ScriptTarget | undefined) {
if (!(symbol.flags & SymbolFlags.Transient) && (symbol.escapedName === InternalSymbolName.ExportEquals || symbol.escapedName === InternalSymbolName.Default)) {
// Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
return firstDefined(symbol.declarations, d => isExportAssignment(d) && isIdentifier(d.expression) ? d.expression.text : undefined)
return firstDefined(symbol.declarations, d => isExportAssignment(d) ? tryCast(skipOuterExpressions(d.expression), isIdentifier)?.text : undefined)
|| codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget);
}
return symbol.name;
+2
View File
@@ -112,6 +112,7 @@
"unittests/services/transpile.ts",
"unittests/tsbuild/amdModulesWithOut.ts",
"unittests/tsbuild/configFileErrors.ts",
"unittests/tsbuild/configFileExtends.ts",
"unittests/tsbuild/containerOnlyReferenced.ts",
"unittests/tsbuild/declarationEmit.ts",
"unittests/tsbuild/demo.ts",
@@ -183,6 +184,7 @@
"unittests/tsserver/openFile.ts",
"unittests/tsserver/packageJsonInfo.ts",
"unittests/tsserver/partialSemanticServer.ts",
"unittests/tsserver/plugins.ts",
"unittests/tsserver/projectErrors.ts",
"unittests/tsserver/projectReferenceCompileOnSave.ts",
"unittests/tsserver/projectReferenceErrors.ts",
@@ -0,0 +1,52 @@
namespace ts {
describe("unittests:: tsbuild:: configFileExtends:: when tsconfig extends another config", () => {
function getConfigExtendsWithIncludeFs() {
return loadProjectFromFiles({
"/src/tsconfig.json": JSON.stringify({
references: [
{ path: "./shared/tsconfig.json" },
{ path: "./webpack/tsconfig.json" }
],
files: []
}),
"/src/shared/tsconfig-base.json": JSON.stringify({
include: ["./typings-base/"]
}),
"/src/shared/typings-base/globals.d.ts": `type Unrestricted = any;`,
"/src/shared/tsconfig.json": JSON.stringify({
extends: "./tsconfig-base.json",
compilerOptions: {
composite: true,
outDir: "../target-tsc-build/",
rootDir: ".."
},
files: ["./index.ts"]
}),
"/src/shared/index.ts": `export const a: Unrestricted = 1;`,
"/src/webpack/tsconfig.json": JSON.stringify({
extends: "../shared/tsconfig-base.json",
compilerOptions: {
composite: true,
outDir: "../target-tsc-build/",
rootDir: ".."
},
files: ["./index.ts"],
references: [{ path: "../shared/tsconfig.json" }]
}),
"/src/webpack/index.ts": `export const b: Unrestricted = 1;`,
});
}
verifyTsc({
scenario: "configFileExtends",
subScenario: "when building solution with projects extends config with include",
fs: getConfigExtendsWithIncludeFs,
commandLineArgs: ["--b", "/src/tsconfig.json", "--v", "--listFiles"],
});
verifyTsc({
scenario: "configFileExtends",
subScenario: "when building project uses reference and both extend config with include",
fs: getConfigExtendsWithIncludeFs,
commandLineArgs: ["--b", "/src/webpack/tsconfig.json", "--v", "--listFiles"],
});
});
}
@@ -0,0 +1,55 @@
namespace ts.projectSystem {
describe("unittests:: tsserver:: plugins loading", () => {
function createHostWithPlugin(files: readonly File[]) {
const host = createServerHost(files);
const pluginsLoaded: string[] = [];
host.require = (_initialPath, moduleName) => {
pluginsLoaded.push(moduleName);
return {
module: () => ({
create(info: server.PluginCreateInfo) {
return Harness.LanguageService.makeDefaultProxy(info);
}
}),
error: undefined
};
};
return { host, pluginsLoaded };
}
it("With local plugins", () => {
const expectedToLoad = ["@myscoped/plugin", "unscopedPlugin"];
const notToLoad = ["../myPlugin", "myPlugin/../malicious"];
const aTs: File = { path: "/a.ts", content: `class c { prop = "hello"; foo() { return this.prop; } }` };
const tsconfig: File = {
path: "/tsconfig.json",
content: JSON.stringify({
compilerOptions: {
plugins: [
...[...expectedToLoad, ...notToLoad].map(name => ({ name })),
{ transform: "some-transform" }
]
}
})
};
const { host, pluginsLoaded } = createHostWithPlugin([aTs, tsconfig, libFile]);
const service = createProjectService(host);
service.openClientFile(aTs.path);
assert.deepEqual(pluginsLoaded, expectedToLoad);
});
it("With global plugins", () => {
const expectedToLoad = ["@myscoped/plugin", "unscopedPlugin"];
const notToLoad = ["../myPlugin", "myPlugin/../malicious"];
const aTs: File = { path: "/a.ts", content: `class c { prop = "hello"; foo() { return this.prop; } }` };
const tsconfig: File = {
path: "/tsconfig.json",
content: "{}"
};
const { host, pluginsLoaded } = createHostWithPlugin([aTs, tsconfig, libFile]);
const service = createProjectService(host, { globalPlugins: [...expectedToLoad, ...notToLoad] });
service.openClientFile(aTs.path);
assert.deepEqual(pluginsLoaded, expectedToLoad);
});
});
}
+2 -4
View File
@@ -833,9 +833,7 @@ namespace ts.server {
exit() {
this.logger.info("Exiting...");
this.projectService.closeLog();
if (traceDir) {
tracing.stopTracing(ts.emptyArray);
}
tracing?.stopTracing(ts.emptyArray);
process.exit(0);
}
@@ -863,7 +861,7 @@ namespace ts.server {
? stripQuotes(commandLineTraceDir)
: process.env.TSS_TRACE;
if (traceDir) {
tracing.startTracing(tracing.Mode.Server, traceDir);
startTracing("server", traceDir);
}
const ioSession = new IOSession();
@@ -1,6 +1,6 @@
=== tests/cases/conformance/es6/templates/TemplateExpression1.ts ===
var v = `foo ${ a
>v : string
>`foo ${ a : `foo ${any}`
>`foo ${ a : string
>a : any
@@ -22,7 +22,7 @@ class Derived extends Base {
>console.log : (...data: any[]) => void
>console : Console
>log : (...data: any[]) => void
>`x was set to ${value}` : `x was set to ${number}`
>`x was set to ${value}` : string
>value : number
}
+7 -4
View File
@@ -14,7 +14,7 @@ and limitations under the License.
***************************************************************************** */
declare namespace ts {
const versionMajorMinor = "4.2";
const versionMajorMinor = "4.3";
/** The version of the TypeScript compiler release */
const version: string;
/**
@@ -2656,8 +2656,6 @@ declare namespace ts {
export interface TemplateLiteralType extends InstantiableType {
texts: readonly string[];
types: readonly Type[];
freshType: TemplateLiteralType;
regularType: TemplateLiteralType;
}
export interface StringMappingType extends InstantiableType {
symbol: Symbol;
@@ -5557,7 +5555,7 @@ declare namespace ts {
getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions | FormatCodeSettings): TextChange[];
getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[];
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[];
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion | undefined;
getDocCommentTemplateAtPosition(fileName: string, position: number, options?: DocCommentTemplateOptions): TextInsertion | undefined;
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
/**
* This will return a defined result if the position is after the `>` of the opening tag, or somewhere in the text, of a JSXElement with no closing tag.
@@ -6022,11 +6020,15 @@ declare namespace ts {
interface RenameInfoOptions {
readonly allowRenameOfImportPath?: boolean;
}
interface DocCommentTemplateOptions {
readonly generateReturnInDocTemplate?: boolean;
}
interface SignatureHelpParameter {
name: string;
documentation: SymbolDisplayPart[];
displayParts: SymbolDisplayPart[];
isOptional: boolean;
isRest?: boolean;
}
interface SelectionRange {
textSpan: TextSpan;
@@ -9047,6 +9049,7 @@ declare namespace ts.server.protocol {
readonly provideRefactorNotApplicableReason?: boolean;
readonly allowRenameOfImportPath?: boolean;
readonly includePackageJsonAutoImports?: "auto" | "on" | "off";
readonly generateReturnInDocTemplate?: boolean;
}
interface CompilerOptions {
allowJs?: boolean;
+6 -4
View File
@@ -14,7 +14,7 @@ and limitations under the License.
***************************************************************************** */
declare namespace ts {
const versionMajorMinor = "4.2";
const versionMajorMinor = "4.3";
/** The version of the TypeScript compiler release */
const version: string;
/**
@@ -2656,8 +2656,6 @@ declare namespace ts {
export interface TemplateLiteralType extends InstantiableType {
texts: readonly string[];
types: readonly Type[];
freshType: TemplateLiteralType;
regularType: TemplateLiteralType;
}
export interface StringMappingType extends InstantiableType {
symbol: Symbol;
@@ -5557,7 +5555,7 @@ declare namespace ts {
getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions | FormatCodeSettings): TextChange[];
getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[];
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[];
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion | undefined;
getDocCommentTemplateAtPosition(fileName: string, position: number, options?: DocCommentTemplateOptions): TextInsertion | undefined;
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
/**
* This will return a defined result if the position is after the `>` of the opening tag, or somewhere in the text, of a JSXElement with no closing tag.
@@ -6022,11 +6020,15 @@ declare namespace ts {
interface RenameInfoOptions {
readonly allowRenameOfImportPath?: boolean;
}
interface DocCommentTemplateOptions {
readonly generateReturnInDocTemplate?: boolean;
}
interface SignatureHelpParameter {
name: string;
documentation: SymbolDisplayPart[];
displayParts: SymbolDisplayPart[];
isOptional: boolean;
isRest?: boolean;
}
interface SelectionRange {
textSpan: TextSpan;
+6 -6
View File
@@ -5,7 +5,7 @@ declare function tag(...x: any[]): any;
var a = `${123 + 456 as number}`;
>a : string
>`${123 + 456 as number}` : `${number}`
>`${123 + 456 as number}` : string
>123 + 456 as number : number
>123 + 456 : number
>123 : 123
@@ -13,7 +13,7 @@ var a = `${123 + 456 as number}`;
var b = `leading ${123 + 456 as number}`;
>b : string
>`leading ${123 + 456 as number}` : `leading ${number}`
>`leading ${123 + 456 as number}` : string
>123 + 456 as number : number
>123 + 456 : number
>123 : 123
@@ -21,7 +21,7 @@ var b = `leading ${123 + 456 as number}`;
var c = `${123 + 456 as number} trailing`;
>c : string
>`${123 + 456 as number} trailing` : `${number} trailing`
>`${123 + 456 as number} trailing` : string
>123 + 456 as number : number
>123 + 456 : number
>123 : 123
@@ -30,7 +30,7 @@ var c = `${123 + 456 as number} trailing`;
var d = `Hello ${123} World` as string;
>d : string
>`Hello ${123} World` as string : string
>`Hello ${123} World` : "Hello 123 World"
>`Hello ${123} World` : string
>123 : 123
var e = `Hello` as string;
@@ -43,7 +43,7 @@ var f = 1 + `${1} end of string` as string;
>1 + `${1} end of string` as string : string
>1 + `${1} end of string` : string
>1 : 1
>`${1} end of string` : "1 end of string"
>`${1} end of string` : string
>1 : 1
var g = tag `Hello ${123} World` as string;
@@ -51,7 +51,7 @@ var g = tag `Hello ${123} World` as string;
>tag `Hello ${123} World` as string : string
>tag `Hello ${123} World` : any
>tag : (...x: any[]) => any
>`Hello ${123} World` : "Hello 123 World"
>`Hello ${123} World` : string
>123 : 123
var h = tag `Hello` as string;
@@ -8,7 +8,7 @@ var loop2 = loop1;
>loop1 : Symbol(loop1, Decl(loop.js, 0, 3))
module.exports = loop2;
>module.exports : Symbol("tests/cases/conformance/salsa/loop", Decl(loop.js, 0, 0))
>module.exports : Symbol(module.exports, Decl(loop.js, 0, 0))
>module : Symbol(export=, Decl(loop.js, 1, 18))
>exports : Symbol(export=, Decl(loop.js, 1, 18))
>loop2 : Symbol(loop2, Decl(loop.js, 1, 3))
@@ -10,7 +10,7 @@ var loop2 = loop1;
module.exports = loop2;
>module.exports = loop2 : any
>module.exports : any
>module : { "\"tests/cases/conformance/salsa/loop\"": any; }
>module : { exports: any; }
>exports : any
>loop2 : any
+1 -1
View File
@@ -260,7 +260,7 @@ declare const o5: <T>() => undefined | (() => void);
>o5 : <T>() => undefined | (() => void)
o5<number>()?.();
>o5<number>()?.() : void | undefined
>o5<number>()?.() : void
>o5<number>() : (() => void) | undefined
>o5 : <T>() => (() => void) | undefined
@@ -0,0 +1,25 @@
//// [callChainInference.ts]
// Repro from #42404
interface Y {
foo<T>(this: T, arg: keyof T): void;
a: number;
b: string;
}
declare const value: Y | undefined;
if (value) {
value?.foo("a");
}
value?.foo("a");
//// [callChainInference.js]
"use strict";
// Repro from #42404
if (value) {
value === null || value === void 0 ? void 0 : value.foo("a");
}
value === null || value === void 0 ? void 0 : value.foo("a");
@@ -0,0 +1,39 @@
=== tests/cases/conformance/expressions/optionalChaining/callChain/callChainInference.ts ===
// Repro from #42404
interface Y {
>Y : Symbol(Y, Decl(callChainInference.ts, 0, 0))
foo<T>(this: T, arg: keyof T): void;
>foo : Symbol(Y.foo, Decl(callChainInference.ts, 2, 13))
>T : Symbol(T, Decl(callChainInference.ts, 3, 8))
>this : Symbol(this, Decl(callChainInference.ts, 3, 11))
>T : Symbol(T, Decl(callChainInference.ts, 3, 8))
>arg : Symbol(arg, Decl(callChainInference.ts, 3, 19))
>T : Symbol(T, Decl(callChainInference.ts, 3, 8))
a: number;
>a : Symbol(Y.a, Decl(callChainInference.ts, 3, 40))
b: string;
>b : Symbol(Y.b, Decl(callChainInference.ts, 4, 14))
}
declare const value: Y | undefined;
>value : Symbol(value, Decl(callChainInference.ts, 8, 13))
>Y : Symbol(Y, Decl(callChainInference.ts, 0, 0))
if (value) {
>value : Symbol(value, Decl(callChainInference.ts, 8, 13))
value?.foo("a");
>value?.foo : Symbol(Y.foo, Decl(callChainInference.ts, 2, 13))
>value : Symbol(value, Decl(callChainInference.ts, 8, 13))
>foo : Symbol(Y.foo, Decl(callChainInference.ts, 2, 13))
}
value?.foo("a");
>value?.foo : Symbol(Y.foo, Decl(callChainInference.ts, 2, 13))
>value : Symbol(value, Decl(callChainInference.ts, 8, 13))
>foo : Symbol(Y.foo, Decl(callChainInference.ts, 2, 13))
@@ -0,0 +1,37 @@
=== tests/cases/conformance/expressions/optionalChaining/callChain/callChainInference.ts ===
// Repro from #42404
interface Y {
foo<T>(this: T, arg: keyof T): void;
>foo : <T>(this: T, arg: keyof T) => void
>this : T
>arg : keyof T
a: number;
>a : number
b: string;
>b : string
}
declare const value: Y | undefined;
>value : Y | undefined
if (value) {
>value : Y | undefined
value?.foo("a");
>value?.foo("a") : void
>value?.foo : <T>(this: T, arg: keyof T) => void
>value : Y
>foo : <T>(this: T, arg: keyof T) => void
>"a" : "a"
}
value?.foo("a");
>value?.foo("a") : void
>value?.foo : (<T>(this: T, arg: keyof T) => void) | undefined
>value : Y | undefined
>foo : (<T>(this: T, arg: keyof T) => void) | undefined
>"a" : "a"
@@ -4,7 +4,7 @@
* @return {any} I don't even know what this should return
*/
module.exports = C
>module.exports : Symbol("tests/cases/conformance/jsdoc/mod1", Decl(mod1.js, 0, 0))
>module.exports : Symbol(module.exports, Decl(mod1.js, 0, 0))
>module : Symbol(export=, Decl(mod1.js, 0, 0))
>exports : Symbol(export=, Decl(mod1.js, 0, 0))
>C : Symbol(C, Decl(mod1.js, 4, 18))
@@ -6,7 +6,7 @@
module.exports = C
>module.exports = C : typeof C
>module.exports : typeof C
>module : { "\"tests/cases/conformance/jsdoc/mod1\"": typeof C; }
>module : { exports: typeof C; }
>exports : typeof C
>C : typeof C
@@ -202,9 +202,9 @@ Object.defineProperty(module.exports, "thing", { value: "yes", writable: true })
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
>module.exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
>module : Symbol(module, Decl(mod2.js, 0, 22))
>exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
>exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
>"thing" : Symbol(thing, Decl(mod2.js, 0, 0))
>value : Symbol(value, Decl(mod2.js, 0, 48))
>writable : Symbol(writable, Decl(mod2.js, 0, 62))
@@ -213,9 +213,9 @@ Object.defineProperty(module.exports, "readonlyProp", { value: "Smith", writable
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
>module.exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
>module : Symbol(module, Decl(mod2.js, 0, 22))
>exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
>exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
>"readonlyProp" : Symbol(readonlyProp, Decl(mod2.js, 0, 81))
>value : Symbol(value, Decl(mod2.js, 1, 55))
>writable : Symbol(writable, Decl(mod2.js, 1, 71))
@@ -224,9 +224,9 @@ Object.defineProperty(module.exports, "rwAccessors", { get() { return 98122 }, s
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
>module.exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
>module : Symbol(module, Decl(mod2.js, 0, 22))
>exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
>exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
>"rwAccessors" : Symbol(rwAccessors, Decl(mod2.js, 1, 91))
>get : Symbol(get, Decl(mod2.js, 2, 54))
>set : Symbol(set, Decl(mod2.js, 2, 78))
@@ -236,9 +236,9 @@ Object.defineProperty(module.exports, "readonlyAccessor", { get() { return 21.75
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
>module.exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
>module : Symbol(module, Decl(mod2.js, 0, 22))
>exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
>exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
>"readonlyAccessor" : Symbol(readonlyAccessor, Decl(mod2.js, 2, 104))
>get : Symbol(get, Decl(mod2.js, 3, 59))
@@ -246,9 +246,9 @@ Object.defineProperty(module.exports, "setonlyAccessor", {
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
>module.exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
>module.exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
>module : Symbol(module, Decl(mod2.js, 0, 22))
>exports : Symbol("tests/cases/conformance/jsdoc/mod2", Decl(mod2.js, 0, 0))
>exports : Symbol(module.exports, Decl(mod2.js, 0, 0))
>"setonlyAccessor" : Symbol(setonlyAccessor, Decl(mod2.js, 3, 86))
/** @param {string} str */
@@ -255,9 +255,9 @@ Object.defineProperty(module.exports, "thing", { value: "yes", writable: true })
>Object.defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
>module.exports : typeof import("tests/cases/conformance/jsdoc/mod2")
>module : { "\"tests/cases/conformance/jsdoc/mod2\"": typeof import("tests/cases/conformance/jsdoc/mod2"); }
>exports : typeof import("tests/cases/conformance/jsdoc/mod2")
>module.exports : typeof module.exports
>module : { exports: typeof module.exports; }
>exports : typeof module.exports
>"thing" : "thing"
>{ value: "yes", writable: true } : { value: string; writable: true; }
>value : string
@@ -270,9 +270,9 @@ Object.defineProperty(module.exports, "readonlyProp", { value: "Smith", writable
>Object.defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
>module.exports : typeof import("tests/cases/conformance/jsdoc/mod2")
>module : { "\"tests/cases/conformance/jsdoc/mod2\"": typeof import("tests/cases/conformance/jsdoc/mod2"); }
>exports : typeof import("tests/cases/conformance/jsdoc/mod2")
>module.exports : typeof module.exports
>module : { exports: typeof module.exports; }
>exports : typeof module.exports
>"readonlyProp" : "readonlyProp"
>{ value: "Smith", writable: false } : { value: string; writable: false; }
>value : string
@@ -285,9 +285,9 @@ Object.defineProperty(module.exports, "rwAccessors", { get() { return 98122 }, s
>Object.defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
>module.exports : typeof import("tests/cases/conformance/jsdoc/mod2")
>module : { "\"tests/cases/conformance/jsdoc/mod2\"": typeof import("tests/cases/conformance/jsdoc/mod2"); }
>exports : typeof import("tests/cases/conformance/jsdoc/mod2")
>module.exports : typeof module.exports
>module : { exports: typeof module.exports; }
>exports : typeof module.exports
>"rwAccessors" : "rwAccessors"
>{ get() { return 98122 }, set(_) { /*ignore*/ } } : { get(): number; set(_: any): void; }
>get : () => number
@@ -300,9 +300,9 @@ Object.defineProperty(module.exports, "readonlyAccessor", { get() { return 21.75
>Object.defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
>module.exports : typeof import("tests/cases/conformance/jsdoc/mod2")
>module : { "\"tests/cases/conformance/jsdoc/mod2\"": typeof import("tests/cases/conformance/jsdoc/mod2"); }
>exports : typeof import("tests/cases/conformance/jsdoc/mod2")
>module.exports : typeof module.exports
>module : { exports: typeof module.exports; }
>exports : typeof module.exports
>"readonlyAccessor" : "readonlyAccessor"
>{ get() { return 21.75 } } : { get(): number; }
>get : () => number
@@ -313,9 +313,9 @@ Object.defineProperty(module.exports, "setonlyAccessor", {
>Object.defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any
>module.exports : typeof import("tests/cases/conformance/jsdoc/mod2")
>module : { "\"tests/cases/conformance/jsdoc/mod2\"": typeof import("tests/cases/conformance/jsdoc/mod2"); }
>exports : typeof import("tests/cases/conformance/jsdoc/mod2")
>module.exports : typeof module.exports
>module : { exports: typeof module.exports; }
>exports : typeof module.exports
>"setonlyAccessor" : "setonlyAccessor"
>{ /** @param {string} str */ set(str) { this.rwAccessors = Number(str) }} : { set(str: string): void; }
@@ -170,7 +170,7 @@ Object.defineProperty(Person.prototype, "setonlyAccessor", {
}
});
module.exports = Person;
>module.exports : Symbol("tests/cases/conformance/jsdoc/mod1", Decl(mod1.js, 0, 0))
>module.exports : Symbol(module.exports, Decl(mod1.js, 0, 0))
>module : Symbol(export=, Decl(mod1.js, 19, 3))
>exports : Symbol(export=, Decl(mod1.js, 19, 3))
>Person : Symbol(Person, Decl(mod1.js, 0, 0))
@@ -214,7 +214,7 @@ Object.defineProperty(Person.prototype, "setonlyAccessor", {
module.exports = Person;
>module.exports = Person : typeof Person
>module.exports : typeof Person
>module : { "\"tests/cases/conformance/jsdoc/mod1\"": typeof Person; }
>module : { exports: typeof Person; }
>exports : typeof Person
>Person : typeof Person
@@ -10,7 +10,7 @@ let n = Math.random();
let s = `${n}`;
>s : string
>`${n}` : `${number}`
>`${n}` : string
>n : number
const numericIndex = { [n]: 1 };
@@ -22,7 +22,7 @@ export = Foo;
/** @typedef {(foo: Foo) => string} FooFun */
module.exports = /** @type {FooFun} */(void 0);
>module.exports : Symbol("tests/cases/compiler/something", Decl(something.js, 0, 0))
>module.exports : Symbol(module.exports, Decl(something.js, 0, 0))
>module : Symbol(export=, Decl(something.js, 0, 0))
>exports : Symbol(export=, Decl(something.js, 0, 0))
@@ -24,7 +24,7 @@ export = Foo;
module.exports = /** @type {FooFun} */(void 0);
>module.exports = /** @type {FooFun} */(void 0) : (foo: Foo) => string
>module.exports : (foo: typeof import("tests/cases/compiler/file")) => string
>module : { "\"tests/cases/compiler/something\"": (foo: typeof import("tests/cases/compiler/file")) => string; }
>module : { exports: (foo: typeof import("tests/cases/compiler/file")) => string; }
>exports : (foo: typeof import("tests/cases/compiler/file")) => string
>(void 0) : FooFun
>void 0 : undefined
@@ -196,7 +196,7 @@ match(() => expected, (x = expected) => void 0);
>expected : Symbol(expected, Decl(index.js, 32, 5))
module.exports = x;
>module.exports : Symbol("tests/cases/conformance/jsdoc/index", Decl(index.js, 0, 0))
>module.exports : Symbol(module.exports, Decl(index.js, 0, 0))
>module : Symbol(export=, Decl(index.js, 41, 48))
>exports : Symbol(export=, Decl(index.js, 41, 48))
>x : Symbol(x, Decl(index.js, 0, 5), Decl(index.js, 1, 22), Decl(index.js, 2, 22), Decl(index.js, 3, 22), Decl(index.js, 4, 22) ... and 2 more)
@@ -249,7 +249,7 @@ match(() => expected, (x = expected) => void 0);
module.exports = x;
>module.exports = x : typeof x
>module.exports : typeof x
>module : { "\"tests/cases/conformance/jsdoc/index\"": typeof x; }
>module : { exports: typeof x; }
>exports : typeof x
>x : typeof x
@@ -17,9 +17,9 @@ const hardline = { type: "hard" }
>type : Symbol(type, Decl(first.js, 2, 18))
module.exports = {
>module.exports : Symbol("tests/cases/conformance/salsa/first", Decl(first.js, 0, 0))
>module.exports : Symbol(module.exports, Decl(first.js, 0, 0))
>module : Symbol(module, Decl(first.js, 2, 33))
>exports : Symbol("tests/cases/conformance/salsa/first", Decl(first.js, 0, 0))
>exports : Symbol(module.exports, Decl(first.js, 0, 0))
hardline
>hardline : Symbol(hardline, Decl(first.js, 3, 18))
@@ -28,7 +28,7 @@ module.exports = {
=== tests/cases/conformance/salsa/second.js ===
module.exports = {
>module.exports : Symbol("tests/cases/conformance/salsa/second", Decl(second.js, 0, 0))
>module.exports : Symbol(module.exports, Decl(second.js, 0, 0))
>module : Symbol(export=, Decl(second.js, 0, 0))
>exports : Symbol(export=, Decl(second.js, 0, 0))
@@ -20,10 +20,10 @@ const hardline = { type: "hard" }
>"hard" : "hard"
module.exports = {
>module.exports = { hardline} : typeof import("tests/cases/conformance/salsa/first")
>module.exports : typeof import("tests/cases/conformance/salsa/first")
>module : { "\"tests/cases/conformance/salsa/first\"": typeof import("tests/cases/conformance/salsa/first"); }
>exports : typeof import("tests/cases/conformance/salsa/first")
>module.exports = { hardline} : typeof module.exports
>module.exports : typeof module.exports
>module : { exports: typeof module.exports; }
>exports : typeof module.exports
>{ hardline} : { hardline: { type: string; }; }
hardline
@@ -35,7 +35,7 @@ module.exports = {
module.exports = {
>module.exports = { nested: require('./first')} : { nested: typeof import("tests/cases/conformance/salsa/first"); }
>module.exports : { nested: typeof import("tests/cases/conformance/salsa/first"); }
>module : { "\"tests/cases/conformance/salsa/second\"": { nested: typeof import("tests/cases/conformance/salsa/first"); }; }
>module : { exports: { nested: typeof import("tests/cases/conformance/salsa/first"); }; }
>exports : { nested: typeof import("tests/cases/conformance/salsa/first"); }
>{ nested: require('./first')} : { nested: typeof import("tests/cases/conformance/salsa/first"); }
@@ -1,8 +1,8 @@
=== tests/cases/compiler/index.js ===
module.exports = {}
>module.exports : Symbol("tests/cases/compiler/index", Decl(index.js, 0, 0))
>module.exports : Symbol(module.exports, Decl(index.js, 0, 0))
>module : Symbol(module, Decl(index.js, 0, 0))
>exports : Symbol("tests/cases/compiler/index", Decl(index.js, 0, 0))
>exports : Symbol(module.exports, Decl(index.js, 0, 0))
var x = 1
>x : Symbol(x, Decl(index.js, 1, 3))
@@ -1,9 +1,9 @@
=== tests/cases/compiler/index.js ===
module.exports = {}
>module.exports = {} : typeof import("tests/cases/compiler/index")
>module.exports : typeof import("tests/cases/compiler/index")
>module : { "\"tests/cases/compiler/index\"": typeof import("tests/cases/compiler/index"); }
>exports : typeof import("tests/cases/compiler/index")
>module.exports = {} : typeof module.exports
>module.exports : typeof module.exports
>module : { exports: typeof module.exports; }
>exports : typeof module.exports
>{} : {}
var x = 1
@@ -60,6 +60,6 @@ var v = {
[`hello ${a} bye`]() { }
>[`hello ${a} bye`] : () => void
>`hello ${a} bye` : `hello ${any} bye`
>`hello ${a} bye` : string
>a : any
}
@@ -60,6 +60,6 @@ var v = {
[`hello ${a} bye`]() { }
>[`hello ${a} bye`] : () => void
>`hello ${a} bye` : `hello ${any} bye`
>`hello ${a} bye` : string
>a : any
}
@@ -70,7 +70,7 @@ var v = {
get [`hello ${a} bye`]() { return 0; }
>[`hello ${a} bye`] : number
>`hello ${a} bye` : `hello ${any} bye`
>`hello ${a} bye` : string
>a : any
>0 : 0
}
@@ -70,7 +70,7 @@ var v = {
get [`hello ${a} bye`]() { return 0; }
>[`hello ${a} bye`] : number
>`hello ${a} bye` : `hello ${any} bye`
>`hello ${a} bye` : string
>a : any
>0 : 0
}
@@ -63,7 +63,7 @@ class C {
static [`hello ${a} bye`] = 0
>[`hello ${a} bye`] : number
>`hello ${a} bye` : `hello ${any} bye`
>`hello ${a} bye` : string
>a : any
>0 : 0
}
@@ -63,7 +63,7 @@ class C {
static [`hello ${a} bye`] = 0
>[`hello ${a} bye`] : number
>`hello ${a} bye` : `hello ${any} bye`
>`hello ${a} bye` : string
>a : any
>0 : 0
}
@@ -59,6 +59,6 @@ class C {
static [`hello ${a} bye`]() { }
>[`hello ${a} bye`] : () => void
>`hello ${a} bye` : `hello ${any} bye`
>`hello ${a} bye` : string
>a : any
}
@@ -59,6 +59,6 @@ class C {
static [`hello ${a} bye`]() { }
>[`hello ${a} bye`] : () => void
>`hello ${a} bye` : `hello ${any} bye`
>`hello ${a} bye` : string
>a : any
}
@@ -69,7 +69,7 @@ class C {
get [`hello ${a} bye`]() { return 0; }
>[`hello ${a} bye`] : number
>`hello ${a} bye` : `hello ${any} bye`
>`hello ${a} bye` : string
>a : any
>0 : 0
}
@@ -69,7 +69,7 @@ class C {
get [`hello ${a} bye`]() { return 0; }
>[`hello ${a} bye`] : number
>`hello ${a} bye` : `hello ${any} bye`
>`hello ${a} bye` : string
>a : any
>0 : 0
}
@@ -70,7 +70,7 @@ var v = {
[`hello ${a} bye`]: 0
>[`hello ${a} bye`] : number
>`hello ${a} bye` : `hello ${any} bye`
>`hello ${a} bye` : string
>a : any
>0 : 0
}
@@ -70,7 +70,7 @@ var v = {
[`hello ${a} bye`]: 0
>[`hello ${a} bye`] : number
>`hello ${a} bye` : `hello ${any} bye`
>`hello ${a} bye` : string
>a : any
>0 : 0
}
@@ -56,7 +56,7 @@ function A() { this.id = 1; }
>id : Symbol(A.id, Decl(other.js, 0, 14))
module.exports = A;
>module.exports : Symbol("tests/cases/conformance/salsa/other", Decl(other.js, 0, 0))
>module.exports : Symbol(module.exports, Decl(other.js, 0, 0))
>module : Symbol(export=, Decl(other.js, 0, 29))
>exports : Symbol(export=, Decl(other.js, 0, 29))
>A : Symbol(A, Decl(other.js, 0, 0))
@@ -71,7 +71,7 @@ function A() { this.id = 1; }
module.exports = A;
>module.exports = A : typeof A
>module.exports : typeof A
>module : { "\"tests/cases/conformance/salsa/other\"": typeof A; }
>module : { exports: typeof A; }
>exports : typeof A
>A : typeof A
@@ -103,7 +103,7 @@ module.exports.y = {
>module.exports.y : Symbol(y, Decl(test.js, 45, 9))
>module.exports : Symbol(y, Decl(test.js, 45, 9))
>module : Symbol(module, Decl(test.js, 45, 9))
>exports : Symbol("tests/cases/conformance/salsa/test", Decl(test.js, 0, 0))
>exports : Symbol(module.exports, Decl(test.js, 0, 0))
>y : Symbol(y, Decl(test.js, 45, 9))
status: "done",
@@ -115,9 +115,9 @@ module.exports.y = {
}
module.exports.y
>module.exports.y : Symbol(y, Decl(test.js, 45, 9))
>module.exports : Symbol("tests/cases/conformance/salsa/test", Decl(test.js, 0, 0))
>module.exports : Symbol(module.exports, Decl(test.js, 0, 0))
>module : Symbol(module, Decl(test.js, 45, 9))
>exports : Symbol("tests/cases/conformance/salsa/test", Decl(test.js, 0, 0))
>exports : Symbol(module.exports, Decl(test.js, 0, 0))
>y : Symbol(y, Decl(test.js, 45, 9))
// prototype-property assignment
@@ -165,7 +165,7 @@ F.prototype = {
// module.exports assignment
/** @type {{ status: 'done', m(n: number): void }} */
module.exports = {
>module.exports : Symbol("tests/cases/conformance/salsa/mod", Decl(mod.js, 0, 0))
>module.exports : Symbol(module.exports, Decl(mod.js, 0, 0))
>module : Symbol(export=, Decl(mod.js, 0, 0))
>exports : Symbol(export=, Decl(mod.js, 0, 0))
@@ -118,9 +118,9 @@ exports.x
module.exports.y = {
>module.exports.y = { status: "done", m(n) { }} : { status: "done"; m(n: number): void; }
>module.exports.y : DoneStatus
>module.exports : typeof import("tests/cases/conformance/salsa/test")
>module : { "\"tests/cases/conformance/salsa/test\"": typeof import("tests/cases/conformance/salsa/test"); }
>exports : typeof import("tests/cases/conformance/salsa/test")
>module.exports : typeof module.exports
>module : { exports: typeof module.exports; }
>exports : typeof module.exports
>y : DoneStatus
>{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; }
@@ -134,9 +134,9 @@ module.exports.y = {
}
module.exports.y
>module.exports.y : DoneStatus
>module.exports : typeof import("tests/cases/conformance/salsa/test")
>module : { "\"tests/cases/conformance/salsa/test\"": typeof import("tests/cases/conformance/salsa/test"); }
>exports : typeof import("tests/cases/conformance/salsa/test")
>module.exports : typeof module.exports
>module : { exports: typeof module.exports; }
>exports : typeof module.exports
>y : DoneStatus
// prototype-property assignment
@@ -192,7 +192,7 @@ F.prototype = {
module.exports = {
>module.exports = { status: "done", m(n) { }} : { status: 'done'; m(n: number): void; }
>module.exports : { status: "done"; m(n: number): void; }
>module : { "\"tests/cases/conformance/salsa/mod\"": { status: "done"; m(n: number): void; }; }
>module : { exports: { status: "done"; m(n: number): void; }; }
>exports : { status: "done"; m(n: number): void; }
>{ status: "done", m(n) { }} : { status: "done"; m(n: number): void; }
@@ -18,7 +18,6 @@ tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(112,1): error TS
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(112,1): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(130,5): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(134,1): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(153,9): error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation.
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(208,9): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(211,9): error TS2532: Object is possibly 'undefined'.
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(214,9): error TS2532: Object is possibly 'undefined'.
@@ -62,7 +61,7 @@ tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(518,13): error T
tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(567,21): error TS2532: Object is possibly 'undefined'.
==== tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts (62 errors) ====
==== tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts (61 errors) ====
// assignments in shortcutting chain
declare const o: undefined | {
[key: string]: any;
@@ -256,8 +255,6 @@ tests/cases/conformance/controlFlow/controlFlowOptionalChain.ts(567,21): error T
if (!!true) {
isDefined(maybeIsString);
maybeIsString?.(x);
~~~~~~~~~~~~~
!!! error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation.
x;
}
if (!!true) {
@@ -595,7 +595,7 @@ function f01(x: unknown) {
>true : true
maybeIsString?.(x);
>maybeIsString?.(x) : void | undefined
>maybeIsString?.(x) : void
>maybeIsString : ((value: unknown) => asserts value is string) | undefined
>x : unknown
@@ -13,7 +13,7 @@ class C extends B {
>body : () => void
super.m && super.m();
>super.m && super.m() : void | undefined
>super.m && super.m() : void
>super.m : (() => void) | undefined
>super : B
>m : (() => void) | undefined
@@ -23,7 +23,7 @@ class HelloWorld {
>Log.info : (msg: string) => void
>Log : { info(msg: string): void; }
>info : (msg: string) => void
>`Hello ${this.name}` : `Hello ${string}`
>`Hello ${this.name}` : string
>this.name : string
>this : this
>name : string
@@ -0,0 +1,53 @@
tests/cases/compiler/another.ts(11,1): error TS4094: Property '_assertIsStripped' of exported class expression may not be private or protected.
tests/cases/compiler/another.ts(11,1): error TS4094: Property '_onDispose' of exported class expression may not be private or protected.
tests/cases/compiler/first.ts(12,1): error TS4094: Property '_assertIsStripped' of exported class expression may not be private or protected.
tests/cases/compiler/first.ts(12,1): error TS4094: Property '_onDispose' of exported class expression may not be private or protected.
tests/cases/compiler/first.ts(13,14): error TS4094: Property '_assertIsStripped' of exported class expression may not be private or protected.
tests/cases/compiler/first.ts(13,14): error TS4094: Property '_onDispose' of exported class expression may not be private or protected.
==== tests/cases/compiler/first.ts (4 errors) ====
declare function mix<TMix>(mixin: TMix): TMix;
const DisposableMixin = class {
protected _onDispose() {
this._assertIsStripped()
}
private _assertIsStripped() {
}
};
// No error, but definition is wrong.
export default mix(DisposableMixin);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS4094: Property '_assertIsStripped' of exported class expression may not be private or protected.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS4094: Property '_onDispose' of exported class expression may not be private or protected.
export class Monitor extends mix(DisposableMixin) {
~~~~~~~
!!! error TS4094: Property '_assertIsStripped' of exported class expression may not be private or protected.
~~~~~~~
!!! error TS4094: Property '_onDispose' of exported class expression may not be private or protected.
protected _onDispose() {
}
}
==== tests/cases/compiler/another.ts (2 errors) ====
declare function mix<TMix>(mixin: TMix): TMix;
const DisposableMixin = class {
protected _onDispose() {
this._assertIsStripped()
}
private _assertIsStripped() {
}
};
export default class extends mix(DisposableMixin) {
~~~~~~
!!! error TS4094: Property '_assertIsStripped' of exported class expression may not be private or protected.
~~~~~~
!!! error TS4094: Property '_onDispose' of exported class expression may not be private or protected.
protected _onDispose() {
}
}
@@ -0,0 +1,115 @@
//// [tests/cases/compiler/declarationEmitMixinPrivateProtected.ts] ////
//// [first.ts]
declare function mix<TMix>(mixin: TMix): TMix;
const DisposableMixin = class {
protected _onDispose() {
this._assertIsStripped()
}
private _assertIsStripped() {
}
};
// No error, but definition is wrong.
export default mix(DisposableMixin);
export class Monitor extends mix(DisposableMixin) {
protected _onDispose() {
}
}
//// [another.ts]
declare function mix<TMix>(mixin: TMix): TMix;
const DisposableMixin = class {
protected _onDispose() {
this._assertIsStripped()
}
private _assertIsStripped() {
}
};
export default class extends mix(DisposableMixin) {
protected _onDispose() {
}
}
//// [first.js]
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
exports.__esModule = true;
exports.Monitor = void 0;
var DisposableMixin = /** @class */ (function () {
function class_1() {
}
class_1.prototype._onDispose = function () {
this._assertIsStripped();
};
class_1.prototype._assertIsStripped = function () {
};
return class_1;
}());
// No error, but definition is wrong.
exports["default"] = mix(DisposableMixin);
var Monitor = /** @class */ (function (_super) {
__extends(Monitor, _super);
function Monitor() {
return _super !== null && _super.apply(this, arguments) || this;
}
Monitor.prototype._onDispose = function () {
};
return Monitor;
}(mix(DisposableMixin)));
exports.Monitor = Monitor;
//// [another.js]
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
exports.__esModule = true;
var DisposableMixin = /** @class */ (function () {
function class_1() {
}
class_1.prototype._onDispose = function () {
this._assertIsStripped();
};
class_1.prototype._assertIsStripped = function () {
};
return class_1;
}());
var default_1 = /** @class */ (function (_super) {
__extends(default_1, _super);
function default_1() {
return _super !== null && _super.apply(this, arguments) || this;
}
default_1.prototype._onDispose = function () {
};
return default_1;
}(mix(DisposableMixin)));
exports["default"] = default_1;
@@ -0,0 +1,71 @@
=== tests/cases/compiler/first.ts ===
declare function mix<TMix>(mixin: TMix): TMix;
>mix : Symbol(mix, Decl(first.ts, 0, 0))
>TMix : Symbol(TMix, Decl(first.ts, 0, 21))
>mixin : Symbol(mixin, Decl(first.ts, 0, 27))
>TMix : Symbol(TMix, Decl(first.ts, 0, 21))
>TMix : Symbol(TMix, Decl(first.ts, 0, 21))
const DisposableMixin = class {
>DisposableMixin : Symbol(DisposableMixin, Decl(first.ts, 2, 5))
protected _onDispose() {
>_onDispose : Symbol(DisposableMixin._onDispose, Decl(first.ts, 2, 31))
this._assertIsStripped()
>this._assertIsStripped : Symbol(DisposableMixin._assertIsStripped, Decl(first.ts, 5, 5))
>this : Symbol(DisposableMixin, Decl(first.ts, 2, 23))
>_assertIsStripped : Symbol(DisposableMixin._assertIsStripped, Decl(first.ts, 5, 5))
}
private _assertIsStripped() {
>_assertIsStripped : Symbol(DisposableMixin._assertIsStripped, Decl(first.ts, 5, 5))
}
};
// No error, but definition is wrong.
export default mix(DisposableMixin);
>mix : Symbol(mix, Decl(first.ts, 0, 0))
>DisposableMixin : Symbol(DisposableMixin, Decl(first.ts, 2, 5))
export class Monitor extends mix(DisposableMixin) {
>Monitor : Symbol(Monitor, Decl(first.ts, 11, 36))
>mix : Symbol(mix, Decl(first.ts, 0, 0))
>DisposableMixin : Symbol(DisposableMixin, Decl(first.ts, 2, 5))
protected _onDispose() {
>_onDispose : Symbol(Monitor._onDispose, Decl(first.ts, 12, 51))
}
}
=== tests/cases/compiler/another.ts ===
declare function mix<TMix>(mixin: TMix): TMix;
>mix : Symbol(mix, Decl(another.ts, 0, 0))
>TMix : Symbol(TMix, Decl(another.ts, 0, 21))
>mixin : Symbol(mixin, Decl(another.ts, 0, 27))
>TMix : Symbol(TMix, Decl(another.ts, 0, 21))
>TMix : Symbol(TMix, Decl(another.ts, 0, 21))
const DisposableMixin = class {
>DisposableMixin : Symbol(DisposableMixin, Decl(another.ts, 2, 5))
protected _onDispose() {
>_onDispose : Symbol(DisposableMixin._onDispose, Decl(another.ts, 2, 31))
this._assertIsStripped()
>this._assertIsStripped : Symbol(DisposableMixin._assertIsStripped, Decl(another.ts, 5, 5))
>this : Symbol(DisposableMixin, Decl(another.ts, 2, 23))
>_assertIsStripped : Symbol(DisposableMixin._assertIsStripped, Decl(another.ts, 5, 5))
}
private _assertIsStripped() {
>_assertIsStripped : Symbol(DisposableMixin._assertIsStripped, Decl(another.ts, 5, 5))
}
};
export default class extends mix(DisposableMixin) {
>mix : Symbol(mix, Decl(another.ts, 0, 0))
>DisposableMixin : Symbol(DisposableMixin, Decl(another.ts, 2, 5))
protected _onDispose() {
>_onDispose : Symbol(default._onDispose, Decl(another.ts, 10, 51))
}
}
@@ -0,0 +1,72 @@
=== tests/cases/compiler/first.ts ===
declare function mix<TMix>(mixin: TMix): TMix;
>mix : <TMix>(mixin: TMix) => TMix
>mixin : TMix
const DisposableMixin = class {
>DisposableMixin : typeof DisposableMixin
>class { protected _onDispose() { this._assertIsStripped() } private _assertIsStripped() { }} : typeof DisposableMixin
protected _onDispose() {
>_onDispose : () => void
this._assertIsStripped()
>this._assertIsStripped() : void
>this._assertIsStripped : () => void
>this : this
>_assertIsStripped : () => void
}
private _assertIsStripped() {
>_assertIsStripped : () => void
}
};
// No error, but definition is wrong.
export default mix(DisposableMixin);
>mix(DisposableMixin) : typeof DisposableMixin
>mix : <TMix>(mixin: TMix) => TMix
>DisposableMixin : typeof DisposableMixin
export class Monitor extends mix(DisposableMixin) {
>Monitor : Monitor
>mix(DisposableMixin) : DisposableMixin
>mix : <TMix>(mixin: TMix) => TMix
>DisposableMixin : typeof DisposableMixin
protected _onDispose() {
>_onDispose : () => void
}
}
=== tests/cases/compiler/another.ts ===
declare function mix<TMix>(mixin: TMix): TMix;
>mix : <TMix>(mixin: TMix) => TMix
>mixin : TMix
const DisposableMixin = class {
>DisposableMixin : typeof DisposableMixin
>class { protected _onDispose() { this._assertIsStripped() } private _assertIsStripped() { }} : typeof DisposableMixin
protected _onDispose() {
>_onDispose : () => void
this._assertIsStripped()
>this._assertIsStripped() : void
>this._assertIsStripped : () => void
>this : this
>_assertIsStripped : () => void
}
private _assertIsStripped() {
>_assertIsStripped : () => void
}
};
export default class extends mix(DisposableMixin) {
>mix(DisposableMixin) : DisposableMixin
>mix : <TMix>(mixin: TMix) => TMix
>DisposableMixin : typeof DisposableMixin
protected _onDispose() {
>_onDispose : () => void
}
}
@@ -16,7 +16,7 @@ function register(kind: string): void | never {
throw new Error(`Class with kind "${kind}" is already registered.`);
>new Error(`Class with kind "${kind}" is already registered.`) : Error
>Error : ErrorConstructor
>`Class with kind "${kind}" is already registered.` : `Class with kind "${string}" is already registered.`
>`Class with kind "${kind}" is already registered.` : string
>kind : string
}
kindCache[kind] = true;
@@ -34,7 +34,7 @@ const Parent: SFC<Props> = ({
const Child: SFC<Props> = ({
>Child : SFC<Props>
>({ children, name = "Artemis", ...props}) => `name: ${name} props: ${JSON.stringify(props)}` : ({ children, name, ...props }: Props & { children?: any; }) => `name: Apollo props: ${string}` | `name: Artemis props: ${string}` | `name: Dionysus props: ${string}` | `name: Persephone props: ${string}`
>({ children, name = "Artemis", ...props}) => `name: ${name} props: ${JSON.stringify(props)}` : ({ children, name, ...props }: Props & { children?: any; }) => string
children,
>children : any
@@ -47,7 +47,7 @@ const Child: SFC<Props> = ({
>props : {}
}) => `name: ${name} props: ${JSON.stringify(props)}`;
>`name: ${name} props: ${JSON.stringify(props)}` : `name: Apollo props: ${string}` | `name: Artemis props: ${string}` | `name: Dionysus props: ${string}` | `name: Persephone props: ${string}`
>`name: ${name} props: ${JSON.stringify(props)}` : string
>name : "Apollo" | "Artemis" | "Dionysus" | "Persephone"
>JSON.stringify(props) : string
>JSON.stringify : { (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; }
@@ -75,10 +75,10 @@ class C2 extends C1<number, string, boolean> {
>C1 : C1<number, string, boolean>
public doSomethingWithSuperProperties() {
>doSomethingWithSuperProperties : () => `${any} ${any} ${any}`
>doSomethingWithSuperProperties : () => string
return `${this.a} ${this.b} ${this.c}`;
>`${this.a} ${this.b} ${this.c}` : `${any} ${any} ${any}`
>`${this.a} ${this.b} ${this.c}` : string
>this.a : any
>this : this
>a : any
@@ -343,7 +343,7 @@ const u: U = {} as any;
>{} : {}
u.a && u.b && f(u.a, u.b);
>u.a && u.b && f(u.a, u.b) : void | "" | undefined
>u.a && u.b && f(u.a, u.b) : void | ""
>u.a && u.b : string | undefined
>u.a : string | undefined
>u : U
@@ -361,7 +361,7 @@ u.a && u.b && f(u.a, u.b);
>b : string
u.b && u.a && f(u.a, u.b);
>u.b && u.a && f(u.a, u.b) : void | "" | undefined
>u.b && u.a && f(u.a, u.b) : void | ""
>u.b && u.a : string | undefined
>u.b : string | undefined
>u : U
@@ -1,9 +1,10 @@
tests/cases/compiler/emitClassExpressionInDeclarationFile2.ts(1,12): error TS4094: Property 'p' of exported class expression may not be private or protected.
tests/cases/compiler/emitClassExpressionInDeclarationFile2.ts(1,12): error TS4094: Property 'ps' of exported class expression may not be private or protected.
tests/cases/compiler/emitClassExpressionInDeclarationFile2.ts(16,17): error TS4094: Property 'property' of exported class expression may not be private or protected.
tests/cases/compiler/emitClassExpressionInDeclarationFile2.ts(23,14): error TS4094: Property 'property' of exported class expression may not be private or protected.
==== tests/cases/compiler/emitClassExpressionInDeclarationFile2.ts (3 errors) ====
==== tests/cases/compiler/emitClassExpressionInDeclarationFile2.ts (4 errors) ====
export var noPrivates = class {
~~~~~~~~~~
!!! error TS4094: Property 'p' of exported class expression may not be private or protected.
@@ -33,6 +34,8 @@ tests/cases/compiler/emitClassExpressionInDeclarationFile2.ts(16,17): error TS40
}
export class Test extends WithTags(FooItem) {}
~~~~
!!! error TS4094: Property 'property' of exported class expression may not be private or protected.
const test = new Test();
@@ -12,14 +12,14 @@ var s;
// With TemplateTail
`${t1 ** -t2} world`;
>`${t1 ** -t2} world` : `${number} world`
>`${t1 ** -t2} world` : string
>t1 ** -t2 : number
>t1 : number
>-t2 : number
>t2 : number
`${(-t1) ** t2 - t1} world`;
>`${(-t1) ** t2 - t1} world` : `${number} world`
>`${(-t1) ** t2 - t1} world` : string
>(-t1) ** t2 - t1 : number
>(-t1) ** t2 : number
>(-t1) : number
@@ -29,7 +29,7 @@ var s;
>t1 : number
`${(-++t1) ** t2 - t1} world`;
>`${(-++t1) ** t2 - t1} world` : `${number} world`
>`${(-++t1) ** t2 - t1} world` : string
>(-++t1) ** t2 - t1 : number
>(-++t1) ** t2 : number
>(-++t1) : number
@@ -40,7 +40,7 @@ var s;
>t1 : number
`${(-t1++) ** t2 - t1} world`;
>`${(-t1++) ** t2 - t1} world` : `${number} world`
>`${(-t1++) ** t2 - t1} world` : string
>(-t1++) ** t2 - t1 : number
>(-t1++) ** t2 : number
>(-t1++) : number
@@ -51,7 +51,7 @@ var s;
>t1 : number
`${(~t1) ** t2 ** --t1 } world`;
>`${(~t1) ** t2 ** --t1 } world` : `${number} world`
>`${(~t1) ** t2 ** --t1 } world` : string
>(~t1) ** t2 ** --t1 : number
>(~t1) : number
>~t1 : number
@@ -62,7 +62,7 @@ var s;
>t1 : number
`${typeof (t1 ** t2 ** t1) } world`;
>`${typeof (t1 ** t2 ** t1) } world` : "string world" | "number world" | "bigint world" | "boolean world" | "symbol world" | "undefined world" | "object world" | "function world"
>`${typeof (t1 ** t2 ** t1) } world` : string
>typeof (t1 ** t2 ** t1) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>(t1 ** t2 ** t1) : number
>t1 ** t2 ** t1 : number
@@ -73,7 +73,7 @@ var s;
// TempateHead & TemplateTail are empt
`${t1 ** -t2} hello world ${t1 ** -t2}`;
>`${t1 ** -t2} hello world ${t1 ** -t2}` : `${number} hello world ${number}`
>`${t1 ** -t2} hello world ${t1 ** -t2}` : string
>t1 ** -t2 : number
>t1 : number
>-t2 : number
@@ -84,7 +84,7 @@ var s;
>t2 : number
`${(-t1) ** t2 - t1} hello world ${(-t1) ** t2 - t1}`;
>`${(-t1) ** t2 - t1} hello world ${(-t1) ** t2 - t1}` : `${number} hello world ${number}`
>`${(-t1) ** t2 - t1} hello world ${(-t1) ** t2 - t1}` : string
>(-t1) ** t2 - t1 : number
>(-t1) ** t2 : number
>(-t1) : number
@@ -101,7 +101,7 @@ var s;
>t1 : number
`${(-++t1) ** t2 - t1} hello world ${t1 ** (-++t1) **- t1}`;
>`${(-++t1) ** t2 - t1} hello world ${t1 ** (-++t1) **- t1}` : `${number} hello world ${number}`
>`${(-++t1) ** t2 - t1} hello world ${t1 ** (-++t1) **- t1}` : string
>(-++t1) ** t2 - t1 : number
>(-++t1) ** t2 : number
>(-++t1) : number
@@ -121,7 +121,7 @@ var s;
>t1 : number
`${(-t1++) ** t2 - t1} hello world ${t2 ** (-t1++) ** - t1}`;
>`${(-t1++) ** t2 - t1} hello world ${t2 ** (-t1++) ** - t1}` : `${number} hello world ${number}`
>`${(-t1++) ** t2 - t1} hello world ${t2 ** (-t1++) ** - t1}` : string
>(-t1++) ** t2 - t1 : number
>(-t1++) ** t2 : number
>(-t1++) : number
@@ -141,7 +141,7 @@ var s;
>t1 : number
`${(~t1) ** t2 ** --t1 } hello world ${(~t1) ** t2 ** --t1 }`;
>`${(~t1) ** t2 ** --t1 } hello world ${(~t1) ** t2 ** --t1 }` : `${number} hello world ${number}`
>`${(~t1) ** t2 ** --t1 } hello world ${(~t1) ** t2 ** --t1 }` : string
>(~t1) ** t2 ** --t1 : number
>(~t1) : number
>~t1 : number
@@ -160,7 +160,7 @@ var s;
>t1 : number
`${typeof (t1 ** t2 ** t1)} hello world ${typeof (t1 ** t2 ** t1)}`;
>`${typeof (t1 ** t2 ** t1)} hello world ${typeof (t1 ** t2 ** t1)}` : "string hello world string" | "string hello world number" | "string hello world bigint" | "string hello world boolean" | "string hello world symbol" | "string hello world undefined" | "string hello world object" | "string hello world function" | "number hello world string" | "number hello world number" | "number hello world bigint" | "number hello world boolean" | "number hello world symbol" | "number hello world undefined" | "number hello world object" | "number hello world function" | "bigint hello world string" | "bigint hello world number" | "bigint hello world bigint" | "bigint hello world boolean" | "bigint hello world symbol" | "bigint hello world undefined" | "bigint hello world object" | "bigint hello world function" | "boolean hello world string" | "boolean hello world number" | "boolean hello world bigint" | "boolean hello world boolean" | "boolean hello world symbol" | "boolean hello world undefined" | "boolean hello world object" | "boolean hello world function" | "symbol hello world string" | "symbol hello world number" | "symbol hello world bigint" | "symbol hello world boolean" | "symbol hello world symbol" | "symbol hello world undefined" | "symbol hello world object" | "symbol hello world function" | "undefined hello world string" | "undefined hello world number" | "undefined hello world bigint" | "undefined hello world boolean" | "undefined hello world symbol" | "undefined hello world undefined" | "undefined hello world object" | "undefined hello world function" | "object hello world string" | "object hello world number" | "object hello world bigint" | "object hello world boolean" | "object hello world symbol" | "object hello world undefined" | "object hello world object" | "object hello world function" | "function hello world string" | "function hello world number" | "function hello world bigint" | "function hello world boolean" | "function hello world symbol" | "function hello world undefined" | "function hello world object" | "function hello world function"
>`${typeof (t1 ** t2 ** t1)} hello world ${typeof (t1 ** t2 ** t1)}` : string
>typeof (t1 ** t2 ** t1) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>(t1 ** t2 ** t1) : number
>t1 ** t2 ** t1 : number
@@ -178,7 +178,7 @@ var s;
// With templateHead
`hello ${(-t1) ** t2 - t1}`;
>`hello ${(-t1) ** t2 - t1}` : `hello ${number}`
>`hello ${(-t1) ** t2 - t1}` : string
>(-t1) ** t2 - t1 : number
>(-t1) ** t2 : number
>(-t1) : number
@@ -188,7 +188,7 @@ var s;
>t1 : number
`hello ${(-++t1) ** t2 - t1}`;
>`hello ${(-++t1) ** t2 - t1}` : `hello ${number}`
>`hello ${(-++t1) ** t2 - t1}` : string
>(-++t1) ** t2 - t1 : number
>(-++t1) ** t2 : number
>(-++t1) : number
@@ -199,7 +199,7 @@ var s;
>t1 : number
`hello ${(-t1++) ** t2 - t1}`;
>`hello ${(-t1++) ** t2 - t1}` : `hello ${number}`
>`hello ${(-t1++) ** t2 - t1}` : string
>(-t1++) ** t2 - t1 : number
>(-t1++) ** t2 : number
>(-t1++) : number
@@ -210,7 +210,7 @@ var s;
>t1 : number
`hello ${(~t1) ** t2 ** --t1 }`;
>`hello ${(~t1) ** t2 ** --t1 }` : `hello ${number}`
>`hello ${(~t1) ** t2 ** --t1 }` : string
>(~t1) ** t2 ** --t1 : number
>(~t1) : number
>~t1 : number
@@ -221,7 +221,7 @@ var s;
>t1 : number
`hello ${typeof (t1 ** t2 ** t1)}`;
>`hello ${typeof (t1 ** t2 ** t1)}` : "hello string" | "hello number" | "hello bigint" | "hello boolean" | "hello symbol" | "hello undefined" | "hello object" | "hello function"
>`hello ${typeof (t1 ** t2 ** t1)}` : string
>typeof (t1 ** t2 ** t1) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>(t1 ** t2 ** t1) : number
>t1 ** t2 ** t1 : number
@@ -12,14 +12,14 @@ var s;
// With TemplateTail
`${t1 ** -t2} world`;
>`${t1 ** -t2} world` : `${number} world`
>`${t1 ** -t2} world` : string
>t1 ** -t2 : number
>t1 : number
>-t2 : number
>t2 : number
`${(-t1) ** t2 - t1} world`;
>`${(-t1) ** t2 - t1} world` : `${number} world`
>`${(-t1) ** t2 - t1} world` : string
>(-t1) ** t2 - t1 : number
>(-t1) ** t2 : number
>(-t1) : number
@@ -29,7 +29,7 @@ var s;
>t1 : number
`${(-++t1) ** t2 - t1} world`;
>`${(-++t1) ** t2 - t1} world` : `${number} world`
>`${(-++t1) ** t2 - t1} world` : string
>(-++t1) ** t2 - t1 : number
>(-++t1) ** t2 : number
>(-++t1) : number
@@ -40,7 +40,7 @@ var s;
>t1 : number
`${(-t1++) ** t2 - t1} world`;
>`${(-t1++) ** t2 - t1} world` : `${number} world`
>`${(-t1++) ** t2 - t1} world` : string
>(-t1++) ** t2 - t1 : number
>(-t1++) ** t2 : number
>(-t1++) : number
@@ -51,7 +51,7 @@ var s;
>t1 : number
`${(~t1) ** t2 ** --t1 } world`;
>`${(~t1) ** t2 ** --t1 } world` : `${number} world`
>`${(~t1) ** t2 ** --t1 } world` : string
>(~t1) ** t2 ** --t1 : number
>(~t1) : number
>~t1 : number
@@ -62,7 +62,7 @@ var s;
>t1 : number
`${typeof (t1 ** t2 ** t1) } world`;
>`${typeof (t1 ** t2 ** t1) } world` : "string world" | "number world" | "bigint world" | "boolean world" | "symbol world" | "undefined world" | "object world" | "function world"
>`${typeof (t1 ** t2 ** t1) } world` : string
>typeof (t1 ** t2 ** t1) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>(t1 ** t2 ** t1) : number
>t1 ** t2 ** t1 : number
@@ -73,7 +73,7 @@ var s;
// TempateHead & TemplateTail are empt
`${t1 ** -t2} hello world ${t1 ** -t2}`;
>`${t1 ** -t2} hello world ${t1 ** -t2}` : `${number} hello world ${number}`
>`${t1 ** -t2} hello world ${t1 ** -t2}` : string
>t1 ** -t2 : number
>t1 : number
>-t2 : number
@@ -84,7 +84,7 @@ var s;
>t2 : number
`${(-t1) ** t2 - t1} hello world ${(-t1) ** t2 - t1}`;
>`${(-t1) ** t2 - t1} hello world ${(-t1) ** t2 - t1}` : `${number} hello world ${number}`
>`${(-t1) ** t2 - t1} hello world ${(-t1) ** t2 - t1}` : string
>(-t1) ** t2 - t1 : number
>(-t1) ** t2 : number
>(-t1) : number
@@ -101,7 +101,7 @@ var s;
>t1 : number
`${(-++t1) ** t2 - t1} hello world ${t1 ** (-++t1) **- t1}`;
>`${(-++t1) ** t2 - t1} hello world ${t1 ** (-++t1) **- t1}` : `${number} hello world ${number}`
>`${(-++t1) ** t2 - t1} hello world ${t1 ** (-++t1) **- t1}` : string
>(-++t1) ** t2 - t1 : number
>(-++t1) ** t2 : number
>(-++t1) : number
@@ -121,7 +121,7 @@ var s;
>t1 : number
`${(-t1++) ** t2 - t1} hello world ${t2 ** (-t1++) ** - t1}`;
>`${(-t1++) ** t2 - t1} hello world ${t2 ** (-t1++) ** - t1}` : `${number} hello world ${number}`
>`${(-t1++) ** t2 - t1} hello world ${t2 ** (-t1++) ** - t1}` : string
>(-t1++) ** t2 - t1 : number
>(-t1++) ** t2 : number
>(-t1++) : number
@@ -141,7 +141,7 @@ var s;
>t1 : number
`${(~t1) ** t2 ** --t1 } hello world ${(~t1) ** t2 ** --t1 }`;
>`${(~t1) ** t2 ** --t1 } hello world ${(~t1) ** t2 ** --t1 }` : `${number} hello world ${number}`
>`${(~t1) ** t2 ** --t1 } hello world ${(~t1) ** t2 ** --t1 }` : string
>(~t1) ** t2 ** --t1 : number
>(~t1) : number
>~t1 : number
@@ -160,7 +160,7 @@ var s;
>t1 : number
`${typeof (t1 ** t2 ** t1)} hello world ${typeof (t1 ** t2 ** t1)}`;
>`${typeof (t1 ** t2 ** t1)} hello world ${typeof (t1 ** t2 ** t1)}` : "string hello world string" | "string hello world number" | "string hello world bigint" | "string hello world boolean" | "string hello world symbol" | "string hello world undefined" | "string hello world object" | "string hello world function" | "number hello world string" | "number hello world number" | "number hello world bigint" | "number hello world boolean" | "number hello world symbol" | "number hello world undefined" | "number hello world object" | "number hello world function" | "bigint hello world string" | "bigint hello world number" | "bigint hello world bigint" | "bigint hello world boolean" | "bigint hello world symbol" | "bigint hello world undefined" | "bigint hello world object" | "bigint hello world function" | "boolean hello world string" | "boolean hello world number" | "boolean hello world bigint" | "boolean hello world boolean" | "boolean hello world symbol" | "boolean hello world undefined" | "boolean hello world object" | "boolean hello world function" | "symbol hello world string" | "symbol hello world number" | "symbol hello world bigint" | "symbol hello world boolean" | "symbol hello world symbol" | "symbol hello world undefined" | "symbol hello world object" | "symbol hello world function" | "undefined hello world string" | "undefined hello world number" | "undefined hello world bigint" | "undefined hello world boolean" | "undefined hello world symbol" | "undefined hello world undefined" | "undefined hello world object" | "undefined hello world function" | "object hello world string" | "object hello world number" | "object hello world bigint" | "object hello world boolean" | "object hello world symbol" | "object hello world undefined" | "object hello world object" | "object hello world function" | "function hello world string" | "function hello world number" | "function hello world bigint" | "function hello world boolean" | "function hello world symbol" | "function hello world undefined" | "function hello world object" | "function hello world function"
>`${typeof (t1 ** t2 ** t1)} hello world ${typeof (t1 ** t2 ** t1)}` : string
>typeof (t1 ** t2 ** t1) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>(t1 ** t2 ** t1) : number
>t1 ** t2 ** t1 : number
@@ -178,7 +178,7 @@ var s;
// With templateHead
`hello ${(-t1) ** t2 - t1}`;
>`hello ${(-t1) ** t2 - t1}` : `hello ${number}`
>`hello ${(-t1) ** t2 - t1}` : string
>(-t1) ** t2 - t1 : number
>(-t1) ** t2 : number
>(-t1) : number
@@ -188,7 +188,7 @@ var s;
>t1 : number
`hello ${(-++t1) ** t2 - t1}`;
>`hello ${(-++t1) ** t2 - t1}` : `hello ${number}`
>`hello ${(-++t1) ** t2 - t1}` : string
>(-++t1) ** t2 - t1 : number
>(-++t1) ** t2 : number
>(-++t1) : number
@@ -199,7 +199,7 @@ var s;
>t1 : number
`hello ${(-t1++) ** t2 - t1}`;
>`hello ${(-t1++) ** t2 - t1}` : `hello ${number}`
>`hello ${(-t1++) ** t2 - t1}` : string
>(-t1++) ** t2 - t1 : number
>(-t1++) ** t2 : number
>(-t1++) : number
@@ -210,7 +210,7 @@ var s;
>t1 : number
`hello ${(~t1) ** t2 ** --t1 }`;
>`hello ${(~t1) ** t2 ** --t1 }` : `hello ${number}`
>`hello ${(~t1) ** t2 ** --t1 }` : string
>(~t1) ** t2 ** --t1 : number
>(~t1) : number
>~t1 : number
@@ -221,7 +221,7 @@ var s;
>t1 : number
`hello ${typeof (t1 ** t2 ** t1)}`;
>`hello ${typeof (t1 ** t2 ** t1)}` : "hello string" | "hello number" | "hello bigint" | "hello boolean" | "hello symbol" | "hello undefined" | "hello object" | "hello function"
>`hello ${typeof (t1 ** t2 ** t1)}` : string
>typeof (t1 ** t2 ** t1) : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>(t1 ** t2 ** t1) : number
>t1 ** t2 ** t1 : number

Some files were not shown because too many files have changed in this diff Show More