mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge remote-tracking branch 'origin/main' into release-5.6
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"reporter": ["lcovonly", "cobertura", "v8", "codecov"],
|
||||
"reporter": ["lcovonly", "cobertura", "v8", "v8-json", "codecov"],
|
||||
"src": "src",
|
||||
"include": ["src/**", "built/local/**"],
|
||||
"exclude": ["**/node_modules/**"],
|
||||
|
||||
+2
-2
@@ -59,8 +59,8 @@
|
||||
// Note: if adding new languages, make sure settings.template.json is updated too.
|
||||
// Also, if updating typescript, update the one in package.json.
|
||||
"plugins": [
|
||||
"https://plugins.dprint.dev/typescript-0.91.4.wasm",
|
||||
"https://plugins.dprint.dev/typescript-0.91.6.wasm",
|
||||
"https://plugins.dprint.dev/json-0.19.3.wasm",
|
||||
"https://plugins.dprint.dev/prettier-0.40.0.json@68c668863ec834d4be0f6f5ccaab415df75336a992aceb7eeeb14fdf096a9e9c"
|
||||
"https://plugins.dprint.dev/prettier-0.46.1.json@e5bd083088a8dfc6e5ce2d3c9bee81489b065bd5345ef55b59f5d96627928b7a"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ body:
|
||||
|
||||
Please keep and fill in the line that best applies.
|
||||
value: |
|
||||
- This is a crash
|
||||
- This changed between versions ______ and _______
|
||||
- This changed in commit or PR _______
|
||||
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
|
||||
|
||||
@@ -90,7 +90,7 @@ jobs:
|
||||
run: npm test -- --no-lint --coverage
|
||||
|
||||
- name: Upload coverage artifact
|
||||
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
|
||||
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
|
||||
with:
|
||||
name: coverage
|
||||
path: coverage
|
||||
@@ -334,7 +334,7 @@ jobs:
|
||||
|
||||
- name: Upload baseline diff artifact
|
||||
if: ${{ failure() && steps.check-baselines.conclusion == 'failure' }}
|
||||
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
|
||||
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
|
||||
with:
|
||||
name: fix_baselines.patch
|
||||
path: fix_baselines.patch
|
||||
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13
|
||||
uses: github/codeql-action/init@429e1977040da7a23b6822b13c129cd1ba93dbb2 # v3.26.2
|
||||
with:
|
||||
config-file: ./.github/codeql/codeql-configuration.yml
|
||||
# Override language selection by uncommenting this and choosing your languages
|
||||
@@ -56,7 +56,7 @@ jobs:
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below).
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13
|
||||
uses: github/codeql-action/autobuild@429e1977040da7a23b6822b13c129cd1ba93dbb2 # v3.26.2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||
@@ -70,4 +70,4 @@ jobs:
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13
|
||||
uses: github/codeql-action/analyze@429e1977040da7a23b6822b13c129cd1ba93dbb2 # v3.26.2
|
||||
|
||||
@@ -44,7 +44,7 @@ jobs:
|
||||
npm pack ./
|
||||
mv typescript-*.tgz typescript.tgz
|
||||
- name: Upload built tarfile
|
||||
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
|
||||
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
|
||||
with:
|
||||
name: tgz
|
||||
path: typescript.tgz
|
||||
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
persist-credentials: false
|
||||
|
||||
- name: 'Run analysis'
|
||||
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
|
||||
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||
# format to the repository Actions tab.
|
||||
- name: 'Upload artifact'
|
||||
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
|
||||
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
@@ -55,6 +55,6 @@ jobs:
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: 'Upload to code-scanning'
|
||||
uses: github/codeql-action/upload-sarif@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13
|
||||
uses: github/codeql-action/upload-sarif@429e1977040da7a23b6822b13c129cd1ba93dbb2 # v3.26.2
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
||||
+17
-13
@@ -1,5 +1,6 @@
|
||||
// @ts-check
|
||||
import eslint from "@eslint/js";
|
||||
import * as regexpPlugin from "eslint-plugin-regexp";
|
||||
import fs from "fs";
|
||||
import globals from "globals";
|
||||
import { createRequire } from "module";
|
||||
@@ -36,6 +37,7 @@ export default tseslint.config(
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
...tseslint.configs.stylistic,
|
||||
regexpPlugin.configs["flat/recommended"],
|
||||
{
|
||||
plugins: {
|
||||
local: {
|
||||
@@ -123,24 +125,15 @@ export default tseslint.config(
|
||||
"@typescript-eslint/no-var-requires": "off",
|
||||
"@typescript-eslint/no-empty-interface": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/ban-types": [
|
||||
"error",
|
||||
{
|
||||
extendDefaults: true,
|
||||
types: {
|
||||
// This is theoretically good, but ts-eslint appears to mistake our declaration of Symbol for the global Symbol type.
|
||||
// See: https://github.com/typescript-eslint/typescript-eslint/issues/7306
|
||||
"Symbol": false,
|
||||
"{}": false, // {} is a totally useful and valid type.
|
||||
},
|
||||
},
|
||||
],
|
||||
"@typescript-eslint/no-empty-object-type": "off", // {} is a totally useful and valid type.
|
||||
"@typescript-eslint/no-require-imports": "off",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"warn",
|
||||
{
|
||||
// Ignore: (solely underscores | starting with exactly one underscore)
|
||||
argsIgnorePattern: "^(_+$|_[^_])",
|
||||
varsIgnorePattern: "^(_+$|_[^_])",
|
||||
// Not setting an ignore pattern for caught errors; those can always be safely removed.
|
||||
},
|
||||
],
|
||||
"@typescript-eslint/no-inferrable-types": "off",
|
||||
@@ -162,6 +155,7 @@ export default tseslint.config(
|
||||
"local/no-keywords": "error",
|
||||
"local/jsdoc-format": "error",
|
||||
"local/js-extensions": "error",
|
||||
"local/no-array-mutating-method-expressions": "error",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -210,12 +204,21 @@ export default tseslint.config(
|
||||
{ name: "clearImmediate" },
|
||||
{ name: "performance" },
|
||||
],
|
||||
"local/no-direct-import": "error",
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["src/harness/**", "src/testRunner/**"],
|
||||
rules: {
|
||||
"no-restricted-globals": "off",
|
||||
"regexp/no-super-linear-backtracking": "off",
|
||||
"local/no-direct-import": "off",
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["src/**/_namespaces/**"],
|
||||
rules: {
|
||||
"local/no-direct-import": "off",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -231,7 +234,8 @@ export default tseslint.config(
|
||||
"@typescript-eslint/interface-name-prefix": "off",
|
||||
"@typescript-eslint/prefer-function-type": "off",
|
||||
"@typescript-eslint/unified-signatures": "off",
|
||||
"@typescript-eslint/ban-types": "off",
|
||||
"@typescript-eslint/no-unsafe-function-type": "off",
|
||||
"@typescript-eslint/no-wrapper-object-types": "off",
|
||||
"@typescript-eslint/no-unused-vars": "off",
|
||||
|
||||
// scripts/eslint/rules
|
||||
|
||||
Generated
+858
-860
File diff suppressed because it is too large
Load Diff
+18
-15
@@ -40,11 +40,11 @@
|
||||
],
|
||||
"devDependencies": {
|
||||
"@dprint/formatter": "^0.4.1",
|
||||
"@dprint/typescript": "0.91.4",
|
||||
"@dprint/typescript": "0.91.6",
|
||||
"@esfx/canceltoken": "^1.0.0",
|
||||
"@eslint/js": "^8.57.0",
|
||||
"@eslint/js": "^9.9.0",
|
||||
"@octokit/rest": "^21.0.1",
|
||||
"@types/chai": "^4.3.16",
|
||||
"@types/chai": "^4.3.17",
|
||||
"@types/diff": "^5.2.1",
|
||||
"@types/minimist": "^1.2.5",
|
||||
"@types/mocha": "^10.0.7",
|
||||
@@ -52,34 +52,37 @@
|
||||
"@types/node": "latest",
|
||||
"@types/source-map-support": "^0.5.10",
|
||||
"@types/which": "^3.0.4",
|
||||
"@typescript-eslint/utils": "^7.17.0",
|
||||
"azure-devops-node-api": "^14.0.1",
|
||||
"@typescript-eslint/rule-tester": "^8.1.0",
|
||||
"@typescript-eslint/type-utils": "^8.1.0",
|
||||
"@typescript-eslint/utils": "^8.1.0",
|
||||
"azure-devops-node-api": "^14.0.2",
|
||||
"c8": "^10.1.2",
|
||||
"chai": "^4.4.1",
|
||||
"chai": "^4.5.0",
|
||||
"chalk": "^4.1.2",
|
||||
"chokidar": "^3.6.0",
|
||||
"diff": "^5.2.0",
|
||||
"dprint": "^0.47.2",
|
||||
"esbuild": "^0.23.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-formatter-autolinkable-stylish": "^1.3.0",
|
||||
"fast-xml-parser": "^4.4.0",
|
||||
"eslint": "^9.9.0",
|
||||
"eslint-formatter-autolinkable-stylish": "^1.4.0",
|
||||
"eslint-plugin-regexp": "^2.6.0",
|
||||
"fast-xml-parser": "^4.4.1",
|
||||
"glob": "^10.4.5",
|
||||
"globals": "^13.24.0",
|
||||
"globals": "^15.9.0",
|
||||
"hereby": "^1.9.0",
|
||||
"jsonc-parser": "^3.3.1",
|
||||
"knip": "^5.26.0",
|
||||
"knip": "^5.27.2",
|
||||
"minimist": "^1.2.8",
|
||||
"mocha": "^10.7.0",
|
||||
"mocha": "^10.7.3",
|
||||
"mocha-fivemat-progress-reporter": "^0.1.0",
|
||||
"monocart-coverage-reports": "^2.9.3",
|
||||
"monocart-coverage-reports": "^2.10.2",
|
||||
"ms": "^2.1.3",
|
||||
"node-fetch": "^3.3.2",
|
||||
"playwright": "^1.45.3",
|
||||
"playwright": "^1.46.0",
|
||||
"source-map-support": "^0.5.21",
|
||||
"tslib": "^2.6.3",
|
||||
"typescript": "^5.5.4",
|
||||
"typescript-eslint": "^7.17.0",
|
||||
"typescript-eslint": "^8.1.0",
|
||||
"which": "^3.0.1"
|
||||
},
|
||||
"overrides": {
|
||||
|
||||
@@ -105,7 +105,7 @@ export async function runConsoleTests(runJs, defaultReporter, runInParallel, opt
|
||||
}
|
||||
if (failed) {
|
||||
const grep = fs.readFileSync(".failed-tests", "utf8")
|
||||
.split(/\r?\n/g)
|
||||
.split(/\r?\n/)
|
||||
.map(test => test.trim())
|
||||
.filter(test => test.length > 0)
|
||||
.map(regExpEscape)
|
||||
|
||||
@@ -112,7 +112,7 @@ function getPrereleasePatch(tag, plainPatch) {
|
||||
// but we'd prefer to just remove separators and limit ourselves to YYYYMMDD.
|
||||
// UTC time will always be implicit here.
|
||||
const now = new Date();
|
||||
const timeStr = now.toISOString().replace(/:|T|\.|-/g, "").slice(0, 8);
|
||||
const timeStr = now.toISOString().replace(/[:T.-]/g, "").slice(0, 8);
|
||||
|
||||
return `${plainPatch}-${tag}.${timeStr}`;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
const { ESLintUtils } = require("@typescript-eslint/utils");
|
||||
const { createRule } = require("./utils.cjs");
|
||||
const { getConstrainedTypeAtLocation, isTypeArrayTypeOrUnionOfArrayTypes } = require("@typescript-eslint/type-utils");
|
||||
|
||||
/**
|
||||
* @import { TSESTree } from "@typescript-eslint/utils"
|
||||
*/
|
||||
void 0;
|
||||
|
||||
module.exports = createRule({
|
||||
name: "no-array-mutating-method-expressions",
|
||||
meta: {
|
||||
docs: {
|
||||
description: ``,
|
||||
},
|
||||
messages: {
|
||||
noSideEffectUse: `This call to {{method}} appears to be unintentional as it appears in an expression position. Sort the array in a separate statement or explicitly copy the array with slice.`,
|
||||
noSideEffectUseToMethod: `This call to {{method}} appears to be unintentional as it appears in an expression position. Sort the array in a separate statement or explicitly copy and slice the array with slice/{{toMethod}}.`,
|
||||
},
|
||||
schema: [],
|
||||
type: "problem",
|
||||
},
|
||||
defaultOptions: [],
|
||||
|
||||
create(context) {
|
||||
const services = ESLintUtils.getParserServices(context, /*allowWithoutFullTypeInformation*/ true);
|
||||
if (!services.program) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const checker = services.program.getTypeChecker();
|
||||
|
||||
/**
|
||||
* This is a heuristic to ignore cases where the mutating method appears to be
|
||||
* operating on a "fresh" array.
|
||||
*
|
||||
* @type {(callee: TSESTree.MemberExpression) => boolean}
|
||||
*/
|
||||
const isFreshArray = callee => {
|
||||
const object = callee.object;
|
||||
|
||||
if (object.type === "ArrayExpression") {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (object.type !== "CallExpression") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (object.callee.type === "Identifier") {
|
||||
// TypeScript codebase specific helpers.
|
||||
// TODO(jakebailey): handle ts.
|
||||
switch (object.callee.name) {
|
||||
case "arrayFrom":
|
||||
case "getOwnKeys":
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (object.callee.type === "MemberExpression" && object.callee.property.type === "Identifier") {
|
||||
switch (object.callee.property.name) {
|
||||
case "concat":
|
||||
case "filter":
|
||||
case "map":
|
||||
case "slice":
|
||||
return true;
|
||||
}
|
||||
|
||||
if (object.callee.object.type === "Identifier") {
|
||||
if (object.callee.object.name === "Array") {
|
||||
switch (object.callee.property.name) {
|
||||
case "from":
|
||||
case "of":
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (object.callee.object.name === "Object") {
|
||||
switch (object.callee.property.name) {
|
||||
case "values":
|
||||
case "keys":
|
||||
case "entries":
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/** @type {(callee: TSESTree.MemberExpression & { parent: TSESTree.CallExpression; }, method: string, toMethod: string | undefined) => void} */
|
||||
const check = (callee, method, toMethod) => {
|
||||
if (callee.parent.parent.type === "ExpressionStatement") return;
|
||||
if (isFreshArray(callee)) return;
|
||||
|
||||
const calleeObjType = getConstrainedTypeAtLocation(services, callee.object);
|
||||
if (!isTypeArrayTypeOrUnionOfArrayTypes(calleeObjType, checker)) return;
|
||||
|
||||
if (toMethod) {
|
||||
context.report({ node: callee.property, messageId: "noSideEffectUseToMethod", data: { method, toMethod } });
|
||||
}
|
||||
else {
|
||||
context.report({ node: callee.property, messageId: "noSideEffectUse", data: { method } });
|
||||
}
|
||||
};
|
||||
|
||||
// Methods with new copying variants.
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#copying_methods_and_mutating_methods
|
||||
const mutatingMethods = {
|
||||
reverse: undefined,
|
||||
sort: "toSorted", // This exists as `ts.toSorted`, so recommend that.
|
||||
splice: undefined,
|
||||
};
|
||||
|
||||
return Object.fromEntries(
|
||||
Object.entries(mutatingMethods).map(([method, toMethod]) => [
|
||||
`CallExpression > MemberExpression[property.name='${method}'][computed=false]`,
|
||||
node => check(node, method, toMethod),
|
||||
]),
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,81 @@
|
||||
const { createRule } = require("./utils.cjs");
|
||||
const path = require("path");
|
||||
|
||||
/** @import { TSESTree } from "@typescript-eslint/utils" */
|
||||
void 0;
|
||||
|
||||
module.exports = createRule({
|
||||
name: "no-direct-import",
|
||||
meta: {
|
||||
docs: {
|
||||
description: ``,
|
||||
},
|
||||
messages: {
|
||||
noDirectImport: `This import relatively references another project; did you mean to import from a local _namespace module?`,
|
||||
},
|
||||
schema: [],
|
||||
type: "problem",
|
||||
},
|
||||
defaultOptions: [],
|
||||
|
||||
create(context) {
|
||||
const containingFileName = context.filename;
|
||||
const containingDirectory = path.dirname(containingFileName);
|
||||
|
||||
/** @type {(node: TSESTree.ImportDeclaration | TSESTree.TSImportEqualsDeclaration) => void} */
|
||||
const check = node => {
|
||||
let source;
|
||||
if (node.type === "TSImportEqualsDeclaration") {
|
||||
const moduleReference = node.moduleReference;
|
||||
if (
|
||||
moduleReference.type === "TSExternalModuleReference"
|
||||
&& moduleReference.expression.type === "Literal"
|
||||
&& typeof moduleReference.expression.value === "string"
|
||||
) {
|
||||
source = moduleReference.expression;
|
||||
}
|
||||
}
|
||||
else {
|
||||
source = node.source;
|
||||
}
|
||||
|
||||
if (!source) return;
|
||||
|
||||
const p = source.value;
|
||||
|
||||
// These appear in place of public API imports.
|
||||
if (p.endsWith("../typescript/typescript.js")) return;
|
||||
|
||||
// The below is similar to https://github.com/microsoft/DefinitelyTyped-tools/blob/main/packages/eslint-plugin/src/rules/no-bad-reference.ts
|
||||
|
||||
// Any relative path that goes to the wrong place will contain "..".
|
||||
if (!p.includes("..")) return;
|
||||
|
||||
const parts = p.split("/");
|
||||
let cwd = containingDirectory;
|
||||
for (const part of parts) {
|
||||
if (part === "" || part === ".") {
|
||||
continue;
|
||||
}
|
||||
if (part === "..") {
|
||||
cwd = path.dirname(cwd);
|
||||
}
|
||||
else {
|
||||
cwd = path.join(cwd, part);
|
||||
}
|
||||
|
||||
if (path.basename(cwd) === "src") {
|
||||
context.report({
|
||||
messageId: "noDirectImport",
|
||||
node: source,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
ImportDeclaration: check,
|
||||
TSImportEqualsDeclaration: check,
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -2,10 +2,11 @@ const { RuleTester } = require("./support/RuleTester.cjs");
|
||||
const rule = require("../rules/argument-trivia.cjs");
|
||||
|
||||
const ruleTester = new RuleTester({
|
||||
parserOptions: {
|
||||
warnOnUnsupportedTypeScriptVersion: false,
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
warnOnUnsupportedTypeScriptVersion: false,
|
||||
},
|
||||
},
|
||||
parser: require.resolve("@typescript-eslint/parser"),
|
||||
});
|
||||
|
||||
ruleTester.run("argument-trivia", rule, {
|
||||
|
||||
@@ -2,10 +2,11 @@ const { RuleTester } = require("./support/RuleTester.cjs");
|
||||
const rule = require("../rules/debug-assert.cjs");
|
||||
|
||||
const ruleTester = new RuleTester({
|
||||
parserOptions: {
|
||||
warnOnUnsupportedTypeScriptVersion: false,
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
warnOnUnsupportedTypeScriptVersion: false,
|
||||
},
|
||||
},
|
||||
parser: require.resolve("@typescript-eslint/parser"),
|
||||
});
|
||||
|
||||
ruleTester.run("debug-assert", rule, {
|
||||
|
||||
@@ -2,10 +2,11 @@ const { RuleTester } = require("./support/RuleTester.cjs");
|
||||
const rule = require("../rules/js-extensions.cjs");
|
||||
|
||||
const ruleTester = new RuleTester({
|
||||
parserOptions: {
|
||||
warnOnUnsupportedTypeScriptVersion: false,
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
warnOnUnsupportedTypeScriptVersion: false,
|
||||
},
|
||||
},
|
||||
parser: require.resolve("@typescript-eslint/parser"),
|
||||
});
|
||||
|
||||
ruleTester.run("js-extensions", rule, {
|
||||
|
||||
@@ -2,10 +2,11 @@ const { RuleTester } = require("./support/RuleTester.cjs");
|
||||
const rule = require("../rules/no-in-operator.cjs");
|
||||
|
||||
const ruleTester = new RuleTester({
|
||||
parserOptions: {
|
||||
warnOnUnsupportedTypeScriptVersion: false,
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
warnOnUnsupportedTypeScriptVersion: false,
|
||||
},
|
||||
},
|
||||
parser: require.resolve("@typescript-eslint/parser"),
|
||||
});
|
||||
|
||||
ruleTester.run("no-in-operator", rule, {
|
||||
|
||||
@@ -2,10 +2,11 @@ const { RuleTester } = require("./support/RuleTester.cjs");
|
||||
const rule = require("../rules/no-keywords.cjs");
|
||||
|
||||
const ruleTester = new RuleTester({
|
||||
parserOptions: {
|
||||
warnOnUnsupportedTypeScriptVersion: false,
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
warnOnUnsupportedTypeScriptVersion: false,
|
||||
},
|
||||
},
|
||||
parser: require.resolve("@typescript-eslint/parser"),
|
||||
});
|
||||
|
||||
ruleTester.run("no-keywords", rule, {
|
||||
|
||||
@@ -2,10 +2,11 @@ const { RuleTester } = require("./support/RuleTester.cjs");
|
||||
const rule = require("../rules/only-arrow-functions.cjs");
|
||||
|
||||
const ruleTester = new RuleTester({
|
||||
parserOptions: {
|
||||
warnOnUnsupportedTypeScriptVersion: false,
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
warnOnUnsupportedTypeScriptVersion: false,
|
||||
},
|
||||
},
|
||||
parser: require.resolve("@typescript-eslint/parser"),
|
||||
});
|
||||
|
||||
ruleTester.run("only-arrow-functions", rule, {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
const path = require("path");
|
||||
const { TSESLint } = require("@typescript-eslint/utils");
|
||||
const Mocha = require("mocha");
|
||||
const { RuleTester } = require("@typescript-eslint/rule-tester");
|
||||
|
||||
RuleTester.afterAll = Mocha.after;
|
||||
|
||||
module.exports.ROOT_DIR = path.join(process.cwd(), "scripts", "eslint", "tests", "fixtures");
|
||||
module.exports.FILENAME = path.join(module.exports.ROOT_DIR, "file.ts");
|
||||
module.exports.RuleTester = TSESLint.RuleTester;
|
||||
module.exports.RuleTester = RuleTester;
|
||||
|
||||
@@ -45,7 +45,7 @@ class FailedTestsReporter extends Mocha.reporters.Base {
|
||||
try {
|
||||
reporter = require(reporterOptions.reporter);
|
||||
}
|
||||
catch (_) {
|
||||
catch {
|
||||
reporter = require(path.resolve(process.cwd(), reporterOptions.reporter));
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ class FailedTestsReporter extends Mocha.reporters.Base {
|
||||
|
||||
function readTests() {
|
||||
return fs.readFileSync(file, "utf8")
|
||||
.split(/\r?\n/g)
|
||||
.split(/\r?\n/)
|
||||
.map(line => line.trim())
|
||||
.filter(line => line.length > 0);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ startOfDiags.split(EOL).forEach(line => {
|
||||
execSync(`grep -rnw 'src' -e 'Diagnostics.${diagName}'`).toString();
|
||||
process.stdout.write(".");
|
||||
}
|
||||
catch (error) {
|
||||
catch {
|
||||
missingNames.push(diagName);
|
||||
process.stdout.write("x");
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ async function main() {
|
||||
ItemId = ItemId.slice(1); // remove leading semicolon
|
||||
}
|
||||
|
||||
val = val.replace(/]5D;/, "]"); // unescape `]`
|
||||
val = val.replace(/\]5D;/, "]"); // unescape `]`
|
||||
out[ItemId] = val;
|
||||
}
|
||||
return JSON.stringify(out, undefined, 2);
|
||||
@@ -146,7 +146,7 @@ async function main() {
|
||||
*/
|
||||
function getItemXML(key, value) {
|
||||
// escape entrt value
|
||||
value = value.replace(/]/g, "]5D;");
|
||||
value = value.replace(/\]/g, "]5D;");
|
||||
|
||||
return `
|
||||
<Item ItemId=";${key}" ItemType="0" PsrId="306" Leaf="true">
|
||||
|
||||
@@ -150,7 +150,7 @@ function convertPropertyName(origName) {
|
||||
result = result.replace(/_+/g, "_");
|
||||
|
||||
// remove any leading underscore, unless it is followed by a number.
|
||||
result = result.replace(/^_([^\d])/, "$1");
|
||||
result = result.replace(/^_(\D)/, "$1");
|
||||
|
||||
// get rid of all trailing underscores.
|
||||
result = result.replace(/_$/, "");
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const MAX_UNICODE_CODEPOINT = 0x10FFFF;
|
||||
/** @type {(c: string) => boolean} */
|
||||
const isStart = c => /[\p{ID_Start}\u{2118}\u{212E}\u{309B}\u{309C}]/u.test(c); // Other_ID_Start explicitly included for back compat - see http://www.unicode.org/reports/tr31/#Introduction
|
||||
const isStart = c => /\p{ID_Start}/u.test(c); // Other_ID_Start explicitly included for back compat - see http://www.unicode.org/reports/tr31/#Introduction
|
||||
/** @type {(c: string) => boolean} */
|
||||
const isPart = c => /[\p{ID_Continue}\u{00B7}\u{0387}\u{19DA}\u{1369}\u{136A}\u{136B}\u{136C}\u{136D}\u{136E}\u{136F}\u{1370}\u{1371}]/u.test(c) || isStart(c); // Likewise for Other_ID_Continue
|
||||
const isPart = c => /\p{ID_Continue}/u.test(c) || isStart(c); // Likewise for Other_ID_Continue
|
||||
const parts = [];
|
||||
let partsActive = false;
|
||||
let startsActive = false;
|
||||
|
||||
+33
-24
@@ -154,7 +154,6 @@ import {
|
||||
isEmptyObjectLiteral,
|
||||
isEntityNameExpression,
|
||||
isEnumConst,
|
||||
isEnumDeclaration,
|
||||
isExportAssignment,
|
||||
isExportDeclaration,
|
||||
isExportsIdentifier,
|
||||
@@ -1191,10 +1190,10 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
case SyntaxKind.JSDocEnumTag:
|
||||
bindJSDocTypeAlias(node as JSDocTypedefTag | JSDocCallbackTag | JSDocEnumTag);
|
||||
break;
|
||||
// In source files and blocks, bind functions first to match hoisting that occurs at runtime
|
||||
case SyntaxKind.JSDocImportTag:
|
||||
bindJSDocImportTag(node as JSDocImportTag);
|
||||
break;
|
||||
// In source files and blocks, bind functions first to match hoisting that occurs at runtime
|
||||
case SyntaxKind.SourceFile: {
|
||||
bindEachFunctionsFirst((node as SourceFile).statements);
|
||||
bind((node as SourceFile).endOfFileToken);
|
||||
@@ -2105,7 +2104,10 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
}
|
||||
|
||||
function bindJSDocImportTag(node: JSDocImportTag) {
|
||||
// don't bind the importClause yet; that's delayed until bindJSDocImports
|
||||
bind(node.tagName);
|
||||
bind(node.moduleSpecifier);
|
||||
bind(node.attributes);
|
||||
|
||||
if (typeof node.comment !== "string") {
|
||||
bindEach(node.comment);
|
||||
@@ -3786,7 +3788,9 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
(isStatementButNotDeclaration(node) && node.kind !== SyntaxKind.EmptyStatement) ||
|
||||
// report error on class declarations
|
||||
node.kind === SyntaxKind.ClassDeclaration ||
|
||||
// report error on instantiated modules or const-enums only modules if preserveConstEnums is set
|
||||
// report errors on enums with preserved emit
|
||||
isEnumDeclarationWithPreservedEmit(node, options) ||
|
||||
// report error on instantiated modules
|
||||
(node.kind === SyntaxKind.ModuleDeclaration && shouldReportErrorOnModuleDeclaration(node as ModuleDeclaration));
|
||||
|
||||
if (reportError) {
|
||||
@@ -3810,7 +3814,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
node.declarationList.declarations.some(d => !!d.initializer)
|
||||
);
|
||||
|
||||
eachUnreachableRange(node, (start, end) => errorOrSuggestionOnRange(isError, start, end, Diagnostics.Unreachable_code_detected));
|
||||
eachUnreachableRange(node, options, (start, end) => errorOrSuggestionOnRange(isError, start, end, Diagnostics.Unreachable_code_detected));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3818,7 +3822,11 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
}
|
||||
}
|
||||
|
||||
function eachUnreachableRange(node: Node, cb: (start: Node, last: Node) => void): void {
|
||||
function isEnumDeclarationWithPreservedEmit(node: Node, options: CompilerOptions): boolean {
|
||||
return node.kind === SyntaxKind.EnumDeclaration && (!isEnumConst(node as EnumDeclaration) || shouldPreserveConstEnums(options));
|
||||
}
|
||||
|
||||
function eachUnreachableRange(node: Node, options: CompilerOptions, cb: (start: Node, last: Node) => void): void {
|
||||
if (isStatement(node) && isExecutableStatement(node) && isBlock(node.parent)) {
|
||||
const { statements } = node.parent;
|
||||
const slice = sliceAfter(statements, node);
|
||||
@@ -3827,26 +3835,27 @@ function eachUnreachableRange(node: Node, cb: (start: Node, last: Node) => void)
|
||||
else {
|
||||
cb(node, node);
|
||||
}
|
||||
}
|
||||
// As opposed to a pure declaration like an `interface`
|
||||
function isExecutableStatement(s: Statement): boolean {
|
||||
// Don't remove statements that can validly be used before they appear.
|
||||
return !isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !isEnumDeclaration(s) &&
|
||||
// `var x;` may declare a variable used above
|
||||
!(isVariableStatement(s) && !(getCombinedNodeFlags(s) & (NodeFlags.BlockScoped)) && s.declarationList.declarations.some(d => !d.initializer));
|
||||
}
|
||||
|
||||
function isPurelyTypeDeclaration(s: Statement): boolean {
|
||||
switch (s.kind) {
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
return true;
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return getModuleInstanceState(s as ModuleDeclaration) !== ModuleInstanceState.Instantiated;
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return hasSyntacticModifier(s, ModifierFlags.Const);
|
||||
default:
|
||||
return false;
|
||||
// As opposed to a pure declaration like an `interface`
|
||||
function isExecutableStatement(s: Statement): boolean {
|
||||
// Don't remove statements that can validly be used before they appear.
|
||||
return !isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) &&
|
||||
// `var x;` may declare a variable used above
|
||||
!(isVariableStatement(s) && !(getCombinedNodeFlags(s) & (NodeFlags.BlockScoped)) && s.declarationList.declarations.some(d => !d.initializer));
|
||||
}
|
||||
|
||||
function isPurelyTypeDeclaration(s: Statement): boolean {
|
||||
switch (s.kind) {
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
return true;
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return getModuleInstanceState(s as ModuleDeclaration) !== ModuleInstanceState.Instantiated;
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
return !isEnumDeclarationWithPreservedEmit(s, options);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+345
-135
File diff suppressed because it is too large
Load Diff
@@ -259,6 +259,8 @@ export const libs = libEntries.map(entry => entry[0]);
|
||||
export const libMap = new Map(libEntries);
|
||||
|
||||
// Watch related options
|
||||
|
||||
// Do not delete this without updating the website's tsconfig generation.
|
||||
/** @internal */
|
||||
export const optionsForWatch: CommandLineOption[] = [
|
||||
{
|
||||
@@ -435,7 +437,6 @@ export const commonOptionsWithBuild: CommandLineOption[] = [
|
||||
name: "generateTrace",
|
||||
type: "string",
|
||||
isFilePath: true,
|
||||
isCommandLineOnly: true,
|
||||
paramType: Diagnostics.DIRECTORY,
|
||||
category: Diagnostics.Compiler_Diagnostics,
|
||||
description: Diagnostics.Generates_an_event_trace_and_a_list_of_types,
|
||||
@@ -1619,6 +1620,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
|
||||
},
|
||||
];
|
||||
|
||||
// Do not delete this without updating the website's tsconfig generation.
|
||||
/** @internal */
|
||||
export const optionDeclarations: CommandLineOption[] = [
|
||||
...commonOptionsWithBuild,
|
||||
@@ -1694,6 +1696,13 @@ export const optionsForBuild: CommandLineOption[] = [
|
||||
type: "boolean",
|
||||
defaultValueDescription: false,
|
||||
},
|
||||
{
|
||||
name: "stopBuildOnErrors",
|
||||
category: Diagnostics.Command_line_Options,
|
||||
description: Diagnostics.Skip_building_downstream_projects_on_error_in_upstream_project,
|
||||
type: "boolean",
|
||||
defaultValueDescription: false,
|
||||
},
|
||||
];
|
||||
|
||||
/** @internal */
|
||||
@@ -1702,6 +1711,7 @@ export const buildOpts: CommandLineOption[] = [
|
||||
...optionsForBuild,
|
||||
];
|
||||
|
||||
// Do not delete this without updating the website's tsconfig generation.
|
||||
/** @internal */
|
||||
export const typeAcquisitionDeclarations: CommandLineOption[] = [
|
||||
{
|
||||
@@ -1764,7 +1774,9 @@ const compilerOptionsAlternateMode: AlternateModeDiagnostics = {
|
||||
getOptionsNameMap: getBuildOptionsNameMap,
|
||||
};
|
||||
|
||||
const defaultInitCompilerOptions: CompilerOptions = {
|
||||
// Do not delete this without updating the website's tsconfig generation.
|
||||
/** @internal @knipignore */
|
||||
export const defaultInitCompilerOptions: CompilerOptions = {
|
||||
module: ModuleKind.CommonJS,
|
||||
target: ScriptTarget.ES2016,
|
||||
strict: true,
|
||||
@@ -3756,7 +3768,7 @@ function convertJsonOptionOfListType(
|
||||
* \*\* # matches the recursive directory wildcard "**".
|
||||
* \/?$ # matches an optional trailing directory separator at the end of the string.
|
||||
*/
|
||||
const invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/;
|
||||
const invalidTrailingRecursionPattern = /(?:^|\/)\*\*\/?$/;
|
||||
|
||||
/**
|
||||
* Matches the portion of a wildcard path that does not contain wildcards.
|
||||
|
||||
+10
-15
@@ -396,7 +396,7 @@ export function flatten<T>(array: T[][] | readonly (T | readonly T[] | undefined
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function flatMap<T, U>(array: readonly T[] | undefined, mapfn: (x: T, i: number) => U | readonly U[] | undefined): readonly U[] {
|
||||
export function flatMap<T, U extends {}>(array: readonly T[] | undefined, mapfn: (x: T, i: number) => U | readonly U[] | undefined): readonly U[] {
|
||||
let result: U[] | undefined;
|
||||
if (array !== undefined) {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
@@ -917,18 +917,13 @@ export function relativeComplement<T>(arrayA: T[] | undefined, arrayB: T[] | und
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function append<TArray extends any[] | undefined, TValue extends NonNullable<TArray>[number] | undefined>(to: TArray, value: TValue): [undefined, undefined] extends [TArray, TValue] ? TArray : NonNullable<TArray>[number][];
|
||||
export function append<T extends {}>(to: T[], value: T | undefined): T[];
|
||||
/** @internal */
|
||||
export function append<T>(to: T[], value: T | undefined): T[];
|
||||
export function append<T extends {}>(to: T[] | undefined, value: T): T[];
|
||||
/** @internal */
|
||||
export function append<T>(to: T[] | undefined, value: T): T[];
|
||||
/** @internal */
|
||||
export function append<T>(to: T[] | undefined, value: T | undefined): T[] | undefined;
|
||||
/** @internal */
|
||||
export function append<T>(to: T[], value: T | undefined): void;
|
||||
/** @internal */
|
||||
export function append<T>(to: T[] | undefined, value: T | undefined): T[] | undefined {
|
||||
if (value === undefined) return to as T[];
|
||||
export function append<T extends {}>(to: T[] | undefined, value: T | undefined): T[] | undefined;
|
||||
export function append<T extends {}>(to: T[] | undefined, value: T | undefined): T[] | undefined {
|
||||
if (value === undefined) return to;
|
||||
if (to === undefined) return [value];
|
||||
to.push(value);
|
||||
return to;
|
||||
@@ -948,13 +943,13 @@ export function append<T>(to: T[] | undefined, value: T | undefined): T[] | unde
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function combine<T>(xs: T[] | undefined, ys: T[] | undefined): T[] | undefined;
|
||||
export function combine<T extends {}>(xs: T[] | undefined, ys: T[] | undefined): T[] | undefined;
|
||||
/** @internal */
|
||||
export function combine<T>(xs: T | readonly T[] | undefined, ys: T | readonly T[] | undefined): T | readonly T[] | undefined;
|
||||
export function combine<T extends {}>(xs: T | readonly T[] | undefined, ys: T | readonly T[] | undefined): T | readonly T[] | undefined;
|
||||
/** @internal */
|
||||
export function combine<T>(xs: T | T[] | undefined, ys: T | T[] | undefined): T | T[] | undefined;
|
||||
export function combine<T extends {}>(xs: T | T[] | undefined, ys: T | T[] | undefined): T | T[] | undefined;
|
||||
/** @internal */
|
||||
export function combine<T>(xs: T | T[] | undefined, ys: T | T[] | undefined) {
|
||||
export function combine<T extends {}>(xs: T | T[] | undefined, ys: T | T[] | undefined) {
|
||||
if (xs === undefined) return ys;
|
||||
if (ys === undefined) return xs;
|
||||
if (isArray(xs)) return isArray(ys) ? concatenate(xs, ys) : append(xs, ys);
|
||||
|
||||
@@ -581,7 +581,7 @@ export namespace Debug {
|
||||
// This regex can trigger slow backtracking because of overlapping potential captures.
|
||||
// We don't care, this is debug code that's only enabled with a debugger attached -
|
||||
// we're just taking note of it for anyone checking regex performance in the future.
|
||||
defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]");
|
||||
defaultValue = String(defaultValue).replace(/(?:,[\s\w]+:[^,]+)+\]$/, "]");
|
||||
return `NodeArray ${defaultValue}`;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -5716,6 +5716,14 @@
|
||||
"category": "Message",
|
||||
"code": 6361
|
||||
},
|
||||
"Skipping build of project '{0}' because its dependency '{1}' has errors": {
|
||||
"category": "Message",
|
||||
"code": 6362
|
||||
},
|
||||
"Project '{0}' can't be built because its dependency '{1}' has errors": {
|
||||
"category": "Message",
|
||||
"code": 6363
|
||||
},
|
||||
"Build one or more projects and their dependencies, if out of date": {
|
||||
"category": "Message",
|
||||
"code": 6364
|
||||
@@ -5760,6 +5768,14 @@
|
||||
"category": "Message",
|
||||
"code": 6381
|
||||
},
|
||||
"Skipping build of project '{0}' because its dependency '{1}' was not built": {
|
||||
"category": "Message",
|
||||
"code": 6382
|
||||
},
|
||||
"Project '{0}' can't be built because its dependency '{1}' was not built": {
|
||||
"category": "Message",
|
||||
"code": 6383
|
||||
},
|
||||
"Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it.": {
|
||||
"category": "Message",
|
||||
"code": 6384
|
||||
@@ -6095,6 +6111,10 @@
|
||||
"category": "Message",
|
||||
"code": 6639
|
||||
},
|
||||
"Skip building downstream projects on error in upstream project.": {
|
||||
"category": "Message",
|
||||
"code": 6640
|
||||
},
|
||||
"Specify a list of glob patterns that match files to be included in compilation.": {
|
||||
"category": "Message",
|
||||
"code": 6641
|
||||
@@ -6420,6 +6440,10 @@
|
||||
"category": "Message",
|
||||
"code": 6806
|
||||
},
|
||||
"This operation can be simplified. This shift is identical to `{0} {1} {2}`.": {
|
||||
"category": "Error",
|
||||
"code": 6807
|
||||
},
|
||||
|
||||
"one of:": {
|
||||
"category": "Message",
|
||||
|
||||
@@ -4005,7 +4005,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
|
||||
if (node.comment) {
|
||||
const text = getTextOfJSDocComment(node.comment);
|
||||
if (text) {
|
||||
const lines = text.split(/\r\n?|\n/g);
|
||||
const lines = text.split(/\r\n?|\n/);
|
||||
for (const line of lines) {
|
||||
writeLine();
|
||||
writeSpace();
|
||||
@@ -4508,7 +4508,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
|
||||
if (isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures
|
||||
return emitTypeArguments(parentNode, parentNode.typeArguments);
|
||||
}
|
||||
emitList(parentNode, typeParameters, ListFormat.TypeParameters);
|
||||
emitList(parentNode, typeParameters, ListFormat.TypeParameters | (isArrowFunction(parentNode) ? ListFormat.AllowTrailingComma : ListFormat.None));
|
||||
}
|
||||
|
||||
function emitParameters(parentNode: Node, parameters: NodeArray<ParameterDeclaration>) {
|
||||
@@ -4880,7 +4880,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
|
||||
}
|
||||
|
||||
function writeLines(text: string): void {
|
||||
const lines = text.split(/\r\n?|\n/g);
|
||||
const lines = text.split(/\r\n?|\n/);
|
||||
const indentation = guessIndentation(lines);
|
||||
for (const lineText of lines) {
|
||||
const line = indentation ? lineText.slice(indentation) : lineText;
|
||||
|
||||
@@ -178,7 +178,7 @@ export function createSyntacticTypeNodeBuilder(options: CompilerOptions, resolve
|
||||
return typeFromAccessor(parent, context);
|
||||
}
|
||||
const declaredType = getEffectiveTypeAnnotationNode(node);
|
||||
const addUndefined = resolver.requiresAddingImplicitUndefined(node);
|
||||
const addUndefined = resolver.requiresAddingImplicitUndefined(node, context.enclosingDeclaration);
|
||||
let resultType;
|
||||
if (declaredType) {
|
||||
resultType = serializeExistingTypeAnnotation(declaredType, addUndefined);
|
||||
|
||||
@@ -836,7 +836,7 @@ const asyncGeneratorHelper: UnscopedEmitHelper = {
|
||||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
||||
return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
||||
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
||||
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
||||
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
||||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
||||
@@ -1102,8 +1102,8 @@ const generatorHelper: UnscopedEmitHelper = {
|
||||
priority: 6,
|
||||
text: `
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
||||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
|
||||
@@ -1985,10 +1985,15 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
|
||||
node.parameters = createNodeArray(parameters);
|
||||
node.body = body;
|
||||
|
||||
node.transformFlags = propagateChildrenFlags(node.modifiers) |
|
||||
propagateChildrenFlags(node.parameters) |
|
||||
(propagateChildFlags(node.body) & ~TransformFlags.ContainsPossibleTopLevelAwait) |
|
||||
TransformFlags.ContainsES2015;
|
||||
if (!node.body) {
|
||||
node.transformFlags = TransformFlags.ContainsTypeScript;
|
||||
}
|
||||
else {
|
||||
node.transformFlags = propagateChildrenFlags(node.modifiers) |
|
||||
propagateChildrenFlags(node.parameters) |
|
||||
(propagateChildFlags(node.body) & ~TransformFlags.ContainsPossibleTopLevelAwait) |
|
||||
TransformFlags.ContainsES2015;
|
||||
}
|
||||
|
||||
node.typeParameters = undefined; // initialized by parser for grammar errors
|
||||
node.type = undefined; // initialized by parser for grammar errors
|
||||
@@ -6553,6 +6558,8 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
|
||||
return updateSatisfiesExpression(outerExpression, expression, outerExpression.type);
|
||||
case SyntaxKind.NonNullExpression:
|
||||
return updateNonNullExpression(outerExpression, expression);
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return updateExpressionWithTypeArguments(outerExpression, expression, outerExpression.typeArguments);
|
||||
case SyntaxKind.PartiallyEmittedExpression:
|
||||
return updatePartiallyEmittedExpression(outerExpression, expression);
|
||||
}
|
||||
|
||||
@@ -630,9 +630,10 @@ export function isOuterExpression(node: Node, kinds = OuterExpressionKinds.All):
|
||||
return (kinds & OuterExpressionKinds.Parentheses) !== 0;
|
||||
case SyntaxKind.TypeAssertionExpression:
|
||||
case SyntaxKind.AsExpression:
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
case SyntaxKind.SatisfiesExpression:
|
||||
return (kinds & OuterExpressionKinds.TypeAssertions) !== 0;
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return (kinds & OuterExpressionKinds.ExpressionsWithTypeArguments) !== 0;
|
||||
case SyntaxKind.NonNullExpression:
|
||||
return (kinds & OuterExpressionKinds.NonNullAssertions) !== 0;
|
||||
case SyntaxKind.PartiallyEmittedExpression:
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
AmbientModuleDeclaration,
|
||||
append,
|
||||
arrayFrom,
|
||||
changeFullExtension,
|
||||
CharacterCodes,
|
||||
combinePaths,
|
||||
compareBooleans,
|
||||
@@ -59,6 +60,7 @@ import {
|
||||
getSupportedExtensions,
|
||||
getTemporaryModuleResolutionState,
|
||||
getTextOfIdentifierOrLiteral,
|
||||
hasImplementationTSFileExtension,
|
||||
hasJSFileExtension,
|
||||
hasTSFileExtension,
|
||||
hostGetCanonicalFileName,
|
||||
@@ -83,6 +85,7 @@ import {
|
||||
mapDefined,
|
||||
MapLike,
|
||||
matchPatternOrExact,
|
||||
memoizeOne,
|
||||
min,
|
||||
ModuleDeclaration,
|
||||
ModuleKind,
|
||||
@@ -127,6 +130,34 @@ import {
|
||||
UserPreferences,
|
||||
} from "./_namespaces/ts.js";
|
||||
|
||||
const stringToRegex = memoizeOne((pattern: string) => {
|
||||
try {
|
||||
let slash = pattern.indexOf("/");
|
||||
if (slash !== 0) {
|
||||
// No leading slash, treat as a pattern
|
||||
return new RegExp(pattern);
|
||||
}
|
||||
const lastSlash = pattern.lastIndexOf("/");
|
||||
if (slash === lastSlash) {
|
||||
// Only one slash, treat as a pattern
|
||||
return new RegExp(pattern);
|
||||
}
|
||||
while ((slash = pattern.indexOf("/", slash + 1)) !== lastSlash) {
|
||||
if (pattern[slash - 1] !== "\\") {
|
||||
// Unescaped middle slash, treat as a pattern
|
||||
return new RegExp(pattern);
|
||||
}
|
||||
}
|
||||
// Only case-insensitive and unicode flags make sense
|
||||
const flags = pattern.substring(lastSlash + 1).replace(/[^iu]/g, "");
|
||||
pattern = pattern.substring(1, lastSlash);
|
||||
return new RegExp(pattern, flags);
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
// Used by importFixes, getEditsForFileRename, and declaration emit to synthesize import module specifiers.
|
||||
|
||||
/** @internal */
|
||||
@@ -144,11 +175,12 @@ export interface ModuleSpecifierPreferences {
|
||||
* @param syntaxImpliedNodeFormat Used when the import syntax implies ESM or CJS irrespective of the mode of the file.
|
||||
*/
|
||||
getAllowedEndingsInPreferredOrder(syntaxImpliedNodeFormat?: ResolutionMode): ModuleSpecifierEnding[];
|
||||
readonly excludeRegexes?: readonly string[];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function getModuleSpecifierPreferences(
|
||||
{ importModuleSpecifierPreference, importModuleSpecifierEnding }: UserPreferences,
|
||||
{ importModuleSpecifierPreference, importModuleSpecifierEnding, autoImportSpecifierExcludeRegexes }: UserPreferences,
|
||||
host: Pick<ModuleSpecifierResolutionHost, "getDefaultResolutionModeForFile">,
|
||||
compilerOptions: CompilerOptions,
|
||||
importingSourceFile: Pick<SourceFile, "fileName" | "impliedNodeFormat">,
|
||||
@@ -156,6 +188,7 @@ export function getModuleSpecifierPreferences(
|
||||
): ModuleSpecifierPreferences {
|
||||
const filePreferredEnding = getPreferredEnding();
|
||||
return {
|
||||
excludeRegexes: autoImportSpecifierExcludeRegexes,
|
||||
relativePreference: oldImportSpecifier !== undefined ? (isExternalModuleNameRelative(oldImportSpecifier) ?
|
||||
RelativePreference.Relative :
|
||||
RelativePreference.NonRelative) :
|
||||
@@ -362,7 +395,13 @@ export function getModuleSpecifiersWithCacheInfo(
|
||||
): ModuleSpecifierResult {
|
||||
let computedWithoutCache = false;
|
||||
const ambient = tryGetModuleNameFromAmbientModule(moduleSymbol, checker);
|
||||
if (ambient) return { kind: "ambient", moduleSpecifiers: [ambient], computedWithoutCache };
|
||||
if (ambient) {
|
||||
return {
|
||||
kind: "ambient",
|
||||
moduleSpecifiers: !(forAutoImport && isExcludedByRegex(ambient, userPreferences.autoImportSpecifierExcludeRegexes)) ? [ambient] : emptyArray,
|
||||
computedWithoutCache,
|
||||
};
|
||||
}
|
||||
|
||||
// eslint-disable-next-line prefer-const
|
||||
let [kind, specifiers, moduleSourceFile, modulePaths, cache] = tryGetModuleSpecifiersFromCacheWorker(
|
||||
@@ -459,11 +498,13 @@ function computeModuleSpecifiers(
|
||||
const specifier = modulePath.isInNodeModules
|
||||
? tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode)
|
||||
: undefined;
|
||||
nodeModulesSpecifiers = append(nodeModulesSpecifiers, specifier);
|
||||
if (specifier && modulePath.isRedirect) {
|
||||
// If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
|
||||
// not "@foo/bar/path/to/file"). No other specifier will be this good, so stop looking.
|
||||
return { kind: "node_modules", moduleSpecifiers: nodeModulesSpecifiers!, computedWithoutCache: true };
|
||||
if (specifier && !(forAutoImport && isExcludedByRegex(specifier, preferences.excludeRegexes))) {
|
||||
nodeModulesSpecifiers = append(nodeModulesSpecifiers, specifier);
|
||||
if (modulePath.isRedirect) {
|
||||
// If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
|
||||
// not "@foo/bar/path/to/file"). No other specifier will be this good, so stop looking.
|
||||
return { kind: "node_modules", moduleSpecifiers: nodeModulesSpecifiers, computedWithoutCache: true };
|
||||
}
|
||||
}
|
||||
|
||||
if (!specifier) {
|
||||
@@ -476,7 +517,7 @@ function computeModuleSpecifiers(
|
||||
preferences,
|
||||
/*pathsOnly*/ modulePath.isRedirect,
|
||||
);
|
||||
if (!local) {
|
||||
if (!local || forAutoImport && isExcludedByRegex(local, preferences.excludeRegexes)) {
|
||||
continue;
|
||||
}
|
||||
if (modulePath.isRedirect) {
|
||||
@@ -512,7 +553,11 @@ function computeModuleSpecifiers(
|
||||
return pathsSpecifiers?.length ? { kind: "paths", moduleSpecifiers: pathsSpecifiers, computedWithoutCache: true } :
|
||||
redirectPathsSpecifiers?.length ? { kind: "redirect", moduleSpecifiers: redirectPathsSpecifiers, computedWithoutCache: true } :
|
||||
nodeModulesSpecifiers?.length ? { kind: "node_modules", moduleSpecifiers: nodeModulesSpecifiers, computedWithoutCache: true } :
|
||||
{ kind: "relative", moduleSpecifiers: Debug.checkDefined(relativeSpecifiers), computedWithoutCache: true };
|
||||
{ kind: "relative", moduleSpecifiers: relativeSpecifiers ?? emptyArray, computedWithoutCache: true };
|
||||
}
|
||||
|
||||
function isExcludedByRegex(moduleSpecifier: string, excludeRegexes: readonly string[] | undefined): boolean {
|
||||
return some(excludeRegexes, pattern => !!stringToRegex(pattern)?.test(moduleSpecifier));
|
||||
}
|
||||
|
||||
interface Info {
|
||||
@@ -536,7 +581,7 @@ function getInfo(importingSourceFileName: string, host: ModuleSpecifierResolutio
|
||||
|
||||
function getLocalModuleSpecifier(moduleFileName: string, info: Info, compilerOptions: CompilerOptions, host: ModuleSpecifierResolutionHost, importMode: ResolutionMode, preferences: ModuleSpecifierPreferences): string;
|
||||
function getLocalModuleSpecifier(moduleFileName: string, info: Info, compilerOptions: CompilerOptions, host: ModuleSpecifierResolutionHost, importMode: ResolutionMode, preferences: ModuleSpecifierPreferences, pathsOnly?: boolean): string | undefined;
|
||||
function getLocalModuleSpecifier(moduleFileName: string, info: Info, compilerOptions: CompilerOptions, host: ModuleSpecifierResolutionHost, importMode: ResolutionMode, { getAllowedEndingsInPreferredOrder: getAllowedEndingsInPrefererredOrder, relativePreference }: ModuleSpecifierPreferences, pathsOnly?: boolean): string | undefined {
|
||||
function getLocalModuleSpecifier(moduleFileName: string, info: Info, compilerOptions: CompilerOptions, host: ModuleSpecifierResolutionHost, importMode: ResolutionMode, { getAllowedEndingsInPreferredOrder: getAllowedEndingsInPrefererredOrder, relativePreference, excludeRegexes }: ModuleSpecifierPreferences, pathsOnly?: boolean): string | undefined {
|
||||
const { baseUrl, paths, rootDirs } = compilerOptions;
|
||||
if (pathsOnly && !paths) {
|
||||
return undefined;
|
||||
@@ -556,7 +601,16 @@ function getLocalModuleSpecifier(moduleFileName: string, info: Info, compilerOpt
|
||||
return pathsOnly ? undefined : relativePath;
|
||||
}
|
||||
|
||||
const fromPackageJsonImports = pathsOnly ? undefined : tryGetModuleNameFromPackageJsonImports(moduleFileName, sourceDirectory, compilerOptions, host, importMode);
|
||||
const fromPackageJsonImports = pathsOnly
|
||||
? undefined
|
||||
: tryGetModuleNameFromPackageJsonImports(
|
||||
moduleFileName,
|
||||
sourceDirectory,
|
||||
compilerOptions,
|
||||
host,
|
||||
importMode,
|
||||
prefersTsExtension(allowedEndings),
|
||||
);
|
||||
|
||||
const fromPaths = pathsOnly || fromPackageJsonImports === undefined ? paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) : undefined;
|
||||
if (pathsOnly) {
|
||||
@@ -568,6 +622,15 @@ function getLocalModuleSpecifier(moduleFileName: string, info: Info, compilerOpt
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
const relativeIsExcluded = isExcludedByRegex(relativePath, excludeRegexes);
|
||||
const nonRelativeIsExcluded = isExcludedByRegex(maybeNonRelative, excludeRegexes);
|
||||
if (!relativeIsExcluded && nonRelativeIsExcluded) {
|
||||
return relativePath;
|
||||
}
|
||||
if (relativeIsExcluded && !nonRelativeIsExcluded) {
|
||||
return maybeNonRelative;
|
||||
}
|
||||
|
||||
if (relativePreference === RelativePreference.NonRelative && !pathIsRelative(maybeNonRelative)) {
|
||||
return maybeNonRelative;
|
||||
}
|
||||
@@ -945,7 +1008,18 @@ const enum MatchingMode {
|
||||
Pattern,
|
||||
}
|
||||
|
||||
function tryGetModuleNameFromExportsOrImports(options: CompilerOptions, host: ModuleSpecifierResolutionHost, targetFilePath: string, packageDirectory: string, packageName: string, exports: unknown, conditions: string[], mode: MatchingMode, isImports: boolean): { moduleFileToTry: string; } | undefined {
|
||||
function tryGetModuleNameFromExportsOrImports(
|
||||
options: CompilerOptions,
|
||||
host: ModuleSpecifierResolutionHost,
|
||||
targetFilePath: string,
|
||||
packageDirectory: string,
|
||||
packageName: string,
|
||||
exports: unknown,
|
||||
conditions: string[],
|
||||
mode: MatchingMode,
|
||||
isImports: boolean,
|
||||
preferTsExtension: boolean,
|
||||
): { moduleFileToTry: string; } | undefined {
|
||||
if (typeof exports === "string") {
|
||||
const ignoreCase = !hostUsesCaseSensitiveFileNames(host);
|
||||
const getCommonSourceDirectory = () => host.getCommonSourceDirectory();
|
||||
@@ -954,6 +1028,7 @@ function tryGetModuleNameFromExportsOrImports(options: CompilerOptions, host: Mo
|
||||
|
||||
const pathOrPattern = getNormalizedAbsolutePath(combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined);
|
||||
const extensionSwappedTarget = hasTSFileExtension(targetFilePath) ? removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined;
|
||||
const canTryTsExtension = preferTsExtension && hasImplementationTSFileExtension(targetFilePath);
|
||||
|
||||
switch (mode) {
|
||||
case MatchingMode.Exact:
|
||||
@@ -967,11 +1042,15 @@ function tryGetModuleNameFromExportsOrImports(options: CompilerOptions, host: Mo
|
||||
}
|
||||
break;
|
||||
case MatchingMode.Directory:
|
||||
if (canTryTsExtension && containsPath(targetFilePath, pathOrPattern, ignoreCase)) {
|
||||
const fragment = getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false);
|
||||
return { moduleFileToTry: getNormalizedAbsolutePath(combinePaths(combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) };
|
||||
}
|
||||
if (extensionSwappedTarget && containsPath(pathOrPattern, extensionSwappedTarget, ignoreCase)) {
|
||||
const fragment = getRelativePathFromDirectory(pathOrPattern, extensionSwappedTarget, /*ignoreCase*/ false);
|
||||
return { moduleFileToTry: getNormalizedAbsolutePath(combinePaths(combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) };
|
||||
}
|
||||
if (containsPath(pathOrPattern, targetFilePath, ignoreCase)) {
|
||||
if (!canTryTsExtension && containsPath(pathOrPattern, targetFilePath, ignoreCase)) {
|
||||
const fragment = getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false);
|
||||
return { moduleFileToTry: getNormalizedAbsolutePath(combinePaths(combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) };
|
||||
}
|
||||
@@ -980,7 +1059,7 @@ function tryGetModuleNameFromExportsOrImports(options: CompilerOptions, host: Mo
|
||||
return { moduleFileToTry: combinePaths(packageName, fragment) };
|
||||
}
|
||||
if (declarationFile && containsPath(pathOrPattern, declarationFile, ignoreCase)) {
|
||||
const fragment = getRelativePathFromDirectory(pathOrPattern, declarationFile, /*ignoreCase*/ false);
|
||||
const fragment = changeFullExtension(getRelativePathFromDirectory(pathOrPattern, declarationFile, /*ignoreCase*/ false), getJSExtensionForFile(declarationFile, options));
|
||||
return { moduleFileToTry: combinePaths(packageName, fragment) };
|
||||
}
|
||||
break;
|
||||
@@ -988,11 +1067,15 @@ function tryGetModuleNameFromExportsOrImports(options: CompilerOptions, host: Mo
|
||||
const starPos = pathOrPattern.indexOf("*");
|
||||
const leadingSlice = pathOrPattern.slice(0, starPos);
|
||||
const trailingSlice = pathOrPattern.slice(starPos + 1);
|
||||
if (canTryTsExtension && startsWith(targetFilePath, leadingSlice, ignoreCase) && endsWith(targetFilePath, trailingSlice, ignoreCase)) {
|
||||
const starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
|
||||
return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
|
||||
}
|
||||
if (extensionSwappedTarget && startsWith(extensionSwappedTarget, leadingSlice, ignoreCase) && endsWith(extensionSwappedTarget, trailingSlice, ignoreCase)) {
|
||||
const starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length);
|
||||
return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
|
||||
}
|
||||
if (startsWith(targetFilePath, leadingSlice, ignoreCase) && endsWith(targetFilePath, trailingSlice, ignoreCase)) {
|
||||
if (!canTryTsExtension && startsWith(targetFilePath, leadingSlice, ignoreCase) && endsWith(targetFilePath, trailingSlice, ignoreCase)) {
|
||||
const starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length);
|
||||
return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
|
||||
}
|
||||
@@ -1002,20 +1085,22 @@ function tryGetModuleNameFromExportsOrImports(options: CompilerOptions, host: Mo
|
||||
}
|
||||
if (declarationFile && startsWith(declarationFile, leadingSlice, ignoreCase) && endsWith(declarationFile, trailingSlice, ignoreCase)) {
|
||||
const starReplacement = declarationFile.slice(leadingSlice.length, declarationFile.length - trailingSlice.length);
|
||||
return { moduleFileToTry: replaceFirstStar(packageName, starReplacement) };
|
||||
const substituted = replaceFirstStar(packageName, starReplacement);
|
||||
const jsExtension = tryGetJSExtensionForFile(declarationFile, options);
|
||||
return jsExtension ? { moduleFileToTry: changeFullExtension(substituted, jsExtension) } : undefined;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (Array.isArray(exports)) {
|
||||
return forEach(exports, e => tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, e, conditions, mode, isImports));
|
||||
return forEach(exports, e => tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, e, conditions, mode, isImports, preferTsExtension));
|
||||
}
|
||||
else if (typeof exports === "object" && exports !== null) { // eslint-disable-line no-restricted-syntax
|
||||
// conditional mapping
|
||||
for (const key of getOwnKeys(exports as MapLike<unknown>)) {
|
||||
if (key === "default" || conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(conditions, key)) {
|
||||
const subTarget = (exports as MapLike<unknown>)[key];
|
||||
const result = tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, subTarget, conditions, mode, isImports);
|
||||
const result = tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, subTarget, conditions, mode, isImports, preferTsExtension);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
@@ -1037,13 +1122,13 @@ function tryGetModuleNameFromExports(options: CompilerOptions, host: ModuleSpeci
|
||||
const mode = endsWith(k, "/") ? MatchingMode.Directory
|
||||
: k.includes("*") ? MatchingMode.Pattern
|
||||
: MatchingMode.Exact;
|
||||
return tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, subPackageName, (exports as MapLike<unknown>)[k], conditions, mode, /*isImports*/ false);
|
||||
return tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, subPackageName, (exports as MapLike<unknown>)[k], conditions, mode, /*isImports*/ false, /*preferTsExtension*/ false);
|
||||
});
|
||||
}
|
||||
return tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, exports, conditions, MatchingMode.Exact, /*isImports*/ false);
|
||||
return tryGetModuleNameFromExportsOrImports(options, host, targetFilePath, packageDirectory, packageName, exports, conditions, MatchingMode.Exact, /*isImports*/ false, /*preferTsExtension*/ false);
|
||||
}
|
||||
|
||||
function tryGetModuleNameFromPackageJsonImports(moduleFileName: string, sourceDirectory: string, options: CompilerOptions, host: ModuleSpecifierResolutionHost, importMode: ResolutionMode) {
|
||||
function tryGetModuleNameFromPackageJsonImports(moduleFileName: string, sourceDirectory: string, options: CompilerOptions, host: ModuleSpecifierResolutionHost, importMode: ResolutionMode, preferTsExtension: boolean) {
|
||||
if (!host.readFile || !getResolvePackageJsonImports(options)) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -1068,7 +1153,7 @@ function tryGetModuleNameFromPackageJsonImports(moduleFileName: string, sourceDi
|
||||
const mode = endsWith(k, "/") ? MatchingMode.Directory
|
||||
: k.includes("*") ? MatchingMode.Pattern
|
||||
: MatchingMode.Exact;
|
||||
return tryGetModuleNameFromExportsOrImports(options, host, moduleFileName, ancestorDirectoryWithPackageJson, k, (imports as MapLike<unknown>)[k], conditions, mode, /*isImports*/ true);
|
||||
return tryGetModuleNameFromExportsOrImports(options, host, moduleFileName, ancestorDirectoryWithPackageJson, k, (imports as MapLike<unknown>)[k], conditions, mode, /*isImports*/ true, preferTsExtension);
|
||||
})?.moduleFileToTry;
|
||||
}
|
||||
|
||||
@@ -1169,7 +1254,15 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }: ModulePath, { getCan
|
||||
const packageName = getPackageNameFromTypesPackageName(nodeModulesDirectoryName);
|
||||
const conditions = getConditions(options, importMode);
|
||||
const fromExports = packageJsonContent?.exports
|
||||
? tryGetModuleNameFromExports(options, host, path, packageRootPath, packageName, packageJsonContent.exports, conditions)
|
||||
? tryGetModuleNameFromExports(
|
||||
options,
|
||||
host,
|
||||
path,
|
||||
packageRootPath,
|
||||
packageName,
|
||||
packageJsonContent.exports,
|
||||
conditions,
|
||||
)
|
||||
: undefined;
|
||||
if (fromExports) {
|
||||
return { ...fromExports, verbatimFromExports: true };
|
||||
@@ -1359,3 +1452,8 @@ function isPathRelativeToParent(path: string): boolean {
|
||||
function getDefaultResolutionModeForFile(file: Pick<SourceFile, "fileName" | "impliedNodeFormat" | "packageJsonScope">, host: Pick<ModuleSpecifierResolutionHost, "getDefaultResolutionModeForFile">, compilerOptions: CompilerOptions) {
|
||||
return isFullSourceFile(file) ? host.getDefaultResolutionModeForFile(file) : getDefaultResolutionModeForFileWorker(file, compilerOptions);
|
||||
}
|
||||
|
||||
function prefersTsExtension(allowedEndings: readonly ModuleSpecifierEnding[]) {
|
||||
const tsPriority = allowedEndings.indexOf(ModuleSpecifierEnding.TsExtension);
|
||||
return tsPriority > -1 && tsPriority < allowedEndings.indexOf(ModuleSpecifierEnding.JsExtension);
|
||||
}
|
||||
|
||||
@@ -10653,8 +10653,8 @@ function getNamedArgRegEx(name: string): RegExp {
|
||||
return result;
|
||||
}
|
||||
|
||||
const tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
|
||||
const singleLinePragmaRegEx = /^\/\/\/?\s*@([^\s:]+)(.*)\s*$/im;
|
||||
const tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/m;
|
||||
const singleLinePragmaRegEx = /^\/\/\/?\s*@([^\s:]+)((?:[^\S\r\n]|:).*)?$/m;
|
||||
function extractPragmas(pragmas: PragmaPseudoMapEntry[], range: CommentRange, text: string) {
|
||||
const tripleSlash = range.kind === SyntaxKind.SingleLineCommentTrivia && tripleSlashXMLCommentStartRegEx.exec(text);
|
||||
if (tripleSlash) {
|
||||
@@ -10700,7 +10700,7 @@ function extractPragmas(pragmas: PragmaPseudoMapEntry[], range: CommentRange, te
|
||||
}
|
||||
|
||||
if (range.kind === SyntaxKind.MultiLineCommentTrivia) {
|
||||
const multiLinePragmaRegEx = /@(\S+)(\s+.*)?$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating)
|
||||
const multiLinePragmaRegEx = /@(\S+)(\s+(?:\S.*)?)?$/gm; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating)
|
||||
let multiLineMatch: RegExpExecArray | null; // eslint-disable-line no-restricted-syntax
|
||||
while (multiLineMatch = multiLinePragmaRegEx.exec(text)) {
|
||||
addPragmaForMatch(pragmas, range, PragmaKindFlags.MultiLine, multiLineMatch);
|
||||
|
||||
@@ -98,7 +98,7 @@ export function pathIsAbsolute(path: string): boolean {
|
||||
* @internal
|
||||
*/
|
||||
export function pathIsRelative(path: string): boolean {
|
||||
return /^\.\.?($|[\\/])/.test(path);
|
||||
return /^\.\.?(?:$|[\\/])/.test(path);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -779,7 +779,7 @@ export function changeFullExtension(path: string, newExtension: string) {
|
||||
//// Path Comparisons
|
||||
|
||||
// check path for these segments: '', '.'. '..'
|
||||
const relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
|
||||
const relativePathSegmentRegExp = /\/\/|(?:^|\/)\.\.?(?:$|\/)/;
|
||||
|
||||
function comparePathsWorker(a: string, b: string, componentComparer: (a: string, b: string) => Comparison) {
|
||||
if (a === b) return Comparison.EqualTo;
|
||||
|
||||
+8
-11
@@ -1392,16 +1392,13 @@ export function getImpliedNodeFormatForFileWorker(
|
||||
host: ModuleResolutionHost,
|
||||
options: CompilerOptions,
|
||||
) {
|
||||
switch (getEmitModuleResolutionKind(options)) {
|
||||
case ModuleResolutionKind.Node16:
|
||||
case ModuleResolutionKind.NodeNext:
|
||||
return fileExtensionIsOneOf(fileName, [Extension.Dmts, Extension.Mts, Extension.Mjs]) ? ModuleKind.ESNext :
|
||||
fileExtensionIsOneOf(fileName, [Extension.Dcts, Extension.Cts, Extension.Cjs]) ? ModuleKind.CommonJS :
|
||||
fileExtensionIsOneOf(fileName, [Extension.Dts, Extension.Ts, Extension.Tsx, Extension.Js, Extension.Jsx]) ? lookupFromPackageJson() :
|
||||
undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
const moduleResolution = getEmitModuleResolutionKind(options);
|
||||
const shouldLookupFromPackageJson = ModuleResolutionKind.Node16 <= moduleResolution && moduleResolution <= ModuleResolutionKind.NodeNext
|
||||
|| pathContainsNodeModules(fileName);
|
||||
return fileExtensionIsOneOf(fileName, [Extension.Dmts, Extension.Mts, Extension.Mjs]) ? ModuleKind.ESNext :
|
||||
fileExtensionIsOneOf(fileName, [Extension.Dcts, Extension.Cts, Extension.Cjs]) ? ModuleKind.CommonJS :
|
||||
shouldLookupFromPackageJson && fileExtensionIsOneOf(fileName, [Extension.Dts, Extension.Ts, Extension.Tsx, Extension.Js, Extension.Jsx]) ? lookupFromPackageJson() :
|
||||
undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline
|
||||
|
||||
function lookupFromPackageJson(): Partial<CreateSourceFileOptions> {
|
||||
const state = getTemporaryModuleResolutionState(packageJsonInfoCache, host, options);
|
||||
@@ -3112,7 +3109,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
|
||||
|
||||
// Stop searching if the line is not empty and not a comment
|
||||
const lineText = file.text.slice(lineStarts[line], lineStarts[line + 1]).trim();
|
||||
if (lineText !== "" && !/^(\s*)\/\/(.*)$/.test(lineText)) {
|
||||
if (lineText !== "" && !/^\s*\/\/.*$/.test(lineText)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -267,11 +267,11 @@ function perceivedOsRootLengthForWatching(pathComponents: Readonly<PathPathCompo
|
||||
// Ignore "/", "c:/"
|
||||
if (length <= 1) return 1;
|
||||
let indexAfterOsRoot = 1;
|
||||
let isDosStyle = pathComponents[0].search(/[a-zA-Z]:/) === 0;
|
||||
let isDosStyle = pathComponents[0].search(/[a-z]:/i) === 0;
|
||||
if (
|
||||
pathComponents[0] !== directorySeparator &&
|
||||
!isDosStyle && // Non dos style paths
|
||||
pathComponents[1].search(/[a-zA-Z]\$$/) === 0 // Dos style nextPart
|
||||
pathComponents[1].search(/[a-z]\$$/i) === 0 // Dos style nextPart
|
||||
) {
|
||||
// ignore "//vda1cs4850/c$/folderAtRoot"
|
||||
if (length === 2) return 2;
|
||||
|
||||
@@ -36,7 +36,7 @@ const buildPartRegExp = /^[a-z0-9-]+$/i;
|
||||
|
||||
// https://semver.org/#spec-item-9
|
||||
// > Numeric identifiers MUST NOT include leading zeroes.
|
||||
const numericIdentifierRegExp = /^(0|[1-9]\d*)$/;
|
||||
const numericIdentifierRegExp = /^(?:0|[1-9]\d*)$/;
|
||||
|
||||
/**
|
||||
* Describes a precise semantic version number, https://semver.org
|
||||
@@ -244,8 +244,8 @@ interface Comparator {
|
||||
// range-set ::= range ( logical-or range ) *
|
||||
// range ::= hyphen | simple ( ' ' simple ) * | ''
|
||||
// logical-or ::= ( ' ' ) * '||' ( ' ' ) *
|
||||
const logicalOrRegExp = /\|\|/g;
|
||||
const whitespaceRegExp = /\s+/g;
|
||||
const logicalOrRegExp = /\|\|/;
|
||||
const whitespaceRegExp = /\s+/;
|
||||
|
||||
// https://github.com/npm/node-semver#range-grammar
|
||||
//
|
||||
@@ -257,7 +257,7 @@ const whitespaceRegExp = /\s+/g;
|
||||
// build ::= parts
|
||||
// parts ::= part ( '.' part ) *
|
||||
// part ::= nr | [-0-9A-Za-z]+
|
||||
const partialRegExp = /^([xX*0]|[1-9]\d*)(?:\.([xX*0]|[1-9]\d*)(?:\.([xX*0]|[1-9]\d*)(?:-([a-z0-9-.]+))?(?:\+([a-z0-9-.]+))?)?)?$/i;
|
||||
const partialRegExp = /^([x*0]|[1-9]\d*)(?:\.([x*0]|[1-9]\d*)(?:\.([x*0]|[1-9]\d*)(?:-([a-z0-9-.]+))?(?:\+([a-z0-9-.]+))?)?)?$/i;
|
||||
|
||||
// https://github.com/npm/node-semver#range-grammar
|
||||
//
|
||||
@@ -270,7 +270,7 @@ const hyphenRegExp = /^\s*([a-z0-9-+.*]+)\s+-\s+([a-z0-9-+.*]+)\s*$/i;
|
||||
// primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
|
||||
// tilde ::= '~' partial
|
||||
// caret ::= '^' partial
|
||||
const rangeRegExp = /^(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i;
|
||||
const rangeRegExp = /^([~^<>=]|<=|>=)?\s*([a-z0-9-+.*]+)$/i;
|
||||
|
||||
function parseRange(text: string) {
|
||||
const alternatives: Comparator[][] = [];
|
||||
|
||||
@@ -360,9 +360,9 @@ export function createSourceMapGenerator(host: EmitHost, file: string, sourceRoo
|
||||
|
||||
// Sometimes tools can see the following line as a source mapping url comment, so we mangle it a bit (the [M])
|
||||
/** @internal */
|
||||
export const sourceMapCommentRegExpDontCareLineStart = /\/\/[@#] source[M]appingURL=(.+)\r?\n?$/;
|
||||
export const sourceMapCommentRegExpDontCareLineStart = /\/\/[@#] source[M]appingURL=(.+)\r?\n?$/; // eslint-disable-line regexp/no-useless-character-class
|
||||
/** @internal */
|
||||
export const sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\r?\n?$/;
|
||||
export const sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\r?\n?$/; // eslint-disable-line regexp/no-useless-character-class
|
||||
|
||||
/** @internal */
|
||||
export const whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
|
||||
|
||||
+9
-9
@@ -1466,7 +1466,7 @@ export let sys: System = (() => {
|
||||
const byteOrderMarkIndicator = "\uFEFF";
|
||||
|
||||
function getNodeSystem(): System {
|
||||
const nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/;
|
||||
const nativePattern = /^native |^\([^)]+\)$|^(?:internal[\\/]|[\w\s]+(?:\.js)?$)/;
|
||||
const _fs: typeof import("fs") = require("fs");
|
||||
const _path: typeof import("path") = require("path");
|
||||
const _os = require("os");
|
||||
@@ -1592,7 +1592,7 @@ export let sys: System = (() => {
|
||||
disableCPUProfiler,
|
||||
cpuProfilingEnabled: () => !!activeSession || contains(process.execArgv, "--cpu-prof") || contains(process.execArgv, "--prof"),
|
||||
realpath,
|
||||
debugMode: !!process.env.NODE_INSPECTOR_IPC || !!process.env.VSCODE_INSPECTOR_OPTIONS || some(process.execArgv, arg => /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg)) || !!(process as any).recordreplay,
|
||||
debugMode: !!process.env.NODE_INSPECTOR_IPC || !!process.env.VSCODE_INSPECTOR_OPTIONS || some(process.execArgv, arg => /^--(?:inspect|debug)(?:-brk)?(?:=\d+)?$/i.test(arg)) || !!(process as any).recordreplay,
|
||||
tryEnableSourceMapsForHost() {
|
||||
try {
|
||||
(require("source-map-support") as typeof import("source-map-support")).install();
|
||||
@@ -1792,7 +1792,7 @@ export let sys: System = (() => {
|
||||
try {
|
||||
buffer = _fs.readFileSync(fileName);
|
||||
}
|
||||
catch (e) {
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
let len = buffer.length;
|
||||
@@ -1863,7 +1863,7 @@ export let sys: System = (() => {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
catch {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -1882,7 +1882,7 @@ export let sys: System = (() => {
|
||||
directories.sort();
|
||||
return { files, directories };
|
||||
}
|
||||
catch (e) {
|
||||
catch {
|
||||
return emptyFileSystemEntries;
|
||||
}
|
||||
}
|
||||
@@ -1911,7 +1911,7 @@ export let sys: System = (() => {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
@@ -1952,7 +1952,7 @@ export let sys: System = (() => {
|
||||
try {
|
||||
return statSync(path)?.mtime;
|
||||
}
|
||||
catch (e) {
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
finally {
|
||||
@@ -1964,7 +1964,7 @@ export let sys: System = (() => {
|
||||
try {
|
||||
_fs.utimesSync(path, time, time);
|
||||
}
|
||||
catch (e) {
|
||||
catch {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1973,7 +1973,7 @@ export let sys: System = (() => {
|
||||
try {
|
||||
return _fs.unlinkSync(path);
|
||||
}
|
||||
catch (e) {
|
||||
catch {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ import {
|
||||
ImportTypeNode,
|
||||
IndexSignatureDeclaration,
|
||||
InterfaceDeclaration,
|
||||
InternalNodeBuilderFlags,
|
||||
isAmbientModule,
|
||||
isArray,
|
||||
isArrayBindingElement,
|
||||
@@ -239,10 +240,11 @@ const declarationEmitNodeBuilderFlags = NodeBuilderFlags.MultilineObjectLiterals
|
||||
NodeBuilderFlags.UseTypeOfFunction |
|
||||
NodeBuilderFlags.UseStructuralFallback |
|
||||
NodeBuilderFlags.AllowEmptyTuple |
|
||||
NodeBuilderFlags.AllowUnresolvedNames |
|
||||
NodeBuilderFlags.GenerateNamesForShadowedTypeParams |
|
||||
NodeBuilderFlags.NoTruncation;
|
||||
|
||||
const declarationEmitInternalNodeBuilderFlags = InternalNodeBuilderFlags.AllowUnresolvedNames;
|
||||
|
||||
/**
|
||||
* Transforms a ts file into a .d.ts file
|
||||
* This process requires type information, which is retrieved through the emit resolver. Because of this,
|
||||
@@ -429,7 +431,7 @@ export function transformDeclarations(context: TransformationContext) {
|
||||
: Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit,
|
||||
errorNode: s.errorNode || sourceFile,
|
||||
}));
|
||||
const result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker);
|
||||
const result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, declarationEmitInternalNodeBuilderFlags, symbolTracker);
|
||||
getSymbolAccessibilityDiagnostic = oldDiag;
|
||||
return result;
|
||||
}
|
||||
@@ -678,7 +680,7 @@ export function transformDeclarations(context: TransformationContext) {
|
||||
// Literal const declarations will have an initializer ensured rather than a type
|
||||
return;
|
||||
}
|
||||
const shouldAddImplicitUndefined = node.kind === SyntaxKind.Parameter && resolver.requiresAddingImplicitUndefined(node);
|
||||
const shouldAddImplicitUndefined = node.kind === SyntaxKind.Parameter && resolver.requiresAddingImplicitUndefined(node, enclosingDeclaration);
|
||||
if (type && !shouldAddImplicitUndefined) {
|
||||
return visitNode(type, visitDeclarationSubtree, isTypeNode);
|
||||
}
|
||||
@@ -696,7 +698,7 @@ export function transformDeclarations(context: TransformationContext) {
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.BindingElement:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
typeNode = resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker);
|
||||
typeNode = resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, declarationEmitInternalNodeBuilderFlags, symbolTracker);
|
||||
break;
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
@@ -704,7 +706,7 @@ export function transformDeclarations(context: TransformationContext) {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.CallSignature:
|
||||
typeNode = resolver.createReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker);
|
||||
typeNode = resolver.createReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, declarationEmitInternalNodeBuilderFlags, symbolTracker);
|
||||
break;
|
||||
default:
|
||||
Debug.assertNever(node);
|
||||
@@ -1329,7 +1331,7 @@ export function transformDeclarations(context: TransformationContext) {
|
||||
errorNode: input,
|
||||
});
|
||||
errorFallbackNode = input;
|
||||
const varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined);
|
||||
const varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, declarationEmitInternalNodeBuilderFlags, symbolTracker), /*initializer*/ undefined);
|
||||
errorFallbackNode = undefined;
|
||||
const statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(SyntaxKind.DeclareKeyword)] : [], factory.createVariableDeclarationList([varDecl], NodeFlags.Const));
|
||||
|
||||
@@ -1471,7 +1473,7 @@ export function transformDeclarations(context: TransformationContext) {
|
||||
return undefined; // unique symbol or non-identifier name - omit, since there's no syntax that can preserve it
|
||||
}
|
||||
getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration);
|
||||
const type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace, declarationEmitNodeBuilderFlags | NodeBuilderFlags.NoSyntacticPrinter, symbolTracker);
|
||||
const type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace, declarationEmitNodeBuilderFlags, declarationEmitInternalNodeBuilderFlags | InternalNodeBuilderFlags.NoSyntacticPrinter, symbolTracker);
|
||||
getSymbolAccessibilityDiagnostic = oldDiag;
|
||||
const isNonContextualKeywordName = isStringANonContextualKeyword(nameStr);
|
||||
const name = isNonContextualKeywordName ? factory.getGeneratedNameForNode(p.valueDeclaration) : factory.createIdentifier(nameStr);
|
||||
@@ -1666,7 +1668,7 @@ export function transformDeclarations(context: TransformationContext) {
|
||||
errorNode: extendsClause,
|
||||
typeName: input.name,
|
||||
});
|
||||
const varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(extendsClause.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined);
|
||||
const varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(extendsClause.expression, input, declarationEmitNodeBuilderFlags, declarationEmitInternalNodeBuilderFlags, symbolTracker), /*initializer*/ undefined);
|
||||
const statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(SyntaxKind.DeclareKeyword)] : [], factory.createVariableDeclarationList([varDecl], NodeFlags.Const));
|
||||
const heritageClauses = factory.createNodeArray(map(input.heritageClauses, clause => {
|
||||
if (clause.token === SyntaxKind.ExtendsKeyword) {
|
||||
|
||||
@@ -767,7 +767,7 @@ export function createGetIsolatedDeclarationErrors(resolver: EmitResolver) {
|
||||
if (isSetAccessor(node.parent)) {
|
||||
return createAccessorTypeError(node.parent);
|
||||
}
|
||||
const addUndefined = resolver.requiresAddingImplicitUndefined(node);
|
||||
const addUndefined = resolver.requiresAddingImplicitUndefined(node, /*enclosingDeclaration*/ undefined);
|
||||
if (!addUndefined && node.initializer) {
|
||||
return createExpressionError(node.initializer);
|
||||
}
|
||||
|
||||
@@ -2946,7 +2946,7 @@ export function transformES2015(context: TransformationContext): (x: SourceFile
|
||||
const statement = unwrapInnermostStatementOfLabel(node, convertedLoopState && recordLabel);
|
||||
return isIterationStatement(statement, /*lookInLabeledStatements*/ false)
|
||||
? visitIterationStatement(statement, /*outermostLabeledStatement*/ node)
|
||||
: factory.restoreEnclosingLabel(Debug.checkDefined(visitNode(statement, visitor, isStatement, factory.liftToBlock)), node, convertedLoopState && resetLabel);
|
||||
: factory.restoreEnclosingLabel(visitNode(statement, visitor, isStatement, factory.liftToBlock) ?? setTextRange(factory.createEmptyStatement(), statement), node, convertedLoopState && resetLabel);
|
||||
}
|
||||
|
||||
function visitIterationStatement(node: IterationStatement, outermostLabeledStatement: LabeledStatement) {
|
||||
|
||||
@@ -667,7 +667,7 @@ export function transformJsx(context: TransformationContext): (x: SourceFile | B
|
||||
const name = node.name;
|
||||
if (isIdentifier(name)) {
|
||||
const text = idText(name);
|
||||
return (/^[A-Za-z_]\w*$/.test(text)) ? name : factory.createStringLiteral(text);
|
||||
return (/^[A-Z_]\w*$/i.test(text)) ? name : factory.createStringLiteral(text);
|
||||
}
|
||||
return factory.createStringLiteral(idText(name.namespace) + ":" + idText(name.name));
|
||||
}
|
||||
|
||||
@@ -993,7 +993,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile
|
||||
return factory.updateLabeledStatement(
|
||||
node,
|
||||
node.label,
|
||||
visitNode(node.statement, topLevelNestedVisitor, isStatement, factory.liftToBlock) ?? factory.createExpressionStatement(factory.createIdentifier("")),
|
||||
visitNode(node.statement, topLevelNestedVisitor, isStatement, factory.liftToBlock) ?? setTextRange(factory.createEmptyStatement(), node.statement),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ import {
|
||||
getStrictOptionValue,
|
||||
getTextOfNode,
|
||||
hasDecorators,
|
||||
hasStaticModifier,
|
||||
hasSyntacticModifier,
|
||||
HeritageClause,
|
||||
Identifier,
|
||||
@@ -266,7 +265,6 @@ export function transformTypeScript(context: TransformationContext) {
|
||||
let currentNamespaceContainerName: Identifier;
|
||||
let currentLexicalScope: SourceFile | Block | ModuleBlock | CaseBlock;
|
||||
let currentScopeFirstDeclarationsOfName: Map<__String, Node> | undefined;
|
||||
let currentClassHasParameterProperties: boolean | undefined;
|
||||
|
||||
/**
|
||||
* Keeps track of whether expression substitution has been enabled for specific edge cases.
|
||||
@@ -323,7 +321,6 @@ export function transformTypeScript(context: TransformationContext) {
|
||||
// Save state
|
||||
const savedCurrentScope = currentLexicalScope;
|
||||
const savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
|
||||
const savedCurrentClassHasParameterProperties = currentClassHasParameterProperties;
|
||||
|
||||
// Handle state changes before visiting a node.
|
||||
onBeforeVisitNode(node);
|
||||
@@ -336,7 +333,6 @@ export function transformTypeScript(context: TransformationContext) {
|
||||
}
|
||||
|
||||
currentLexicalScope = savedCurrentScope;
|
||||
currentClassHasParameterProperties = savedCurrentClassHasParameterProperties;
|
||||
return visited;
|
||||
}
|
||||
|
||||
@@ -1239,10 +1235,8 @@ export function transformTypeScript(context: TransformationContext) {
|
||||
function visitPropertyNameOfClassElement(member: ClassElement): PropertyName {
|
||||
const name = member.name!;
|
||||
// Computed property names need to be transformed into a hoisted variable when they are used more than once.
|
||||
// The names are used more than once when:
|
||||
// - the property is non-static and its initializer is moved to the constructor (when there are parameter property assignments).
|
||||
// - the property has a decorator.
|
||||
if (isComputedPropertyName(name) && ((!hasStaticModifier(member) && currentClassHasParameterProperties) || hasDecorators(member) && legacyDecorators)) {
|
||||
// The names are used more than once when the property has a decorator.
|
||||
if (legacyDecorators && isComputedPropertyName(name) && hasDecorators(member)) {
|
||||
const expression = visitNode(name.expression, visitor, isExpression);
|
||||
Debug.assert(expression);
|
||||
const innerExpression = skipPartiallyEmittedExpressions(expression);
|
||||
@@ -1689,7 +1683,7 @@ export function transformTypeScript(context: TransformationContext) {
|
||||
}
|
||||
|
||||
function visitParenthesizedExpression(node: ParenthesizedExpression): Expression {
|
||||
const innerExpression = skipOuterExpressions(node.expression, ~OuterExpressionKinds.Assertions);
|
||||
const innerExpression = skipOuterExpressions(node.expression, ~(OuterExpressionKinds.Assertions | OuterExpressionKinds.ExpressionsWithTypeArguments));
|
||||
if (isAssertionExpression(innerExpression) || isSatisfiesExpression(innerExpression)) {
|
||||
// Make sure we consider all nested cast expressions, e.g.:
|
||||
// (<any><number><any>-A).x;
|
||||
|
||||
@@ -25,6 +25,7 @@ export enum UpToDateStatusType {
|
||||
OutOfDateOptions,
|
||||
OutOfDateRoots,
|
||||
UpstreamOutOfDate,
|
||||
UpstreamBlocked,
|
||||
ComputingUpstream,
|
||||
TsVersionOutputOfDate,
|
||||
UpToDateWithInputFileText,
|
||||
@@ -47,6 +48,7 @@ export type UpToDateStatus =
|
||||
| Status.OutOfDateBuildInfo
|
||||
| Status.OutOfDateRoots
|
||||
| Status.UpstreamOutOfDate
|
||||
| Status.UpstreamBlocked
|
||||
| Status.ComputingUpstream
|
||||
| Status.TsVersionOutOfDate
|
||||
| Status.ContainerOnly
|
||||
@@ -135,6 +137,15 @@ export namespace Status {
|
||||
upstreamProjectName: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* This project depends an upstream project with build errors
|
||||
*/
|
||||
export interface UpstreamBlocked {
|
||||
type: UpToDateStatusType.UpstreamBlocked;
|
||||
upstreamProjectName: string;
|
||||
upstreamProjectBlocked: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computing status of upstream projects referenced
|
||||
*/
|
||||
|
||||
@@ -135,6 +135,7 @@ export interface BuildOptions {
|
||||
dry?: boolean;
|
||||
force?: boolean;
|
||||
verbose?: boolean;
|
||||
stopBuildOnErrors?: boolean;
|
||||
|
||||
/** @internal */ clean?: boolean;
|
||||
/** @internal */ watch?: boolean;
|
||||
@@ -1254,6 +1255,23 @@ function getNextInvalidatedProjectCreateInfo<T extends BuilderProgram>(
|
||||
}
|
||||
}
|
||||
|
||||
if (status.type === UpToDateStatusType.UpstreamBlocked) {
|
||||
verboseReportProjectStatus(state, project, status);
|
||||
reportAndStoreErrors(state, projectPath, getConfigFileParsingDiagnostics(config));
|
||||
projectPendingBuild.delete(projectPath);
|
||||
if (options.verbose) {
|
||||
reportStatus(
|
||||
state,
|
||||
status.upstreamProjectBlocked ?
|
||||
Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built :
|
||||
Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors,
|
||||
project,
|
||||
status.upstreamProjectName,
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (status.type === UpToDateStatusType.ContainerOnly) {
|
||||
verboseReportProjectStatus(state, project, status);
|
||||
reportAndStoreErrors(state, projectPath, getConfigFileParsingDiagnostics(config));
|
||||
@@ -1455,6 +1473,20 @@ function getUpToDateStatusWorker<T extends BuilderProgram>(state: SolutionBuilde
|
||||
continue;
|
||||
}
|
||||
|
||||
// An upstream project is blocked
|
||||
if (
|
||||
state.options.stopBuildOnErrors && (
|
||||
refStatus.type === UpToDateStatusType.Unbuildable ||
|
||||
refStatus.type === UpToDateStatusType.UpstreamBlocked
|
||||
)
|
||||
) {
|
||||
return {
|
||||
type: UpToDateStatusType.UpstreamBlocked,
|
||||
upstreamProjectName: ref.path,
|
||||
upstreamProjectBlocked: refStatus.type === UpToDateStatusType.UpstreamBlocked,
|
||||
};
|
||||
}
|
||||
|
||||
if (!force) (referenceStatuses ||= []).push({ ref, refStatus, resolvedRefPath, resolvedConfig });
|
||||
}
|
||||
}
|
||||
@@ -1848,6 +1880,8 @@ function queueReferencingProjects<T extends BuilderProgram>(
|
||||
buildOrder: readonly ResolvedConfigFileName[],
|
||||
buildResult: BuildResultFlags,
|
||||
) {
|
||||
// Queue only if there are no errors
|
||||
if (state.options.stopBuildOnErrors && (buildResult & BuildResultFlags.AnyErrors)) return;
|
||||
// Only composite projects can be referenced by other projects
|
||||
if (!config.options.composite) return;
|
||||
// Always use build order to queue projects
|
||||
@@ -1883,6 +1917,12 @@ function queueReferencingProjects<T extends BuilderProgram>(
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case UpToDateStatusType.UpstreamBlocked:
|
||||
if (toResolvedConfigFilePath(state, resolveProjectName(state, status.upstreamProjectName)) === projectPath) {
|
||||
clearProjectStatus(state, nextProjectPath);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
addProjToQueue(state, nextProjectPath, ProgramUpdateLevel.Update);
|
||||
@@ -2386,6 +2426,15 @@ function reportUpToDateStatus<T extends BuilderProgram>(state: SolutionBuilderSt
|
||||
relName(state, configFileName),
|
||||
relName(state, status.upstreamProjectName),
|
||||
);
|
||||
case UpToDateStatusType.UpstreamBlocked:
|
||||
return reportStatus(
|
||||
state,
|
||||
status.upstreamProjectBlocked ?
|
||||
Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built :
|
||||
Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors,
|
||||
relName(state, configFileName),
|
||||
relName(state, status.upstreamProjectName),
|
||||
);
|
||||
case UpToDateStatusType.Unbuildable:
|
||||
return reportStatus(
|
||||
state,
|
||||
|
||||
+50
-19
@@ -5051,7 +5051,26 @@ export interface TypeChecker {
|
||||
getWidenedLiteralType(type: Type): Type;
|
||||
/** @internal */
|
||||
getPromisedTypeOfPromise(promise: Type, errorNode?: Node): Type | undefined;
|
||||
/** @internal */
|
||||
/**
|
||||
* Gets the "awaited type" of a type.
|
||||
*
|
||||
* If an expression has a Promise-like type, the "awaited type" of the expression is
|
||||
* derived from the type of the first argument of the fulfillment callback for that
|
||||
* Promise's `then` method. If the "awaited type" is itself a Promise-like, it is
|
||||
* recursively unwrapped in the same manner until a non-promise type is found.
|
||||
*
|
||||
* If an expression does not have a Promise-like type, its "awaited type" is the type
|
||||
* of the expression.
|
||||
*
|
||||
* If the resulting "awaited type" is a generic object type, then it is wrapped in
|
||||
* an `Awaited<T>`.
|
||||
*
|
||||
* In the event the "awaited type" circularly references itself, or is a non-Promise
|
||||
* object-type with a callable `then()` method, an "awaited type" cannot be determined
|
||||
* and the value `undefined` will be returned.
|
||||
*
|
||||
* This is used to reflect the runtime behavior of the `await` keyword.
|
||||
*/
|
||||
getAwaitedType(type: Type): Type | undefined;
|
||||
/** @internal */
|
||||
isEmptyAnonymousObjectType(type: Type): boolean;
|
||||
@@ -5073,13 +5092,14 @@ export interface TypeChecker {
|
||||
// TODO: GH#18217 `xToDeclaration` calls are frequently asserted as defined.
|
||||
/** Note that the resulting nodes cannot be checked. */
|
||||
typeToTypeNode(type: Type, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): TypeNode | undefined;
|
||||
/** @internal */ typeToTypeNode(type: Type, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, tracker?: SymbolTracker): TypeNode | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
|
||||
/** @internal */ typeToTypeNode(type: Type, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, internalFlags?: InternalNodeBuilderFlags | undefined, tracker?: SymbolTracker): TypeNode | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
|
||||
/** @internal */ typePredicateToTypePredicateNode(typePredicate: TypePredicate, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, internalFlags?: InternalNodeBuilderFlags | undefined, tracker?: SymbolTracker): TypePredicateNode | undefined;
|
||||
/** Note that the resulting nodes cannot be checked. */
|
||||
signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): SignatureDeclaration & { typeArguments?: NodeArray<TypeNode>; } | undefined;
|
||||
/** @internal */ signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, tracker?: SymbolTracker): SignatureDeclaration & { typeArguments?: NodeArray<TypeNode>; } | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
|
||||
/** @internal */ signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, internalFlags?: InternalNodeBuilderFlags | undefined, tracker?: SymbolTracker): SignatureDeclaration & { typeArguments?: NodeArray<TypeNode>; } | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
|
||||
/** Note that the resulting nodes cannot be checked. */
|
||||
indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): IndexSignatureDeclaration | undefined;
|
||||
/** @internal */ indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, tracker?: SymbolTracker): IndexSignatureDeclaration | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
|
||||
/** @internal */ indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, internalFlags?: InternalNodeBuilderFlags | undefined, tracker?: SymbolTracker): IndexSignatureDeclaration | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
|
||||
/** Note that the resulting nodes cannot be checked. */
|
||||
symbolToEntityName(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): EntityName | undefined;
|
||||
/** Note that the resulting nodes cannot be checked. */
|
||||
@@ -5089,7 +5109,7 @@ export interface TypeChecker {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
symbolToNode(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): Node | undefined;
|
||||
symbolToNode(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, internalFlags: InternalNodeBuilderFlags | undefined): Node | undefined;
|
||||
/** Note that the resulting nodes cannot be checked. */
|
||||
symbolToTypeParameterDeclarations(symbol: Symbol, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): NodeArray<TypeParameterDeclaration> | undefined;
|
||||
/** Note that the resulting nodes cannot be checked. */
|
||||
@@ -5292,7 +5312,7 @@ export interface TypeChecker {
|
||||
/** @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken, nodesToCheck?: Node[]): Diagnostic[];
|
||||
/** @internal */ getGlobalDiagnostics(): Diagnostic[];
|
||||
/** @internal */ getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationToken, forceDts?: boolean): EmitResolver;
|
||||
/** @internal */ requiresAddingImplicitUndefined(parameter: ParameterDeclaration | JSDocParameterTag): boolean;
|
||||
/** @internal */ requiresAddingImplicitUndefined(parameter: ParameterDeclaration | JSDocParameterTag, enclosingDeclaration: Node | undefined): boolean;
|
||||
|
||||
/** @internal */ getNodeCount(): number;
|
||||
/** @internal */ getIdentifierCount(): number;
|
||||
@@ -5458,12 +5478,9 @@ export const enum NodeBuilderFlags {
|
||||
AllowEmptyTuple = 1 << 19,
|
||||
AllowUniqueESSymbolType = 1 << 20,
|
||||
AllowEmptyIndexInfoType = 1 << 21,
|
||||
/** @internal */ WriteComputedProps = 1 << 30, // { [E.A]: 1 }
|
||||
/** @internal */ NoSyntacticPrinter = 1 << 31,
|
||||
// Errors (cont.)
|
||||
AllowNodeModulesRelativePaths = 1 << 26,
|
||||
/** @internal */ DoNotIncludeSymbolChain = 1 << 27, // Skip looking up and printing an accessible symbol chain
|
||||
/** @internal */ AllowUnresolvedNames = 1 << 32,
|
||||
|
||||
|
||||
IgnoreErrors = AllowThisInObjectLiteral | AllowQualifiedNameInPlaceOfIdentifier | AllowAnonymousIdentifier | AllowEmptyUnionOrIntersection | AllowEmptyTuple | AllowEmptyIndexInfoType | AllowNodeModulesRelativePaths,
|
||||
|
||||
@@ -5473,6 +5490,16 @@ export const enum NodeBuilderFlags {
|
||||
InInitialEntityName = 1 << 24, // Set when writing the LHS of an entity name or entity name expression
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
// dprint-ignore
|
||||
export const enum InternalNodeBuilderFlags {
|
||||
None = 0,
|
||||
WriteComputedProps = 1 << 0, // { [E.A]: 1 }
|
||||
NoSyntacticPrinter = 1 << 1,
|
||||
DoNotIncludeSymbolChain = 1 << 2, // Skip looking up and printing an accessible symbol chain
|
||||
AllowUnresolvedNames = 1 << 3,
|
||||
}
|
||||
|
||||
// Ensure the shared flags between this and `NodeBuilderFlags` stay in alignment
|
||||
// dprint-ignore
|
||||
export const enum TypeFormatFlags {
|
||||
@@ -5806,12 +5833,12 @@ export interface EmitResolver {
|
||||
collectLinkedAliases(node: ModuleExportName, setVisibility?: boolean): Node[] | undefined;
|
||||
markLinkedReferences(node: Node): void;
|
||||
isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined;
|
||||
requiresAddingImplicitUndefined(node: ParameterDeclaration): boolean;
|
||||
requiresAddingImplicitUndefined(node: ParameterDeclaration, enclosingDeclaration: Node | undefined): boolean;
|
||||
isExpandoFunctionDeclaration(node: FunctionDeclaration | VariableDeclaration): boolean;
|
||||
getPropertiesOfContainerFunction(node: Declaration): Symbol[];
|
||||
createTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration | PropertyAccessExpression | ElementAccessExpression | BinaryExpression, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker): TypeNode | undefined;
|
||||
createReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker): TypeNode | undefined;
|
||||
createTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker): TypeNode | undefined;
|
||||
createTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration | PropertyAccessExpression | ElementAccessExpression | BinaryExpression, enclosingDeclaration: Node, flags: NodeBuilderFlags, internalFlags: InternalNodeBuilderFlags, tracker: SymbolTracker): TypeNode | undefined;
|
||||
createReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: NodeBuilderFlags, internalFlags: InternalNodeBuilderFlags, tracker: SymbolTracker): TypeNode | undefined;
|
||||
createTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: NodeBuilderFlags, internalFlags: InternalNodeBuilderFlags, tracker: SymbolTracker): TypeNode | undefined;
|
||||
createLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration, tracker: SymbolTracker): Expression;
|
||||
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags | undefined, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult;
|
||||
isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult;
|
||||
@@ -5828,7 +5855,7 @@ export interface EmitResolver {
|
||||
getJsxFactoryEntity(location?: Node): EntityName | undefined;
|
||||
getJsxFragmentFactoryEntity(location?: Node): EntityName | undefined;
|
||||
isBindingCapturedByNode(node: Node, decl: VariableDeclaration | BindingElement): boolean;
|
||||
getDeclarationStatementsForSourceFile(node: SourceFile, flags: NodeBuilderFlags, tracker: SymbolTracker): Statement[] | undefined;
|
||||
getDeclarationStatementsForSourceFile(node: SourceFile, flags: NodeBuilderFlags, internalFlags: InternalNodeBuilderFlags, tracker: SymbolTracker): Statement[] | undefined;
|
||||
isImportRequiredByAugmentation(decl: ImportDeclaration): boolean;
|
||||
isDefinitelyReferenceToGlobalSymbolObject(node: Node): boolean;
|
||||
}
|
||||
@@ -8475,11 +8502,12 @@ export const enum OuterExpressionKinds {
|
||||
TypeAssertions = 1 << 1,
|
||||
NonNullAssertions = 1 << 2,
|
||||
PartiallyEmittedExpressions = 1 << 3,
|
||||
ExpressionsWithTypeArguments = 1 << 4,
|
||||
|
||||
Assertions = TypeAssertions | NonNullAssertions,
|
||||
All = Parentheses | Assertions | PartiallyEmittedExpressions,
|
||||
All = Parentheses | Assertions | PartiallyEmittedExpressions | ExpressionsWithTypeArguments,
|
||||
|
||||
ExcludeJSDocTypeAssertion = 1 << 4,
|
||||
ExcludeJSDocTypeAssertion = 1 << 31,
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -8489,6 +8517,7 @@ export type OuterExpression =
|
||||
| SatisfiesExpression
|
||||
| AsExpression
|
||||
| NonNullExpression
|
||||
| ExpressionWithTypeArguments
|
||||
| PartiallyEmittedExpression;
|
||||
|
||||
/** @internal */
|
||||
@@ -9845,6 +9874,7 @@ export interface ModulePath {
|
||||
export interface ResolvedModuleSpecifierInfo {
|
||||
kind: "node_modules" | "paths" | "redirect" | "relative" | "ambient" | undefined;
|
||||
modulePaths: readonly ModulePath[] | undefined;
|
||||
packageName: string | undefined;
|
||||
moduleSpecifiers: readonly string[] | undefined;
|
||||
isBlockedByPackageJsonDependencies: boolean | undefined;
|
||||
}
|
||||
@@ -9858,7 +9888,7 @@ export interface ModuleSpecifierOptions {
|
||||
export interface ModuleSpecifierCache {
|
||||
get(fromFileName: Path, toFileName: Path, preferences: UserPreferences, options: ModuleSpecifierOptions): Readonly<ResolvedModuleSpecifierInfo> | undefined;
|
||||
set(fromFileName: Path, toFileName: Path, preferences: UserPreferences, options: ModuleSpecifierOptions, kind: ResolvedModuleSpecifierInfo["kind"], modulePaths: readonly ModulePath[], moduleSpecifiers: readonly string[]): void;
|
||||
setBlockedByPackageJsonDependencies(fromFileName: Path, toFileName: Path, preferences: UserPreferences, options: ModuleSpecifierOptions, isBlockedByPackageJsonDependencies: boolean): void;
|
||||
setBlockedByPackageJsonDependencies(fromFileName: Path, toFileName: Path, preferences: UserPreferences, options: ModuleSpecifierOptions, packageName: string | undefined, isBlockedByPackageJsonDependencies: boolean): void;
|
||||
setModulePaths(fromFileName: Path, toFileName: Path, preferences: UserPreferences, options: ModuleSpecifierOptions, modulePaths: readonly ModulePath[]): void;
|
||||
clear(): void;
|
||||
count(): number;
|
||||
@@ -10250,6 +10280,7 @@ export interface UserPreferences {
|
||||
readonly interactiveInlayHints?: boolean;
|
||||
readonly allowRenameOfImportPath?: boolean;
|
||||
readonly autoImportFileExcludePatterns?: string[];
|
||||
readonly autoImportSpecifierExcludeRegexes?: string[];
|
||||
readonly preferTypeOnlyAutoImports?: boolean;
|
||||
/**
|
||||
* Indicates whether imports should be organized in a case-insensitive manner.
|
||||
@@ -10367,6 +10398,6 @@ export interface SyntacticTypeNodeBuilderResolver {
|
||||
isExpandoFunctionDeclaration(name: FunctionDeclaration | VariableDeclaration): boolean;
|
||||
getAllAccessorDeclarations(declaration: AccessorDeclaration): AllAccessorDeclarations;
|
||||
isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node, shouldComputeAliasToMakeVisible?: boolean): SymbolVisibilityResult;
|
||||
requiresAddingImplicitUndefined(parameter: ParameterDeclaration | JSDocParameterTag): boolean;
|
||||
requiresAddingImplicitUndefined(parameter: ParameterDeclaration | JSDocParameterTag, enclosingDeclaration: Node | undefined): boolean;
|
||||
isDefinitelyReferenceToGlobalSymbolObject(node: Node): boolean;
|
||||
}
|
||||
|
||||
+25
-12
@@ -265,6 +265,7 @@ import {
|
||||
isConstructorDeclaration,
|
||||
isConstTypeReference,
|
||||
isDeclaration,
|
||||
isDeclarationFileName,
|
||||
isDecorator,
|
||||
isElementAccessExpression,
|
||||
isEnumDeclaration,
|
||||
@@ -2621,12 +2622,12 @@ export function getJSDocCommentRanges(node: Node, text: string) {
|
||||
text.charCodeAt(comment.pos + 3) !== CharacterCodes.slash);
|
||||
}
|
||||
|
||||
const fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
|
||||
const fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*<reference\s+types\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
|
||||
const fullTripleSlashLibReferenceRegEx = /^(\/\/\/\s*<reference\s+lib\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
|
||||
const fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*<amd-dependency\s+path\s*=\s*)(('[^']*')|("[^"]*")).*?\/>/;
|
||||
const fullTripleSlashAMDModuleRegEx = /^\/\/\/\s*<amd-module\s+.*?\/>/;
|
||||
const defaultLibReferenceRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)(('[^']*')|("[^"]*"))\s*\/>/;
|
||||
const fullTripleSlashReferencePathRegEx = /^\/\/\/\s*<reference\s+path\s*=\s*(?:'[^']*'|"[^"]*").*?\/>/;
|
||||
const fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^\/\/\/\s*<reference\s+types\s*=\s*(?:'[^']*'|"[^"]*").*?\/>/;
|
||||
const fullTripleSlashLibReferenceRegEx = /^\/\/\/\s*<reference\s+lib\s*=\s*(?:'[^']*'|"[^"]*").*?\/>/;
|
||||
const fullTripleSlashAMDReferencePathRegEx = /^\/\/\/\s*<amd-dependency\s+path\s*=\s*(?:'[^']*'|"[^"]*").*?\/>/;
|
||||
const fullTripleSlashAMDModuleRegEx = /^\/\/\/\s*<amd-module\s+(?:\S.*?)??\/>/;
|
||||
const defaultLibReferenceRegEx = /^\/\/\/\s*<reference\s+no-default-lib\s*=\s*(?:'[^']*'|"[^"]*")\s*\/>/;
|
||||
|
||||
export function isPartOfTypeNode(node: Node): boolean {
|
||||
if (SyntaxKind.FirstTypeNode <= node.kind && node.kind <= SyntaxKind.LastTypeNode) {
|
||||
@@ -5987,10 +5988,10 @@ export function hasInvalidEscape(template: TemplateLiteral): boolean {
|
||||
// the language service. These characters should be escaped when printing, and if any characters are added,
|
||||
// the map below must be updated. Note that this regexp *does not* include the 'delete' character.
|
||||
// There is no reason for this other than that JSON.stringify does not handle it either.
|
||||
const doubleQuoteEscapedCharsRegExp = /[\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
|
||||
const singleQuoteEscapedCharsRegExp = /[\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
|
||||
const doubleQuoteEscapedCharsRegExp = /[\\"\u0000-\u001f\u2028\u2029\u0085]/g;
|
||||
const singleQuoteEscapedCharsRegExp = /[\\'\u0000-\u001f\u2028\u2029\u0085]/g;
|
||||
// Template strings preserve simple LF newlines, still encode CRLF (or CR)
|
||||
const backtickQuoteEscapedCharsRegExp = /\r\n|[\\`\u0000-\u001f\t\v\f\b\r\u2028\u2029\u0085]/g;
|
||||
const backtickQuoteEscapedCharsRegExp = /\r\n|[\\`\u0000-\u001f\u2028\u2029\u0085]/g;
|
||||
const escapedCharsMap = new Map(Object.entries({
|
||||
"\t": "\\t",
|
||||
"\v": "\\v",
|
||||
@@ -8364,7 +8365,7 @@ export function setObjectAllocator(alloc: ObjectAllocator) {
|
||||
|
||||
/** @internal */
|
||||
export function formatStringFromArgs(text: string, args: DiagnosticArguments): string {
|
||||
return text.replace(/{(\d+)}/g, (_match, index: string) => "" + Debug.checkDefined(args[+index]));
|
||||
return text.replace(/\{(\d+)\}/g, (_match, index: string) => "" + Debug.checkDefined(args[+index]));
|
||||
}
|
||||
|
||||
let localizedDiagnosticMessages: MapLike<string> | undefined;
|
||||
@@ -9164,10 +9165,16 @@ export function getJSXTransformEnabled(options: CompilerOptions): boolean {
|
||||
export function getJSXImplicitImportBase(compilerOptions: CompilerOptions, file?: SourceFile): string | undefined {
|
||||
const jsxImportSourcePragmas = file?.pragmas.get("jsximportsource");
|
||||
const jsxImportSourcePragma = isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas;
|
||||
const jsxRuntimePragmas = file?.pragmas.get("jsxruntime");
|
||||
const jsxRuntimePragma = isArray(jsxRuntimePragmas) ? jsxRuntimePragmas[jsxRuntimePragmas.length - 1] : jsxRuntimePragmas;
|
||||
if (jsxRuntimePragma?.arguments.factory === "classic") {
|
||||
return undefined;
|
||||
}
|
||||
return compilerOptions.jsx === JsxEmit.ReactJSX ||
|
||||
compilerOptions.jsx === JsxEmit.ReactJSXDev ||
|
||||
compilerOptions.jsxImportSource ||
|
||||
jsxImportSourcePragma ?
|
||||
jsxImportSourcePragma ||
|
||||
jsxRuntimePragma?.arguments.factory === "automatic" ?
|
||||
jsxImportSourcePragma?.arguments.factory || compilerOptions.jsxImportSource || "react" :
|
||||
undefined;
|
||||
}
|
||||
@@ -9779,6 +9786,12 @@ export function hasTSFileExtension(fileName: string): boolean {
|
||||
return some(supportedTSExtensionsFlat, extension => fileExtensionIs(fileName, extension));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function hasImplementationTSFileExtension(fileName: string): boolean {
|
||||
return some(supportedTSImplementationExtensions, extension => fileExtensionIs(fileName, extension))
|
||||
&& !isDeclarationFileName(fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* Corresponds to UserPreferences#importPathEnding
|
||||
@@ -10610,7 +10623,7 @@ export function isFunctionExpressionOrArrowFunction(node: Node): node is Functio
|
||||
|
||||
/** @internal */
|
||||
export function escapeSnippetText(text: string): string {
|
||||
return text.replace(/\$/gm, () => "\\$");
|
||||
return text.replace(/\$/g, () => "\\$");
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
||||
@@ -681,7 +681,7 @@ export function validateLocaleAndSetLanguage(
|
||||
errors?: Diagnostic[],
|
||||
) {
|
||||
const lowerCaseLocale = locale.toLowerCase();
|
||||
const matchResult = /^([a-z]+)([_-]([a-z]+))?$/.exec(lowerCaseLocale);
|
||||
const matchResult = /^([a-z]+)(?:[_-]([a-z]+))?$/.exec(lowerCaseLocale);
|
||||
|
||||
if (!matchResult) {
|
||||
if (errors) {
|
||||
@@ -691,7 +691,7 @@ export function validateLocaleAndSetLanguage(
|
||||
}
|
||||
|
||||
const language = matchResult[1];
|
||||
const territory = matchResult[3];
|
||||
const territory = matchResult[2];
|
||||
|
||||
// First try the entire locale, then fall back to just language if that's all we have.
|
||||
// Either ways do not fail, and fallback to the English diagnostic strings.
|
||||
@@ -723,7 +723,7 @@ export function validateLocaleAndSetLanguage(
|
||||
try {
|
||||
fileContents = sys.readFile(filePath);
|
||||
}
|
||||
catch (e) {
|
||||
catch {
|
||||
if (errors) {
|
||||
errors.push(createCompilerDiagnostic(Diagnostics.Unable_to_open_file_0, filePath));
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
FileWatcherCallback,
|
||||
FileWatcherEventKind,
|
||||
find,
|
||||
forEachAncestorDirectory,
|
||||
getAllowJSCompilerOption,
|
||||
getBaseFileName,
|
||||
getDirectoryPath,
|
||||
@@ -198,7 +199,7 @@ export function createCachedDirectoryStructureHost(host: DirectoryStructureHost,
|
||||
try {
|
||||
return createCachedFileSystemEntries(rootDir, rootDirPath);
|
||||
}
|
||||
catch (_e) {
|
||||
catch {
|
||||
// If there is exception to read directories, dont cache the result and direct the calls to host
|
||||
Debug.assert(!cachedReadDirectoryResult.has(ensureTrailingDirectorySeparator(rootDirPath)));
|
||||
return undefined;
|
||||
@@ -291,6 +292,13 @@ export function createCachedDirectoryStructureHost(host: DirectoryStructureHost,
|
||||
return host.realpath ? host.realpath(s) : s;
|
||||
}
|
||||
|
||||
function clearFirstAncestorEntry(fileOrDirectoryPath: Path) {
|
||||
forEachAncestorDirectory(
|
||||
getDirectoryPath(fileOrDirectoryPath),
|
||||
ancestor => cachedReadDirectoryResult.delete(ensureTrailingDirectorySeparator(ancestor)) ? true : undefined,
|
||||
);
|
||||
}
|
||||
|
||||
function addOrDeleteFileOrDirectory(fileOrDirectory: string, fileOrDirectoryPath: Path) {
|
||||
const existingResult = getCachedFileSystemEntries(fileOrDirectoryPath);
|
||||
if (existingResult !== undefined) {
|
||||
@@ -302,6 +310,7 @@ export function createCachedDirectoryStructureHost(host: DirectoryStructureHost,
|
||||
|
||||
const parentResult = getCachedFileSystemEntriesForBaseDir(fileOrDirectoryPath);
|
||||
if (!parentResult) {
|
||||
clearFirstAncestorEntry(fileOrDirectoryPath);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -339,6 +348,9 @@ export function createCachedDirectoryStructureHost(host: DirectoryStructureHost,
|
||||
if (parentResult) {
|
||||
updateFilesOfFileSystemEntry(parentResult, getBaseNameOfFileName(fileName), eventKind === FileWatcherEventKind.Created);
|
||||
}
|
||||
else {
|
||||
clearFirstAncestorEntry(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
function updateFilesOfFileSystemEntry(parentResult: SortedAndCanonicalizedMutableFileSystemEntries, baseName: string, fileExists: boolean): void {
|
||||
@@ -486,8 +498,8 @@ export function updateMissingFilePathsWatch(
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface WildcardDirectoryWatcher {
|
||||
watcher: FileWatcher;
|
||||
export interface WildcardDirectoryWatcher<T extends FileWatcher = FileWatcher> {
|
||||
watcher: T;
|
||||
flags: WatchDirectoryFlags;
|
||||
}
|
||||
|
||||
@@ -499,10 +511,10 @@ export interface WildcardDirectoryWatcher {
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function updateWatchingWildcardDirectories(
|
||||
existingWatchedForWildcards: Map<string, WildcardDirectoryWatcher>,
|
||||
export function updateWatchingWildcardDirectories<T extends FileWatcher>(
|
||||
existingWatchedForWildcards: Map<string, WildcardDirectoryWatcher<T>>,
|
||||
wildcardDirectories: MapLike<WatchDirectoryFlags> | undefined,
|
||||
watchDirectory: (directory: string, flags: WatchDirectoryFlags) => FileWatcher,
|
||||
watchDirectory: (directory: string, flags: WatchDirectoryFlags) => T,
|
||||
) {
|
||||
if (wildcardDirectories) {
|
||||
mutateMap(
|
||||
@@ -522,7 +534,7 @@ export function updateWatchingWildcardDirectories(
|
||||
clearMap(existingWatchedForWildcards, closeFileWatcherOf);
|
||||
}
|
||||
|
||||
function createWildcardDirectoryWatcher(directory: string, flags: WatchDirectoryFlags): WildcardDirectoryWatcher {
|
||||
function createWildcardDirectoryWatcher(directory: string, flags: WatchDirectoryFlags): WildcardDirectoryWatcher<T> {
|
||||
// Create new watch and recursive info
|
||||
return {
|
||||
watcher: watchDirectory(directory, flags),
|
||||
@@ -530,7 +542,7 @@ export function updateWatchingWildcardDirectories(
|
||||
};
|
||||
}
|
||||
|
||||
function updateWildcardDirectoryWatcher(existingWatcher: WildcardDirectoryWatcher, flags: WatchDirectoryFlags, directory: string) {
|
||||
function updateWildcardDirectoryWatcher(existingWatcher: WildcardDirectoryWatcher<T>, flags: WatchDirectoryFlags, directory: string) {
|
||||
// Watcher needs to be updated if the recursive flags dont match
|
||||
if (existingWatcher.flags === flags) {
|
||||
return;
|
||||
|
||||
@@ -241,7 +241,7 @@ export class CompilationResult {
|
||||
}
|
||||
}
|
||||
|
||||
export function compileFiles(host: fakes.CompilerHost, rootFiles: string[] | undefined, compilerOptions: ts.CompilerOptions, typeScriptVersion?: string): CompilationResult {
|
||||
export function compileFiles(host: fakes.CompilerHost, rootFiles: string[] | undefined, compilerOptions: ts.CompilerOptions, typeScriptVersion?: string, captureSuggestions?: boolean): CompilationResult {
|
||||
if (compilerOptions.project || !rootFiles || rootFiles.length === 0) {
|
||||
const project = readProject(host.parseConfigHost, compilerOptions.project, compilerOptions);
|
||||
if (project) {
|
||||
@@ -265,11 +265,17 @@ export function compileFiles(host: fakes.CompilerHost, rootFiles: string[] | und
|
||||
// and if the test is running `skipLibCheck` - an indicator that we want the tets to run quickly - skip the before/after error comparison, too
|
||||
const skipErrorComparison = ts.length(rootFiles) >= 100 || (!!compilerOptions.skipLibCheck && !!compilerOptions.declaration);
|
||||
const preProgram = !skipErrorComparison ? ts.createProgram({ rootNames: rootFiles || [], options: { ...compilerOptions, configFile: compilerOptions.configFile, traceResolution: false }, host, typeScriptVersion }) : undefined;
|
||||
const preErrors = preProgram && ts.getPreEmitDiagnostics(preProgram);
|
||||
let preErrors = preProgram && ts.getPreEmitDiagnostics(preProgram);
|
||||
if (preProgram && captureSuggestions) {
|
||||
preErrors = ts.concatenate(preErrors, ts.flatMap(preProgram.getSourceFiles(), f => preProgram.getSuggestionDiagnostics(f)));
|
||||
}
|
||||
|
||||
const program = ts.createProgram({ rootNames: rootFiles || [], options: compilerOptions, host, typeScriptVersion });
|
||||
const emitResult = program.emit();
|
||||
const postErrors = ts.getPreEmitDiagnostics(program);
|
||||
let postErrors = ts.getPreEmitDiagnostics(program);
|
||||
if (captureSuggestions) {
|
||||
postErrors = ts.concatenate(postErrors, ts.flatMap(program.getSourceFiles(), f => program.getSuggestionDiagnostics(f)));
|
||||
}
|
||||
const longerErrors = ts.length(preErrors) > postErrors.length ? preErrors : postErrors;
|
||||
const shorterErrors = longerErrors === preErrors ? postErrors : preErrors;
|
||||
const errors = preErrors && (preErrors.length !== postErrors.length) ? [
|
||||
|
||||
@@ -72,8 +72,8 @@ export class SourceMap {
|
||||
public readonly mappings: readonly Mapping[] = [];
|
||||
public readonly names: readonly string[] | undefined;
|
||||
|
||||
private static readonly _mappingRegExp = /([A-Za-z0-9+/]+),?|(;)|./g;
|
||||
private static readonly _sourceMappingURLRegExp = /^\/\/[#@]\s*sourceMappingURL\s*=\s*(.*?)\s*$/mig;
|
||||
private static readonly _mappingRegExp = /([A-Z0-9+/]+),?|(;)|./gi;
|
||||
private static readonly _sourceMappingURLRegExp = /^\/\/[#@]\s*sourceMappingURL\s*=\s*(.*?)\s*$/gim;
|
||||
private static readonly _dataURLRegExp = /^data:application\/json;base64,([a-z0-9+/=]+)$/i;
|
||||
private static readonly _base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ const sourceFileJs = vpath.combine(vfs.srcFolder, "source.js");
|
||||
|
||||
// Define a custom "Symbol" constructor to attach missing built-in symbols without
|
||||
// modifying the global "Symbol" constructor
|
||||
const FakeSymbol: SymbolConstructor = ((description?: string) => Symbol(description)) as any;
|
||||
export const FakeSymbol: SymbolConstructor = ((description?: string) => Symbol(description)) as any;
|
||||
(FakeSymbol as any).prototype = Symbol.prototype;
|
||||
for (const key of Object.getOwnPropertyNames(Symbol)) {
|
||||
Object.defineProperty(FakeSymbol, key, Object.getOwnPropertyDescriptor(Symbol, key)!);
|
||||
|
||||
@@ -963,10 +963,10 @@ export class TestState {
|
||||
|
||||
const fileName = this.activeFile.fileName;
|
||||
const hints = this.languageService.provideInlayHints(fileName, span, preferences);
|
||||
const annotations = ts.map(hints.sort(sortHints), hint => {
|
||||
const annotations = ts.map(hints.slice().sort(sortHints), hint => {
|
||||
if (hint.displayParts) {
|
||||
hint.displayParts = ts.map(hint.displayParts, part => {
|
||||
if (part.file && /lib(?:.*)\.d\.ts$/.test(part.file)) {
|
||||
if (part.file && /lib.*\.d\.ts$/.test(part.file)) {
|
||||
part.span!.start = -1;
|
||||
}
|
||||
return part;
|
||||
@@ -1547,7 +1547,7 @@ export class TestState {
|
||||
}: BaselineDocumentSpansWithFileContentsOptions<T>,
|
||||
spanToContextId: Map<T, number>,
|
||||
) {
|
||||
const isLibFile = /lib(?:.*)\.d\.ts$/.test(fileName);
|
||||
const isLibFile = /lib.*\.d\.ts$/.test(fileName);
|
||||
let readableContents = `// === ${fileName} ===`;
|
||||
let newContent = "";
|
||||
interface Detail {
|
||||
@@ -2514,7 +2514,7 @@ export class TestState {
|
||||
for (const part of tag.text ?? ts.emptyArray) {
|
||||
if (part.kind === "linkName") {
|
||||
const link = part as ts.JSDocLinkDisplayPart;
|
||||
if (/lib(?:.*)\.d\.ts$/.test(link.target.fileName)) {
|
||||
if (/lib.*\.d\.ts$/.test(link.target.fileName)) {
|
||||
// The object literal isn't a complete TextSpan, but we're only going to
|
||||
// use these results in the baseline for diffing, so just overwrite.
|
||||
(link.target.textSpan as any) = { start: "--", length: "--" };
|
||||
@@ -3257,8 +3257,8 @@ export class TestState {
|
||||
allSpanInsets.push({ text: "|]", pos: span.textSpan.start + span.textSpan.length });
|
||||
});
|
||||
|
||||
const reverseSpans = allSpanInsets.sort((l, r) => r.pos - l.pos);
|
||||
ts.forEach(reverseSpans, span => {
|
||||
allSpanInsets.sort((l, r) => r.pos - l.pos);
|
||||
ts.forEach(allSpanInsets, span => {
|
||||
annotated = annotated.slice(0, span.pos) + span.text + annotated.slice(span.pos);
|
||||
});
|
||||
Harness.IO.log(`\nMockup:\n${annotated}`);
|
||||
@@ -3783,7 +3783,7 @@ export class TestState {
|
||||
return { baselineContent: baselineContent + activeFile.content + `\n\n--No linked edits found--`, offset };
|
||||
}
|
||||
|
||||
let inlineLinkedEditBaselines: { start: number; end: number; index: number; }[] = [];
|
||||
const inlineLinkedEditBaselines: { start: number; end: number; index: number; }[] = [];
|
||||
let linkedEditInfoBaseline = "";
|
||||
for (const edit of linkedEditsByRange) {
|
||||
const [linkedEdit, positions] = edit;
|
||||
@@ -3802,7 +3802,7 @@ export class TestState {
|
||||
offset++;
|
||||
}
|
||||
|
||||
inlineLinkedEditBaselines = inlineLinkedEditBaselines.sort((a, b) => a.start - b.start);
|
||||
inlineLinkedEditBaselines.sort((a, b) => a.start - b.start);
|
||||
const fileText = activeFile.content;
|
||||
baselineContent += fileText.slice(0, inlineLinkedEditBaselines[0].start);
|
||||
for (let i = 0; i < inlineLinkedEditBaselines.length; i++) {
|
||||
@@ -4058,7 +4058,7 @@ export class TestState {
|
||||
public verifyRefactorKindsAvailable(kind: string, expected: string[], preferences = ts.emptyOptions) {
|
||||
const refactors = this.getApplicableRefactorsAtSelection("invoked", kind, preferences);
|
||||
const availableKinds = ts.flatMap(refactors, refactor => refactor.actions).map(action => action.kind);
|
||||
assert.deepEqual(availableKinds.sort(), expected.sort(), `Expected kinds to be equal`);
|
||||
assert.deepEqual(availableKinds.slice().sort(), expected.slice().sort(), `Expected kinds to be equal`);
|
||||
}
|
||||
|
||||
public verifyRefactorsAvailable(names: readonly string[]): void {
|
||||
@@ -4938,7 +4938,7 @@ function parseFileContent(content: string, fileName: string, markerMap: Map<stri
|
||||
const openRanges: RangeLocationInformation[] = [];
|
||||
|
||||
/// A list of ranges we've collected so far */
|
||||
let localRanges: Range[] = [];
|
||||
const localRanges: Range[] = [];
|
||||
|
||||
/// The latest position of the start of an unflushed plain text area
|
||||
let lastNormalCharPosition = 0;
|
||||
@@ -5105,7 +5105,7 @@ function parseFileContent(content: string, fileName: string, markerMap: Map<stri
|
||||
}
|
||||
|
||||
// put ranges in the correct order
|
||||
localRanges = localRanges.sort((a, b) => a.pos < b.pos ? -1 : a.pos === b.pos && a.end > b.end ? -1 : 1);
|
||||
localRanges.sort((a, b) => a.pos < b.pos ? -1 : a.pos === b.pos && a.end > b.end ? -1 : 1);
|
||||
localRanges.forEach(r => ranges.push(r));
|
||||
|
||||
return {
|
||||
|
||||
@@ -282,6 +282,7 @@ export namespace Compiler {
|
||||
baselineFile?: string;
|
||||
libFiles?: string;
|
||||
noTypesAndSymbols?: boolean;
|
||||
captureSuggestions?: boolean;
|
||||
}
|
||||
|
||||
// Additional options not already in ts.optionDeclarations
|
||||
@@ -303,6 +304,7 @@ export namespace Compiler {
|
||||
{ name: "fullEmitPaths", type: "boolean", defaultValueDescription: false },
|
||||
{ name: "noCheck", type: "boolean", defaultValueDescription: false },
|
||||
{ name: "reportDiagnostics", type: "boolean", defaultValueDescription: false }, // used to enable error collection in `transpile` baselines
|
||||
{ name: "captureSuggestions", type: "boolean", defaultValueDescription: false }, // Adds suggestion diagnostics to error baselines
|
||||
];
|
||||
|
||||
let optionsIndex: Map<string, ts.CommandLineOption>;
|
||||
@@ -428,7 +430,7 @@ export namespace Compiler {
|
||||
|
||||
ts.assign(options, ts.convertToOptionsWithAbsolutePaths(options, path => ts.getNormalizedAbsolutePath(path, currentDirectory)));
|
||||
const host = new fakes.CompilerHost(fs, options);
|
||||
const result = compiler.compileFiles(host, programFileNames, options, typeScriptVersion);
|
||||
const result = compiler.compileFiles(host, programFileNames, options, typeScriptVersion, harnessSettings?.captureSuggestions === "true");
|
||||
result.symlinks = symlinks;
|
||||
(result as CompileFilesResult).repeat = newOptions => compileFiles(inputFiles, otherFiles, { ...harnessSettings, ...newOptions }, compilerOptions, originalCurrentDirectory, symlinks);
|
||||
return result as CompileFilesResult;
|
||||
@@ -582,7 +584,7 @@ export namespace Compiler {
|
||||
let location = info.file ? " " + ts.formatLocation(info.file, info.start!, formatDiagnsoticHost, ts.identity) : "";
|
||||
location = Utils.removeTestPathPrefixes(location);
|
||||
if (location && isDefaultLibraryFile(info.file!.fileName)) {
|
||||
location = location.replace(/(lib(?:.*)\.d\.ts):\d+:\d+/i, "$1:--:--");
|
||||
location = location.replace(/(lib.*\.d\.ts):\d+:\d+/i, "$1:--:--");
|
||||
}
|
||||
errLines.push(`!!! related TS${info.code}${location}: ${ts.flattenDiagnosticMessageText(info.messageText, IO.newLine())}`);
|
||||
}
|
||||
@@ -603,7 +605,7 @@ export namespace Compiler {
|
||||
|
||||
let topDiagnostics = minimalDiagnosticsToString(diagnostics, options && options.pretty);
|
||||
topDiagnostics = Utils.removeTestPathPrefixes(topDiagnostics);
|
||||
topDiagnostics = topDiagnostics.replace(/^(lib(?:.*)\.d\.ts)\(\d+,\d+\)/igm, "$1(--,--)");
|
||||
topDiagnostics = topDiagnostics.replace(/^(lib.*\.d\.ts)\(\d+,\d+\)/gim, "$1(--,--)");
|
||||
|
||||
yield [diagnosticSummaryMarker, topDiagnostics + IO.newLine() + IO.newLine(), diagnostics.length];
|
||||
|
||||
@@ -666,7 +668,7 @@ export namespace Compiler {
|
||||
// Calculate the start of the squiggle
|
||||
const squiggleStart = Math.max(0, relativeOffset);
|
||||
// TODO/REVIEW: this doesn't work quite right in the browser if a multi file test has files whose names are just the right length relative to one another
|
||||
outputLines += newLine() + " " + line.substr(0, squiggleStart).replace(/[^\s]/g, " ") + new Array(Math.min(length, line.length - squiggleStart) + 1).join("~");
|
||||
outputLines += newLine() + " " + line.substr(0, squiggleStart).replace(/\S/g, " ") + new Array(Math.min(length, line.length - squiggleStart) + 1).join("~");
|
||||
|
||||
// If the error ended here, or we're at the end of the file, emit its message
|
||||
if ((lineIndex === lines.length - 1) || nextLineStart > end) {
|
||||
@@ -862,7 +864,7 @@ export namespace Compiler {
|
||||
for (const file of allFiles) {
|
||||
const { unitName } = file;
|
||||
let typeLines = "=== " + unitName + " ===\r\n";
|
||||
const codeLines = ts.flatMap(file.content.split(/\r?\n/g), e => e.split(/[\r\u2028\u2029]/g));
|
||||
const codeLines = ts.flatMap(file.content.split(/\r?\n/), e => e.split(/[\r\u2028\u2029]/));
|
||||
const gen: IterableIterator<TypeWriterResult> = isSymbolBaseline ? fullWalker.getSymbols(unitName) : fullWalker.getTypes(unitName);
|
||||
let lastIndexWritten: number | undefined;
|
||||
for (const result of gen) {
|
||||
@@ -1103,7 +1105,7 @@ function splitVaryBySettingValue(text: string, varyBy: string): string[] | undef
|
||||
let star = false;
|
||||
const includes: string[] = [];
|
||||
const excludes: string[] = [];
|
||||
for (let s of text.split(/,/g)) {
|
||||
for (let s of text.split(/,/)) {
|
||||
s = s.trim().toLowerCase();
|
||||
if (s.length === 0) continue;
|
||||
if (s === "*") {
|
||||
@@ -1247,8 +1249,8 @@ export namespace TestCaseParser {
|
||||
}
|
||||
|
||||
// Regex for parsing options in the format "@Alpha: Value of any sort"
|
||||
const optionRegex = /^[/]{2}\s*@(\w+)\s*:\s*([^\r\n]*)/gm; // multiple matches on multiple lines
|
||||
const linkRegex = /^[/]{2}\s*@link\s*:\s*([^\r\n]*)\s*->\s*([^\r\n]*)/gm; // multiple matches on multiple lines
|
||||
const optionRegex = /^\/{2}\s*@(\w+)\s*:\s*([^\r\n]*)/gm; // multiple matches on multiple lines
|
||||
const linkRegex = /^\/{2}\s*@link\s*:\s*([^\r\n]*)\s*->\s*([^\r\n]*)/gm; // multiple matches on multiple lines
|
||||
|
||||
export function parseSymlinkFromTest(line: string, symlinks: vfs.FileSet | undefined, absoluteRootDir?: string) {
|
||||
const linkMetaData = linkRegex.exec(line);
|
||||
|
||||
@@ -41,7 +41,7 @@ export function readTestFile(path: string) {
|
||||
try {
|
||||
content = Harness.IO.readFile(Harness.userSpecifiedRoot + path);
|
||||
}
|
||||
catch (err) {
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ const maxHarnessFrames = 1;
|
||||
export function filterStack(error: Error, stackTraceLimit = Infinity) {
|
||||
const stack = (error as any).stack as string;
|
||||
if (stack) {
|
||||
const lines = stack.split(/\r\n?|\n/g);
|
||||
const lines = stack.split(/\r\n?|\n/);
|
||||
const filtered: string[] = [];
|
||||
let frameCount = 0;
|
||||
let harnessFrameCount = 0;
|
||||
@@ -355,7 +355,7 @@ export function filterStack(error: Error, stackTraceLimit = Infinity) {
|
||||
harnessFrameCount++;
|
||||
}
|
||||
|
||||
line = line.replace(/\bfile:\/\/\/(.*?)(?=(:\d+)*($|\)))/, (_, path) => ts.sys.resolvePath(path));
|
||||
line = line.replace(/\bfile:\/\/\/(.*?)(?=(?::\d+)*(?:$|\)))/, (_, path) => ts.sys.resolvePath(path));
|
||||
frameCount++;
|
||||
}
|
||||
|
||||
@@ -373,11 +373,11 @@ function isStackFrame(line: string) {
|
||||
}
|
||||
|
||||
function isMocha(line: string) {
|
||||
return /[\\/](node_modules|components)[\\/]mocha(js)?[\\/]|[\\/]mocha\.js/.test(line);
|
||||
return /[\\/](?:node_modules|components)[\\/]mocha(?:js)?[\\/]|[\\/]mocha\.js/.test(line);
|
||||
}
|
||||
|
||||
function isNode(line: string) {
|
||||
return /\((timers|events|node|module)\.js:/.test(line);
|
||||
return /\((?:timers|events|node|module)\.js:/.test(line);
|
||||
}
|
||||
|
||||
function isHarness(line: string) {
|
||||
|
||||
@@ -159,7 +159,7 @@ function getProgramStructure(program: ts.Program | undefined) {
|
||||
const baseline: string[] = [];
|
||||
program?.getSourceFiles().slice().sort((f1, f2) => ts.comparePathsCaseSensitive(f1.path, f2.path)).forEach(f => {
|
||||
baseline.push(` File: ${f.fileName} Path: ${f.path} ResolvedPath: ${f.resolvedPath} impliedNodeFormat: ${f.impliedNodeFormat}`);
|
||||
baseline.push(f.text.split(/\r?\n/g).map(l => l ? " " + l : "").join("\n"));
|
||||
baseline.push(f.text.split(/\r?\n/).map(l => l ? " " + l : "").join("\n"));
|
||||
getResolutionCacheDetails(
|
||||
baseline,
|
||||
"Modules",
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
isString,
|
||||
noop,
|
||||
SourceMapper,
|
||||
toSorted,
|
||||
} from "./_namespaces/ts.js";
|
||||
import {
|
||||
AutoImportProviderProject,
|
||||
@@ -93,7 +94,7 @@ export function patchServiceForStateBaseline(service: ProjectService) {
|
||||
function sendLogsToLogger(title: string, logs: StateItemLog[] | undefined) {
|
||||
if (!logs) return;
|
||||
logger.log(title);
|
||||
logs.sort((a, b) => compareStringsCaseSensitive(a[0], b[0]))
|
||||
toSorted(logs, (a, b) => compareStringsCaseSensitive(a[0], b[0]))
|
||||
.forEach(([title, propertyLogs]) => {
|
||||
logger.log(title);
|
||||
propertyLogs.forEach(p => isString(p) ? logger.log(p) : p.forEach(s => logger.log(s)));
|
||||
|
||||
@@ -55,7 +55,7 @@ export abstract class RunnerBase {
|
||||
/** Replaces instances of full paths with fileNames only */
|
||||
static removeFullPaths(path: string) {
|
||||
// If its a full path (starts with "C:" or "/") replace with just the filename
|
||||
let fixedPath = /^(\w:|\/)/.test(path) ? ts.getBaseFileName(path) : path;
|
||||
let fixedPath = /^(?:\w:|\/)/.test(path) ? ts.getBaseFileName(path) : path;
|
||||
|
||||
// when running in the browser the 'full path' is the host name, shows up in error baselines
|
||||
const localHost = /http:\/localhost:\d+/g;
|
||||
|
||||
@@ -279,7 +279,7 @@ export class TypeWriterWalker {
|
||||
}
|
||||
else {
|
||||
const typeFormatFlags = ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.AllowUniqueESSymbolType | ts.TypeFormatFlags.GenerateNamesForShadowedTypeParams;
|
||||
let typeNode = this.checker.typeToTypeNode(type, node.parent, (typeFormatFlags & ts.TypeFormatFlags.NodeBuilderFlagsMask) | ts.NodeBuilderFlags.IgnoreErrors)!;
|
||||
let typeNode = this.checker.typeToTypeNode(type, node.parent, (typeFormatFlags & ts.TypeFormatFlags.NodeBuilderFlagsMask) | ts.NodeBuilderFlags.IgnoreErrors, ts.InternalNodeBuilderFlags.AllowUnresolvedNames)!;
|
||||
if (ts.isIdentifier(node) && ts.isTypeAliasDeclaration(node.parent) && node.parent.name === node && ts.isIdentifier(typeNode) && ts.idText(typeNode) === ts.idText(node)) {
|
||||
// for a complex type alias `type T = ...`, showing "T : T" isn't very helpful for type tests. When the type produced is the same as
|
||||
// the name of the type alias, recreate the type string without reusing the alias name
|
||||
@@ -321,7 +321,7 @@ export class TypeWriterWalker {
|
||||
const declSourceFile = declaration.getSourceFile();
|
||||
const declLineAndCharacter = declSourceFile.getLineAndCharacterOfPosition(declaration.pos);
|
||||
const fileName = ts.getBaseFileName(declSourceFile.fileName);
|
||||
const isLibFile = /lib(.*)\.d\.ts/i.test(fileName);
|
||||
const isLibFile = /lib.*\.d\.ts/i.test(fileName);
|
||||
const declText = `Decl(${fileName}, ${isLibFile ? "--" : declLineAndCharacter.line}, ${isLibFile ? "--" : declLineAndCharacter.character})`;
|
||||
symbolString += declText;
|
||||
(declaration as any).__symbolTestOutputCache = declText;
|
||||
|
||||
+2
-2
@@ -4,13 +4,13 @@ import * as ts from "./_namespaces/ts.js";
|
||||
* Common utilities
|
||||
*/
|
||||
|
||||
const testPathPrefixRegExp = /(?:(file:\/{3})|\/)\.(ts|lib|src)\//g;
|
||||
const testPathPrefixRegExp = /(?:(file:\/{3})|\/)\.(?:ts|lib|src)\//g;
|
||||
export function removeTestPathPrefixes(text: string, retainTrailingDirectorySeparator?: boolean): string {
|
||||
return text !== undefined ? text.replace(testPathPrefixRegExp, (_, scheme) => scheme || (retainTrailingDirectorySeparator ? "/" : "")) : undefined!; // TODO: GH#18217
|
||||
}
|
||||
|
||||
function createDiagnosticMessageReplacer<R extends (messageArgs: string[], ...args: string[]) => string[]>(diagnosticMessage: ts.DiagnosticMessage, replacer: R) {
|
||||
const messageParts = diagnosticMessage.message.split(/{\d+}/g);
|
||||
const messageParts = diagnosticMessage.message.split(/\{\d+\}/);
|
||||
const regExp = new RegExp(`^(?:${messageParts.map(ts.regExpEscape).join("(.*?)")})$`);
|
||||
type Args<R> = R extends (messageArgs: string[], ...args: infer A) => string[] ? A : [];
|
||||
return (text: string, ...args: Args<R>) => text.replace(regExp, (_, ...fixedArgs) => ts.formatStringFromArgs(diagnosticMessage.message, replacer(fixedArgs, ...args)));
|
||||
|
||||
@@ -26,7 +26,7 @@ export import changeExtension = ts.changeAnyExtension;
|
||||
export import isTypeScript = ts.hasTSFileExtension;
|
||||
export import isJavaScript = ts.hasJSFileExtension;
|
||||
|
||||
const invalidRootComponentRegExp = /^(?!(\/|\/\/\w+\/|[a-zA-Z]:\/?|)$)/;
|
||||
const invalidRootComponentRegExp = /^(?!(?:\/|\/\/\w+\/|[a-z]:\/?)?$)/i;
|
||||
const invalidNavigableComponentRegExp = /[:*?"<>|]/;
|
||||
const invalidNavigableComponentWithWildcardsRegExp = /[:"<>|]/;
|
||||
const invalidNonNavigableComponentRegExp = /^\.{1,2}$|[:*?"<>|]/;
|
||||
|
||||
+14
-6
@@ -2,14 +2,22 @@
|
||||
/// Window Async Iterable APIs
|
||||
/////////////////////////////
|
||||
|
||||
interface FileSystemDirectoryHandleAsyncIterator<T> extends AsyncIteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.asyncIterator](): FileSystemDirectoryHandleAsyncIterator<T>;
|
||||
}
|
||||
|
||||
interface FileSystemDirectoryHandle {
|
||||
[Symbol.asyncIterator](): BuiltinAsyncIterator<[string, FileSystemHandle], BuiltinIteratorReturn>;
|
||||
entries(): BuiltinAsyncIterator<[string, FileSystemHandle], BuiltinIteratorReturn>;
|
||||
keys(): BuiltinAsyncIterator<string, BuiltinIteratorReturn>;
|
||||
values(): BuiltinAsyncIterator<FileSystemHandle, BuiltinIteratorReturn>;
|
||||
[Symbol.asyncIterator](): FileSystemDirectoryHandleAsyncIterator<[string, FileSystemHandle]>;
|
||||
entries(): FileSystemDirectoryHandleAsyncIterator<[string, FileSystemHandle]>;
|
||||
keys(): FileSystemDirectoryHandleAsyncIterator<string>;
|
||||
values(): FileSystemDirectoryHandleAsyncIterator<FileSystemHandle>;
|
||||
}
|
||||
|
||||
interface ReadableStreamAsyncIterator<T> extends AsyncIteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.asyncIterator](): ReadableStreamAsyncIterator<T>;
|
||||
}
|
||||
|
||||
interface ReadableStream<R = any> {
|
||||
[Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): BuiltinAsyncIterator<R, BuiltinIteratorReturn>;
|
||||
values(options?: ReadableStreamIteratorOptions): BuiltinAsyncIterator<R, BuiltinIteratorReturn>;
|
||||
[Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
|
||||
values(options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
|
||||
}
|
||||
|
||||
Vendored
+35
-23
@@ -1,30 +1,34 @@
|
||||
/// <reference lib="dom" />
|
||||
|
||||
interface DOMTokenList {
|
||||
[Symbol.iterator](): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface HeadersIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): HeadersIterator<T>;
|
||||
}
|
||||
|
||||
interface Headers {
|
||||
[Symbol.iterator](): BuiltinIterator<[string, string], BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): HeadersIterator<[string, string]>;
|
||||
/**
|
||||
* Returns an iterator allowing to go through all key/value pairs contained in this object.
|
||||
*/
|
||||
entries(): BuiltinIterator<[string, string], BuiltinIteratorReturn>;
|
||||
entries(): HeadersIterator<[string, string]>;
|
||||
/**
|
||||
* Returns an iterator allowing to go through all keys f the key/value pairs contained in this object.
|
||||
*/
|
||||
keys(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
keys(): HeadersIterator<string>;
|
||||
/**
|
||||
* Returns an iterator allowing to go through all values of the key/value pairs contained in this object.
|
||||
*/
|
||||
values(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
values(): HeadersIterator<string>;
|
||||
}
|
||||
|
||||
interface NodeList {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the list
|
||||
*/
|
||||
entries(): BuiltinIterator<[number, Node], BuiltinIteratorReturn>;
|
||||
entries(): ArrayIterator<[number, Node]>;
|
||||
/**
|
||||
* Performs the specified action for each node in an list.
|
||||
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list.
|
||||
@@ -34,21 +38,21 @@ interface NodeList {
|
||||
/**
|
||||
* Returns an list of keys in the list
|
||||
*/
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the list
|
||||
*/
|
||||
values(): BuiltinIterator<Node, BuiltinIteratorReturn>;
|
||||
values(): ArrayIterator<Node>;
|
||||
|
||||
[Symbol.iterator](): BuiltinIterator<Node, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<Node>;
|
||||
}
|
||||
|
||||
interface NodeListOf<TNode extends Node> {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the list
|
||||
*/
|
||||
entries(): BuiltinIterator<[number, TNode], BuiltinIteratorReturn>;
|
||||
entries(): ArrayIterator<[number, TNode]>;
|
||||
|
||||
/**
|
||||
* Performs the specified action for each node in an list.
|
||||
@@ -59,55 +63,63 @@ interface NodeListOf<TNode extends Node> {
|
||||
/**
|
||||
* Returns an list of keys in the list
|
||||
*/
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the list
|
||||
*/
|
||||
values(): BuiltinIterator<TNode, BuiltinIteratorReturn>;
|
||||
values(): ArrayIterator<TNode>;
|
||||
|
||||
[Symbol.iterator](): BuiltinIterator<TNode, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<TNode>;
|
||||
}
|
||||
|
||||
interface HTMLCollectionBase {
|
||||
[Symbol.iterator](): BuiltinIterator<Element, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<Element>;
|
||||
}
|
||||
|
||||
interface HTMLCollectionOf<T extends Element> {
|
||||
[Symbol.iterator](): BuiltinIterator<T, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<T>;
|
||||
}
|
||||
|
||||
interface FormDataIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): FormDataIterator<T>;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the list
|
||||
*/
|
||||
entries(): BuiltinIterator<[string, string | File], BuiltinIteratorReturn>;
|
||||
entries(): FormDataIterator<[string, string | File]>;
|
||||
/**
|
||||
* Returns a list of keys in the list
|
||||
*/
|
||||
keys(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
keys(): FormDataIterator<string>;
|
||||
/**
|
||||
* Returns a list of values in the list
|
||||
*/
|
||||
values(): BuiltinIterator<string | File, BuiltinIteratorReturn>;
|
||||
values(): FormDataIterator<string | File>;
|
||||
|
||||
[Symbol.iterator](): BuiltinIterator<string | File, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): FormDataIterator<string | File>;
|
||||
}
|
||||
|
||||
interface URLSearchParamsIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): URLSearchParamsIterator<T>;
|
||||
}
|
||||
|
||||
interface URLSearchParams {
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the search params
|
||||
*/
|
||||
entries(): BuiltinIterator<[string, string], BuiltinIteratorReturn>;
|
||||
entries(): URLSearchParamsIterator<[string, string]>;
|
||||
/**
|
||||
* Returns a list of keys in the search params
|
||||
*/
|
||||
keys(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
keys(): URLSearchParamsIterator<string>;
|
||||
/**
|
||||
* Returns a list of values in the search params
|
||||
*/
|
||||
values(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
values(): URLSearchParamsIterator<string>;
|
||||
/**
|
||||
* iterate over key/value pairs
|
||||
*/
|
||||
[Symbol.iterator](): BuiltinIterator<[string, string], BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): URLSearchParamsIterator<[string, string]>;
|
||||
}
|
||||
|
||||
Vendored
+93
-73
@@ -23,36 +23,36 @@ interface BaseAudioContext {
|
||||
}
|
||||
|
||||
interface CSSKeyframesRule {
|
||||
[Symbol.iterator](): BuiltinIterator<CSSKeyframeRule, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSKeyframeRule>;
|
||||
}
|
||||
|
||||
interface CSSNumericArray {
|
||||
[Symbol.iterator](): BuiltinIterator<CSSNumericValue, BuiltinIteratorReturn>;
|
||||
entries(): BuiltinIterator<[number, CSSNumericValue], BuiltinIteratorReturn>;
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
values(): BuiltinIterator<CSSNumericValue, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSNumericValue>;
|
||||
entries(): ArrayIterator<[number, CSSNumericValue]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<CSSNumericValue>;
|
||||
}
|
||||
|
||||
interface CSSRuleList {
|
||||
[Symbol.iterator](): BuiltinIterator<CSSRule, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSRule>;
|
||||
}
|
||||
|
||||
interface CSSStyleDeclaration {
|
||||
[Symbol.iterator](): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface CSSTransformValue {
|
||||
[Symbol.iterator](): BuiltinIterator<CSSTransformComponent, BuiltinIteratorReturn>;
|
||||
entries(): BuiltinIterator<[number, CSSTransformComponent], BuiltinIteratorReturn>;
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
values(): BuiltinIterator<CSSTransformComponent, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSTransformComponent>;
|
||||
entries(): ArrayIterator<[number, CSSTransformComponent]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<CSSTransformComponent>;
|
||||
}
|
||||
|
||||
interface CSSUnparsedValue {
|
||||
[Symbol.iterator](): BuiltinIterator<CSSUnparsedSegment, BuiltinIteratorReturn>;
|
||||
entries(): BuiltinIterator<[number, CSSUnparsedSegment], BuiltinIteratorReturn>;
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
values(): BuiltinIterator<CSSUnparsedSegment, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSUnparsedSegment>;
|
||||
entries(): ArrayIterator<[number, CSSUnparsedSegment]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<CSSUnparsedSegment>;
|
||||
}
|
||||
|
||||
interface Cache {
|
||||
@@ -74,72 +74,80 @@ interface CustomStateSet extends Set<string> {
|
||||
}
|
||||
|
||||
interface DOMRectList {
|
||||
[Symbol.iterator](): BuiltinIterator<DOMRect, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<DOMRect>;
|
||||
}
|
||||
|
||||
interface DOMStringList {
|
||||
[Symbol.iterator](): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface DOMTokenList {
|
||||
[Symbol.iterator](): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
entries(): BuiltinIterator<[number, string], BuiltinIteratorReturn>;
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
values(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
entries(): ArrayIterator<[number, string]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface DataTransferItemList {
|
||||
[Symbol.iterator](): BuiltinIterator<DataTransferItem, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<DataTransferItem>;
|
||||
}
|
||||
|
||||
interface EventCounts extends ReadonlyMap<string, number> {
|
||||
}
|
||||
|
||||
interface FileList {
|
||||
[Symbol.iterator](): BuiltinIterator<File, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<File>;
|
||||
}
|
||||
|
||||
interface FontFaceSet extends Set<FontFace> {
|
||||
}
|
||||
|
||||
interface FormDataIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): FormDataIterator<T>;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
[Symbol.iterator](): BuiltinIterator<[string, FormDataEntryValue], BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): FormDataIterator<[string, FormDataEntryValue]>;
|
||||
/** Returns an array of key, value pairs for every entry in the list. */
|
||||
entries(): BuiltinIterator<[string, FormDataEntryValue], BuiltinIteratorReturn>;
|
||||
entries(): FormDataIterator<[string, FormDataEntryValue]>;
|
||||
/** Returns a list of keys in the list. */
|
||||
keys(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
keys(): FormDataIterator<string>;
|
||||
/** Returns a list of values in the list. */
|
||||
values(): BuiltinIterator<FormDataEntryValue, BuiltinIteratorReturn>;
|
||||
values(): FormDataIterator<FormDataEntryValue>;
|
||||
}
|
||||
|
||||
interface HTMLAllCollection {
|
||||
[Symbol.iterator](): BuiltinIterator<Element, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<Element>;
|
||||
}
|
||||
|
||||
interface HTMLCollectionBase {
|
||||
[Symbol.iterator](): BuiltinIterator<Element, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<Element>;
|
||||
}
|
||||
|
||||
interface HTMLCollectionOf<T extends Element> {
|
||||
[Symbol.iterator](): BuiltinIterator<T, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<T>;
|
||||
}
|
||||
|
||||
interface HTMLFormElement {
|
||||
[Symbol.iterator](): BuiltinIterator<Element, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<Element>;
|
||||
}
|
||||
|
||||
interface HTMLSelectElement {
|
||||
[Symbol.iterator](): BuiltinIterator<HTMLOptionElement, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<HTMLOptionElement>;
|
||||
}
|
||||
|
||||
interface HeadersIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): HeadersIterator<T>;
|
||||
}
|
||||
|
||||
interface Headers {
|
||||
[Symbol.iterator](): BuiltinIterator<[string, string], BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): HeadersIterator<[string, string]>;
|
||||
/** Returns an iterator allowing to go through all key/value pairs contained in this object. */
|
||||
entries(): BuiltinIterator<[string, string], BuiltinIteratorReturn>;
|
||||
entries(): HeadersIterator<[string, string]>;
|
||||
/** Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
|
||||
keys(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
keys(): HeadersIterator<string>;
|
||||
/** Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
|
||||
values(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
values(): HeadersIterator<string>;
|
||||
}
|
||||
|
||||
interface Highlight extends Set<AbstractRange> {
|
||||
@@ -179,15 +187,19 @@ interface MIDIOutput {
|
||||
interface MIDIOutputMap extends ReadonlyMap<string, MIDIOutput> {
|
||||
}
|
||||
|
||||
interface MediaKeyStatusMapIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): MediaKeyStatusMapIterator<T>;
|
||||
}
|
||||
|
||||
interface MediaKeyStatusMap {
|
||||
[Symbol.iterator](): BuiltinIterator<[BufferSource, MediaKeyStatus], BuiltinIteratorReturn>;
|
||||
entries(): BuiltinIterator<[BufferSource, MediaKeyStatus], BuiltinIteratorReturn>;
|
||||
keys(): BuiltinIterator<BufferSource, BuiltinIteratorReturn>;
|
||||
values(): BuiltinIterator<MediaKeyStatus, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): MediaKeyStatusMapIterator<[BufferSource, MediaKeyStatus]>;
|
||||
entries(): MediaKeyStatusMapIterator<[BufferSource, MediaKeyStatus]>;
|
||||
keys(): MediaKeyStatusMapIterator<BufferSource>;
|
||||
values(): MediaKeyStatusMapIterator<MediaKeyStatus>;
|
||||
}
|
||||
|
||||
interface MediaList {
|
||||
[Symbol.iterator](): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface MessageEvent<T = any> {
|
||||
@@ -196,11 +208,11 @@ interface MessageEvent<T = any> {
|
||||
}
|
||||
|
||||
interface MimeTypeArray {
|
||||
[Symbol.iterator](): BuiltinIterator<MimeType, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<MimeType>;
|
||||
}
|
||||
|
||||
interface NamedNodeMap {
|
||||
[Symbol.iterator](): BuiltinIterator<Attr, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<Attr>;
|
||||
}
|
||||
|
||||
interface Navigator {
|
||||
@@ -215,31 +227,31 @@ interface Navigator {
|
||||
}
|
||||
|
||||
interface NodeList {
|
||||
[Symbol.iterator](): BuiltinIterator<Node, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<Node>;
|
||||
/** Returns an array of key, value pairs for every entry in the list. */
|
||||
entries(): BuiltinIterator<[number, Node], BuiltinIteratorReturn>;
|
||||
entries(): ArrayIterator<[number, Node]>;
|
||||
/** Returns an list of keys in the list. */
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/** Returns an list of values in the list. */
|
||||
values(): BuiltinIterator<Node, BuiltinIteratorReturn>;
|
||||
values(): ArrayIterator<Node>;
|
||||
}
|
||||
|
||||
interface NodeListOf<TNode extends Node> {
|
||||
[Symbol.iterator](): BuiltinIterator<TNode, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<TNode>;
|
||||
/** Returns an array of key, value pairs for every entry in the list. */
|
||||
entries(): BuiltinIterator<[number, TNode], BuiltinIteratorReturn>;
|
||||
entries(): ArrayIterator<[number, TNode]>;
|
||||
/** Returns an list of keys in the list. */
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/** Returns an list of values in the list. */
|
||||
values(): BuiltinIterator<TNode, BuiltinIteratorReturn>;
|
||||
values(): ArrayIterator<TNode>;
|
||||
}
|
||||
|
||||
interface Plugin {
|
||||
[Symbol.iterator](): BuiltinIterator<MimeType, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<MimeType>;
|
||||
}
|
||||
|
||||
interface PluginArray {
|
||||
[Symbol.iterator](): BuiltinIterator<Plugin, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<Plugin>;
|
||||
}
|
||||
|
||||
interface RTCRtpTransceiver {
|
||||
@@ -251,46 +263,50 @@ interface RTCStatsReport extends ReadonlyMap<string, any> {
|
||||
}
|
||||
|
||||
interface SVGLengthList {
|
||||
[Symbol.iterator](): BuiltinIterator<SVGLength, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<SVGLength>;
|
||||
}
|
||||
|
||||
interface SVGNumberList {
|
||||
[Symbol.iterator](): BuiltinIterator<SVGNumber, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<SVGNumber>;
|
||||
}
|
||||
|
||||
interface SVGPointList {
|
||||
[Symbol.iterator](): BuiltinIterator<DOMPoint, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<DOMPoint>;
|
||||
}
|
||||
|
||||
interface SVGStringList {
|
||||
[Symbol.iterator](): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface SVGTransformList {
|
||||
[Symbol.iterator](): BuiltinIterator<SVGTransform, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<SVGTransform>;
|
||||
}
|
||||
|
||||
interface SourceBufferList {
|
||||
[Symbol.iterator](): BuiltinIterator<SourceBuffer, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<SourceBuffer>;
|
||||
}
|
||||
|
||||
interface SpeechRecognitionResult {
|
||||
[Symbol.iterator](): BuiltinIterator<SpeechRecognitionAlternative, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<SpeechRecognitionAlternative>;
|
||||
}
|
||||
|
||||
interface SpeechRecognitionResultList {
|
||||
[Symbol.iterator](): BuiltinIterator<SpeechRecognitionResult, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<SpeechRecognitionResult>;
|
||||
}
|
||||
|
||||
interface StylePropertyMapReadOnlyIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): StylePropertyMapReadOnlyIterator<T>;
|
||||
}
|
||||
|
||||
interface StylePropertyMapReadOnly {
|
||||
[Symbol.iterator](): BuiltinIterator<[string, Iterable<CSSStyleValue>], BuiltinIteratorReturn>;
|
||||
entries(): BuiltinIterator<[string, Iterable<CSSStyleValue>], BuiltinIteratorReturn>;
|
||||
keys(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
values(): BuiltinIterator<Iterable<CSSStyleValue>, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): StylePropertyMapReadOnlyIterator<[string, Iterable<CSSStyleValue>]>;
|
||||
entries(): StylePropertyMapReadOnlyIterator<[string, Iterable<CSSStyleValue>]>;
|
||||
keys(): StylePropertyMapReadOnlyIterator<string>;
|
||||
values(): StylePropertyMapReadOnlyIterator<Iterable<CSSStyleValue>>;
|
||||
}
|
||||
|
||||
interface StyleSheetList {
|
||||
[Symbol.iterator](): BuiltinIterator<CSSStyleSheet, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSStyleSheet>;
|
||||
}
|
||||
|
||||
interface SubtleCrypto {
|
||||
@@ -309,25 +325,29 @@ interface SubtleCrypto {
|
||||
}
|
||||
|
||||
interface TextTrackCueList {
|
||||
[Symbol.iterator](): BuiltinIterator<TextTrackCue, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<TextTrackCue>;
|
||||
}
|
||||
|
||||
interface TextTrackList {
|
||||
[Symbol.iterator](): BuiltinIterator<TextTrack, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<TextTrack>;
|
||||
}
|
||||
|
||||
interface TouchList {
|
||||
[Symbol.iterator](): BuiltinIterator<Touch, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<Touch>;
|
||||
}
|
||||
|
||||
interface URLSearchParamsIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): URLSearchParamsIterator<T>;
|
||||
}
|
||||
|
||||
interface URLSearchParams {
|
||||
[Symbol.iterator](): BuiltinIterator<[string, string], BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): URLSearchParamsIterator<[string, string]>;
|
||||
/** Returns an array of key, value pairs for every entry in the search params. */
|
||||
entries(): BuiltinIterator<[string, string], BuiltinIteratorReturn>;
|
||||
entries(): URLSearchParamsIterator<[string, string]>;
|
||||
/** Returns a list of keys in the search params. */
|
||||
keys(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
keys(): URLSearchParamsIterator<string>;
|
||||
/** Returns a list of values in the search params. */
|
||||
values(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
values(): URLSearchParamsIterator<string>;
|
||||
}
|
||||
|
||||
interface WEBGL_draw_buffers {
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
/// <reference lib="es2015.iterable" />
|
||||
|
||||
interface Generator<T = unknown, TReturn = any, TNext = any> extends BuiltinIterator<T, TReturn, TNext> {
|
||||
interface Generator<T = unknown, TReturn = any, TNext = any> extends IteratorObject<T, TReturn, TNext> {
|
||||
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
||||
next(...[value]: [] | [TNext]): IteratorResult<T, TReturn>;
|
||||
return(value: TReturn): IteratorResult<T, TReturn>;
|
||||
|
||||
Vendored
+90
-64
@@ -31,34 +31,48 @@ interface Iterable<T, TReturn = any, TNext = any> {
|
||||
[Symbol.iterator](): Iterator<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes a user-defined {@link Iterator} that is also iterable.
|
||||
*/
|
||||
interface IterableIterator<T, TReturn = any, TNext = any> extends Iterator<T, TReturn, TNext> {
|
||||
[Symbol.iterator](): IterableIterator<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
interface BuiltinIterator<T, TReturn = any, TNext = any> extends Iterator<T, TReturn, TNext> {
|
||||
[Symbol.iterator](): BuiltinIterator<T, TReturn, TNext>;
|
||||
/**
|
||||
* Describes an {@link Iterator} produced by the runtime that inherits from the intrinsic `Iterator.prototype`.
|
||||
*/
|
||||
interface IteratorObject<T, TReturn = unknown, TNext = unknown> extends Iterator<T, TReturn, TNext> {
|
||||
[Symbol.iterator](): IteratorObject<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the `TReturn` type used for built-in iterators produced by `Array`, `Map`, `Set`, and others.
|
||||
* This is `undefined` when `strictBuiltInIteratorReturn` is `true`; otherwise, this is `any`.
|
||||
*/
|
||||
type BuiltinIteratorReturn = intrinsic;
|
||||
|
||||
interface ArrayIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): ArrayIterator<T>;
|
||||
}
|
||||
|
||||
interface Array<T> {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): BuiltinIterator<T, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): BuiltinIterator<[number, T], BuiltinIteratorReturn>;
|
||||
entries(): ArrayIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the array
|
||||
*/
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the array
|
||||
*/
|
||||
values(): BuiltinIterator<T, BuiltinIteratorReturn>;
|
||||
values(): ArrayIterator<T>;
|
||||
}
|
||||
|
||||
interface ArrayConstructor {
|
||||
@@ -79,67 +93,71 @@ interface ArrayConstructor {
|
||||
|
||||
interface ReadonlyArray<T> {
|
||||
/** Iterator of values in the array. */
|
||||
[Symbol.iterator](): BuiltinIterator<T, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): BuiltinIterator<[number, T], BuiltinIteratorReturn>;
|
||||
entries(): ArrayIterator<[number, T]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the array
|
||||
*/
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the array
|
||||
*/
|
||||
values(): BuiltinIterator<T, BuiltinIteratorReturn>;
|
||||
values(): ArrayIterator<T>;
|
||||
}
|
||||
|
||||
interface IArguments {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): BuiltinIterator<any, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<any>;
|
||||
}
|
||||
|
||||
interface MapIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): MapIterator<T>;
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
/** Returns an iterable of entries in the map. */
|
||||
[Symbol.iterator](): BuiltinIterator<[K, V], BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): MapIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the map.
|
||||
*/
|
||||
entries(): BuiltinIterator<[K, V], BuiltinIteratorReturn>;
|
||||
entries(): MapIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the map
|
||||
*/
|
||||
keys(): BuiltinIterator<K, BuiltinIteratorReturn>;
|
||||
keys(): MapIterator<K>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the map
|
||||
*/
|
||||
values(): BuiltinIterator<V, BuiltinIteratorReturn>;
|
||||
values(): MapIterator<V>;
|
||||
}
|
||||
|
||||
interface ReadonlyMap<K, V> {
|
||||
/** Returns an iterable of entries in the map. */
|
||||
[Symbol.iterator](): BuiltinIterator<[K, V], BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): MapIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of key, value pairs for every entry in the map.
|
||||
*/
|
||||
entries(): BuiltinIterator<[K, V], BuiltinIteratorReturn>;
|
||||
entries(): MapIterator<[K, V]>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of keys in the map
|
||||
*/
|
||||
keys(): BuiltinIterator<K, BuiltinIteratorReturn>;
|
||||
keys(): MapIterator<K>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the map
|
||||
*/
|
||||
values(): BuiltinIterator<V, BuiltinIteratorReturn>;
|
||||
values(): MapIterator<V>;
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
@@ -153,42 +171,46 @@ interface WeakMapConstructor {
|
||||
new <K extends WeakKey, V>(iterable: Iterable<readonly [K, V]>): WeakMap<K, V>;
|
||||
}
|
||||
|
||||
interface SetIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): SetIterator<T>;
|
||||
}
|
||||
|
||||
interface Set<T> {
|
||||
/** Iterates over values in the set. */
|
||||
[Symbol.iterator](): BuiltinIterator<T, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): SetIterator<T>;
|
||||
/**
|
||||
* Returns an iterable of [v,v] pairs for every value `v` in the set.
|
||||
*/
|
||||
entries(): BuiltinIterator<[T, T], BuiltinIteratorReturn>;
|
||||
entries(): SetIterator<[T, T]>;
|
||||
/**
|
||||
* Despite its name, returns an iterable of the values in the set.
|
||||
*/
|
||||
keys(): BuiltinIterator<T, BuiltinIteratorReturn>;
|
||||
keys(): SetIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the set.
|
||||
*/
|
||||
values(): BuiltinIterator<T, BuiltinIteratorReturn>;
|
||||
values(): SetIterator<T>;
|
||||
}
|
||||
|
||||
interface ReadonlySet<T> {
|
||||
/** Iterates over values in the set. */
|
||||
[Symbol.iterator](): BuiltinIterator<T, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): SetIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of [v,v] pairs for every value `v` in the set.
|
||||
*/
|
||||
entries(): BuiltinIterator<[T, T], BuiltinIteratorReturn>;
|
||||
entries(): SetIterator<[T, T]>;
|
||||
|
||||
/**
|
||||
* Despite its name, returns an iterable of the values in the set.
|
||||
*/
|
||||
keys(): BuiltinIterator<T, BuiltinIteratorReturn>;
|
||||
keys(): SetIterator<T>;
|
||||
|
||||
/**
|
||||
* Returns an iterable of values in the set.
|
||||
*/
|
||||
values(): BuiltinIterator<T, BuiltinIteratorReturn>;
|
||||
values(): SetIterator<T>;
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
@@ -221,25 +243,29 @@ interface PromiseConstructor {
|
||||
race<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>;
|
||||
}
|
||||
|
||||
interface StringIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): StringIterator<T>;
|
||||
}
|
||||
|
||||
interface String {
|
||||
/** Iterator */
|
||||
[Symbol.iterator](): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): StringIterator<string>;
|
||||
}
|
||||
|
||||
interface Int8Array {
|
||||
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Int8ArrayConstructor {
|
||||
@@ -255,19 +281,19 @@ interface Int8ArrayConstructor {
|
||||
}
|
||||
|
||||
interface Uint8Array {
|
||||
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint8ArrayConstructor {
|
||||
@@ -283,21 +309,21 @@ interface Uint8ArrayConstructor {
|
||||
}
|
||||
|
||||
interface Uint8ClampedArray {
|
||||
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint8ClampedArrayConstructor {
|
||||
@@ -313,21 +339,21 @@ interface Uint8ClampedArrayConstructor {
|
||||
}
|
||||
|
||||
interface Int16Array {
|
||||
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Int16ArrayConstructor {
|
||||
@@ -343,19 +369,19 @@ interface Int16ArrayConstructor {
|
||||
}
|
||||
|
||||
interface Uint16Array {
|
||||
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint16ArrayConstructor {
|
||||
@@ -371,19 +397,19 @@ interface Uint16ArrayConstructor {
|
||||
}
|
||||
|
||||
interface Int32Array {
|
||||
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Int32ArrayConstructor {
|
||||
@@ -399,19 +425,19 @@ interface Int32ArrayConstructor {
|
||||
}
|
||||
|
||||
interface Uint32Array {
|
||||
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Uint32ArrayConstructor {
|
||||
@@ -427,19 +453,19 @@ interface Uint32ArrayConstructor {
|
||||
}
|
||||
|
||||
interface Float32Array {
|
||||
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Float32ArrayConstructor {
|
||||
@@ -455,19 +481,19 @@ interface Float32ArrayConstructor {
|
||||
}
|
||||
|
||||
interface Float64Array {
|
||||
[Symbol.iterator](): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an array of key, value pairs for every entry in the array
|
||||
*/
|
||||
entries(): BuiltinIterator<[number, number], BuiltinIteratorReturn>;
|
||||
entries(): ArrayIterator<[number, number]>;
|
||||
/**
|
||||
* Returns an list of keys in the array
|
||||
*/
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
keys(): ArrayIterator<number>;
|
||||
/**
|
||||
* Returns an list of values in the array
|
||||
*/
|
||||
values(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
values(): ArrayIterator<number>;
|
||||
}
|
||||
|
||||
interface Float64ArrayConstructor {
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
/// <reference lib="es2018.asynciterable" />
|
||||
|
||||
interface AsyncGenerator<T = unknown, TReturn = any, TNext = any> extends BuiltinAsyncIterator<T, TReturn, TNext> {
|
||||
interface AsyncGenerator<T = unknown, TReturn = any, TNext = any> extends AsyncIteratorObject<T, TReturn, TNext> {
|
||||
// NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
||||
next(...[value]: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
|
||||
return(value: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T, TReturn>>;
|
||||
|
||||
Vendored
+8
-2
@@ -20,10 +20,16 @@ interface AsyncIterable<T, TReturn = any, TNext = any> {
|
||||
[Symbol.asyncIterator](): AsyncIterator<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes a user-defined {@link AsyncIterator} that is also async iterable.
|
||||
*/
|
||||
interface AsyncIterableIterator<T, TReturn = any, TNext = any> extends AsyncIterator<T, TReturn, TNext> {
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
interface BuiltinAsyncIterator<T, TReturn = any, TNext = any> extends AsyncIterator<T, TReturn, TNext> {
|
||||
[Symbol.asyncIterator](): BuiltinAsyncIterator<T, TReturn, TNext>;
|
||||
/**
|
||||
* Describes an {@link AsyncIterator} produced by the runtime that inherits from the intrinsic `AsyncIterator.prototype`.
|
||||
*/
|
||||
interface AsyncIteratorObject<T, TReturn = unknown, TNext = unknown> extends AsyncIterator<T, TReturn, TNext> {
|
||||
[Symbol.asyncIterator](): AsyncIteratorObject<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
Vendored
+8
-8
@@ -153,7 +153,7 @@ interface BigInt64Array {
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
|
||||
/** Yields index, value pairs for every entry in the array. */
|
||||
entries(): BuiltinIterator<[number, bigint], BuiltinIteratorReturn>;
|
||||
entries(): ArrayIterator<[number, bigint]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -238,7 +238,7 @@ interface BigInt64Array {
|
||||
join(separator?: string): string;
|
||||
|
||||
/** Yields each index in the array. */
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -360,9 +360,9 @@ interface BigInt64Array {
|
||||
valueOf(): BigInt64Array;
|
||||
|
||||
/** Yields each value in the array. */
|
||||
values(): BuiltinIterator<bigint, BuiltinIteratorReturn>;
|
||||
values(): ArrayIterator<bigint>;
|
||||
|
||||
[Symbol.iterator](): BuiltinIterator<bigint, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<bigint>;
|
||||
|
||||
readonly [Symbol.toStringTag]: "BigInt64Array";
|
||||
|
||||
@@ -425,7 +425,7 @@ interface BigUint64Array {
|
||||
copyWithin(target: number, start: number, end?: number): this;
|
||||
|
||||
/** Yields index, value pairs for every entry in the array. */
|
||||
entries(): BuiltinIterator<[number, bigint], BuiltinIteratorReturn>;
|
||||
entries(): ArrayIterator<[number, bigint]>;
|
||||
|
||||
/**
|
||||
* Determines whether all the members of an array satisfy the specified test.
|
||||
@@ -510,7 +510,7 @@ interface BigUint64Array {
|
||||
join(separator?: string): string;
|
||||
|
||||
/** Yields each index in the array. */
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
keys(): ArrayIterator<number>;
|
||||
|
||||
/**
|
||||
* Returns the index of the last occurrence of a value in an array.
|
||||
@@ -632,9 +632,9 @@ interface BigUint64Array {
|
||||
valueOf(): BigUint64Array;
|
||||
|
||||
/** Yields each value in the array. */
|
||||
values(): BuiltinIterator<bigint, BuiltinIteratorReturn>;
|
||||
values(): ArrayIterator<bigint>;
|
||||
|
||||
[Symbol.iterator](): BuiltinIterator<bigint, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<bigint>;
|
||||
|
||||
readonly [Symbol.toStringTag]: "BigUint64Array";
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
/// <reference lib="es2015.iterable" />
|
||||
/// <reference lib="es2020.symbol.wellknown" />
|
||||
|
||||
interface String {
|
||||
/**
|
||||
@@ -6,7 +6,7 @@ interface String {
|
||||
* containing the results of that search.
|
||||
* @param regexp A variable name or string literal containing the regular expression pattern and flags.
|
||||
*/
|
||||
matchAll(regexp: RegExp): BuiltinIterator<RegExpExecArray, BuiltinIteratorReturn>;
|
||||
matchAll(regexp: RegExp): RegExpStringIterator<RegExpExecArray>;
|
||||
|
||||
/** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */
|
||||
toLocaleLowerCase(locales?: Intl.LocalesArgument): string;
|
||||
|
||||
Vendored
+5
-1
@@ -9,11 +9,15 @@ interface SymbolConstructor {
|
||||
readonly matchAll: unique symbol;
|
||||
}
|
||||
|
||||
interface RegExpStringIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): RegExpStringIterator<T>;
|
||||
}
|
||||
|
||||
interface RegExp {
|
||||
/**
|
||||
* Matches a string with this regular expression, and returns an iterable of matches
|
||||
* containing the results of that search.
|
||||
* @param string A string to search within.
|
||||
*/
|
||||
[Symbol.matchAll](str: string): BuiltinIterator<RegExpMatchArray, BuiltinIteratorReturn>;
|
||||
[Symbol.matchAll](str: string): RegExpStringIterator<RegExpMatchArray>;
|
||||
}
|
||||
|
||||
Vendored
+5
-1
@@ -28,6 +28,10 @@ declare namespace Intl {
|
||||
granularity: "grapheme" | "word" | "sentence";
|
||||
}
|
||||
|
||||
interface SegmentIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): SegmentIterator<T>;
|
||||
}
|
||||
|
||||
interface Segments {
|
||||
/**
|
||||
* Returns an object describing the segment in the original string that includes the code unit at a specified index.
|
||||
@@ -37,7 +41,7 @@ declare namespace Intl {
|
||||
containing(codeUnitIndex?: number): SegmentData;
|
||||
|
||||
/** Returns an iterator to iterate over the segments. */
|
||||
[Symbol.iterator](): BuiltinIterator<SegmentData, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): SegmentIterator<SegmentData>;
|
||||
}
|
||||
|
||||
interface SegmentData {
|
||||
|
||||
Vendored
+8
@@ -1,4 +1,6 @@
|
||||
/// <reference lib="es2015.symbol" />
|
||||
/// <reference lib="es2015.iterable" />
|
||||
/// <reference lib="es2018.asynciterable" />
|
||||
|
||||
interface SymbolConstructor {
|
||||
/**
|
||||
@@ -165,3 +167,9 @@ interface AsyncDisposableStackConstructor {
|
||||
readonly prototype: AsyncDisposableStack;
|
||||
}
|
||||
declare var AsyncDisposableStack: AsyncDisposableStackConstructor;
|
||||
|
||||
interface IteratorObject<T, TReturn, TNext> extends Disposable {
|
||||
}
|
||||
|
||||
interface AsyncIteratorObject<T, TReturn, TNext> extends AsyncDisposable {
|
||||
}
|
||||
|
||||
Vendored
+16
-16
@@ -7,59 +7,59 @@
|
||||
export {};
|
||||
|
||||
// Abstract type that allows us to mark `next` as `abstract`
|
||||
declare abstract class Iterator<T> { // eslint-disable-line @typescript-eslint/no-unsafe-declaration-merging
|
||||
abstract next(value?: unknown): IteratorResult<T, undefined>;
|
||||
declare abstract class Iterator<T, TResult = undefined, TNext = unknown> { // eslint-disable-line @typescript-eslint/no-unsafe-declaration-merging
|
||||
abstract next(value?: TNext): IteratorResult<T, TResult>;
|
||||
}
|
||||
|
||||
// Merge all members of `BuiltinIterator<T>` into `Iterator<T>`
|
||||
interface Iterator<T> extends globalThis.BuiltinIterator<T, undefined, unknown> {}
|
||||
// Merge all members of `IteratorObject<T>` into `Iterator<T>`
|
||||
interface Iterator<T, TResult, TNext> extends globalThis.IteratorObject<T, TResult, TNext> {}
|
||||
|
||||
// Capture the `Iterator` constructor in a type we can use in the `extends` clause of `IteratorConstructor`.
|
||||
type BuiltinIteratorConstructor = typeof Iterator;
|
||||
type IteratorObjectConstructor = typeof Iterator;
|
||||
|
||||
declare global {
|
||||
// Global `BuiltinIterator<T>` interface that can be augmented by polyfills
|
||||
interface BuiltinIterator<T, TReturn, TNext> {
|
||||
// Global `IteratorObject<T, TReturn, TNext>` interface that can be augmented by polyfills
|
||||
interface IteratorObject<T, TReturn, TNext> {
|
||||
/**
|
||||
* Returns this iterator.
|
||||
*/
|
||||
[Symbol.iterator](): BuiltinIterator<T, TReturn, TNext>;
|
||||
[Symbol.iterator](): IteratorObject<T, TReturn, TNext>;
|
||||
|
||||
/**
|
||||
* Creates an iterator whose values are the result of applying the callback to the values from this iterator.
|
||||
* @param callbackfn A function that accepts up to two arguments to be used to transform values from the underlying iterator.
|
||||
*/
|
||||
map<U>(callbackfn: (value: T, index: number) => U): BuiltinIterator<U, undefined>;
|
||||
map<U>(callbackfn: (value: T, index: number) => U): IteratorObject<U, undefined, unknown>;
|
||||
|
||||
/**
|
||||
* Creates an iterator whose values are those from this iterator for which the provided predicate returns true.
|
||||
* @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator.
|
||||
*/
|
||||
filter<S extends T>(predicate: (value: T, index: number) => value is S): BuiltinIterator<S, undefined>;
|
||||
filter<S extends T>(predicate: (value: T, index: number) => value is S): IteratorObject<S, undefined, unknown>;
|
||||
|
||||
/**
|
||||
* Creates an iterator whose values are those from this iterator for which the provided predicate returns true.
|
||||
* @param predicate A function that accepts up to two arguments to be used to test values from the underlying iterator.
|
||||
*/
|
||||
filter(predicate: (value: T, index: number) => unknown): BuiltinIterator<T, undefined>;
|
||||
filter(predicate: (value: T, index: number) => unknown): IteratorObject<T, undefined, unknown>;
|
||||
|
||||
/**
|
||||
* Creates an iterator whose values are the values from this iterator, stopping once the provided limit is reached.
|
||||
* @param limit The maximum number of values to yield.
|
||||
*/
|
||||
take(limit: number): BuiltinIterator<T, undefined>;
|
||||
take(limit: number): IteratorObject<T, undefined, unknown>;
|
||||
|
||||
/**
|
||||
* Creates an iterator whose values are the values from this iterator after skipping the provided count.
|
||||
* @param count The number of values to drop.
|
||||
*/
|
||||
drop(count: number): BuiltinIterator<T, undefined>;
|
||||
drop(count: number): IteratorObject<T, undefined, unknown>;
|
||||
|
||||
/**
|
||||
* Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables.
|
||||
* @param callback A function that accepts up to two arguments to be used to transform values from the underlying iterator into new iterators or iterables to be flattened into the result.
|
||||
*/
|
||||
flatMap<U>(callback: (value: T, index: number) => Iterator<U, unknown, undefined> | Iterable<U, unknown, undefined>): BuiltinIterator<U, undefined>;
|
||||
flatMap<U>(callback: (value: T, index: number) => Iterator<U, unknown, undefined> | Iterable<U, unknown, undefined>): IteratorObject<U, undefined, unknown>;
|
||||
|
||||
/**
|
||||
* Calls the specified callback function for all the elements in this iterator. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
|
||||
@@ -117,13 +117,13 @@ declare global {
|
||||
}
|
||||
|
||||
// Global `IteratorConstructor` interface that can be augmented by polyfills
|
||||
interface IteratorConstructor extends BuiltinIteratorConstructor {
|
||||
interface IteratorConstructor extends IteratorObjectConstructor {
|
||||
/**
|
||||
* Creates a native iterator from an iterator or iterable object.
|
||||
* Returns its input if the input already inherits from the built-in Iterator class.
|
||||
* @param value An iterator or iterable object to convert a native iterator.
|
||||
*/
|
||||
from<T>(value: Iterator<T, unknown, undefined> | Iterable<T, unknown, undefined>): BuiltinIterator<T, undefined>;
|
||||
from<T>(value: Iterator<T, unknown, undefined> | Iterable<T, unknown, undefined>): IteratorObject<T, undefined, unknown>;
|
||||
}
|
||||
|
||||
var Iterator: IteratorConstructor;
|
||||
|
||||
+14
-6
@@ -2,14 +2,22 @@
|
||||
/// Worker Async Iterable APIs
|
||||
/////////////////////////////
|
||||
|
||||
interface FileSystemDirectoryHandleAsyncIterator<T> extends AsyncIteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.asyncIterator](): FileSystemDirectoryHandleAsyncIterator<T>;
|
||||
}
|
||||
|
||||
interface FileSystemDirectoryHandle {
|
||||
[Symbol.asyncIterator](): BuiltinAsyncIterator<[string, FileSystemHandle], BuiltinIteratorReturn>;
|
||||
entries(): BuiltinAsyncIterator<[string, FileSystemHandle], BuiltinIteratorReturn>;
|
||||
keys(): BuiltinAsyncIterator<string, BuiltinIteratorReturn>;
|
||||
values(): BuiltinAsyncIterator<FileSystemHandle, BuiltinIteratorReturn>;
|
||||
[Symbol.asyncIterator](): FileSystemDirectoryHandleAsyncIterator<[string, FileSystemHandle]>;
|
||||
entries(): FileSystemDirectoryHandleAsyncIterator<[string, FileSystemHandle]>;
|
||||
keys(): FileSystemDirectoryHandleAsyncIterator<string>;
|
||||
values(): FileSystemDirectoryHandleAsyncIterator<FileSystemHandle>;
|
||||
}
|
||||
|
||||
interface ReadableStreamAsyncIterator<T> extends AsyncIteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.asyncIterator](): ReadableStreamAsyncIterator<T>;
|
||||
}
|
||||
|
||||
interface ReadableStream<R = any> {
|
||||
[Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): BuiltinAsyncIterator<R, BuiltinIteratorReturn>;
|
||||
values(options?: ReadableStreamIteratorOptions): BuiltinAsyncIterator<R, BuiltinIteratorReturn>;
|
||||
[Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
|
||||
values(options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
|
||||
}
|
||||
|
||||
+46
-30
@@ -8,24 +8,24 @@ interface AbortSignal {
|
||||
}
|
||||
|
||||
interface CSSNumericArray {
|
||||
[Symbol.iterator](): BuiltinIterator<CSSNumericValue, BuiltinIteratorReturn>;
|
||||
entries(): BuiltinIterator<[number, CSSNumericValue], BuiltinIteratorReturn>;
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
values(): BuiltinIterator<CSSNumericValue, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSNumericValue>;
|
||||
entries(): ArrayIterator<[number, CSSNumericValue]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<CSSNumericValue>;
|
||||
}
|
||||
|
||||
interface CSSTransformValue {
|
||||
[Symbol.iterator](): BuiltinIterator<CSSTransformComponent, BuiltinIteratorReturn>;
|
||||
entries(): BuiltinIterator<[number, CSSTransformComponent], BuiltinIteratorReturn>;
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
values(): BuiltinIterator<CSSTransformComponent, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSTransformComponent>;
|
||||
entries(): ArrayIterator<[number, CSSTransformComponent]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<CSSTransformComponent>;
|
||||
}
|
||||
|
||||
interface CSSUnparsedValue {
|
||||
[Symbol.iterator](): BuiltinIterator<CSSUnparsedSegment, BuiltinIteratorReturn>;
|
||||
entries(): BuiltinIterator<[number, CSSUnparsedSegment], BuiltinIteratorReturn>;
|
||||
keys(): BuiltinIterator<number, BuiltinIteratorReturn>;
|
||||
values(): BuiltinIterator<CSSUnparsedSegment, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<CSSUnparsedSegment>;
|
||||
entries(): ArrayIterator<[number, CSSUnparsedSegment]>;
|
||||
keys(): ArrayIterator<number>;
|
||||
values(): ArrayIterator<CSSUnparsedSegment>;
|
||||
}
|
||||
|
||||
interface Cache {
|
||||
@@ -44,34 +44,42 @@ interface CanvasPathDrawingStyles {
|
||||
}
|
||||
|
||||
interface DOMStringList {
|
||||
[Symbol.iterator](): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<string>;
|
||||
}
|
||||
|
||||
interface FileList {
|
||||
[Symbol.iterator](): BuiltinIterator<File, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): ArrayIterator<File>;
|
||||
}
|
||||
|
||||
interface FontFaceSet extends Set<FontFace> {
|
||||
}
|
||||
|
||||
interface FormDataIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): FormDataIterator<T>;
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
[Symbol.iterator](): BuiltinIterator<[string, FormDataEntryValue], BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): FormDataIterator<[string, FormDataEntryValue]>;
|
||||
/** Returns an array of key, value pairs for every entry in the list. */
|
||||
entries(): BuiltinIterator<[string, FormDataEntryValue], BuiltinIteratorReturn>;
|
||||
entries(): FormDataIterator<[string, FormDataEntryValue]>;
|
||||
/** Returns a list of keys in the list. */
|
||||
keys(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
keys(): FormDataIterator<string>;
|
||||
/** Returns a list of values in the list. */
|
||||
values(): BuiltinIterator<FormDataEntryValue, BuiltinIteratorReturn>;
|
||||
values(): FormDataIterator<FormDataEntryValue>;
|
||||
}
|
||||
|
||||
interface HeadersIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): HeadersIterator<T>;
|
||||
}
|
||||
|
||||
interface Headers {
|
||||
[Symbol.iterator](): BuiltinIterator<[string, string], BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): HeadersIterator<[string, string]>;
|
||||
/** Returns an iterator allowing to go through all key/value pairs contained in this object. */
|
||||
entries(): BuiltinIterator<[string, string], BuiltinIteratorReturn>;
|
||||
entries(): HeadersIterator<[string, string]>;
|
||||
/** Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
|
||||
keys(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
keys(): HeadersIterator<string>;
|
||||
/** Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
|
||||
values(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
values(): HeadersIterator<string>;
|
||||
}
|
||||
|
||||
interface IDBDatabase {
|
||||
@@ -99,11 +107,15 @@ interface MessageEvent<T = any> {
|
||||
initMessageEvent(type: string, bubbles?: boolean, cancelable?: boolean, data?: any, origin?: string, lastEventId?: string, source?: MessageEventSource | null, ports?: Iterable<MessagePort>): void;
|
||||
}
|
||||
|
||||
interface StylePropertyMapReadOnlyIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): StylePropertyMapReadOnlyIterator<T>;
|
||||
}
|
||||
|
||||
interface StylePropertyMapReadOnly {
|
||||
[Symbol.iterator](): BuiltinIterator<[string, Iterable<CSSStyleValue>], BuiltinIteratorReturn>;
|
||||
entries(): BuiltinIterator<[string, Iterable<CSSStyleValue>], BuiltinIteratorReturn>;
|
||||
keys(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
values(): BuiltinIterator<Iterable<CSSStyleValue>, BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): StylePropertyMapReadOnlyIterator<[string, Iterable<CSSStyleValue>]>;
|
||||
entries(): StylePropertyMapReadOnlyIterator<[string, Iterable<CSSStyleValue>]>;
|
||||
keys(): StylePropertyMapReadOnlyIterator<string>;
|
||||
values(): StylePropertyMapReadOnlyIterator<Iterable<CSSStyleValue>>;
|
||||
}
|
||||
|
||||
interface SubtleCrypto {
|
||||
@@ -121,14 +133,18 @@ interface SubtleCrypto {
|
||||
unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, unwrappedKeyAlgorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: Iterable<KeyUsage>): Promise<CryptoKey>;
|
||||
}
|
||||
|
||||
interface URLSearchParamsIterator<T> extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): URLSearchParamsIterator<T>;
|
||||
}
|
||||
|
||||
interface URLSearchParams {
|
||||
[Symbol.iterator](): BuiltinIterator<[string, string], BuiltinIteratorReturn>;
|
||||
[Symbol.iterator](): URLSearchParamsIterator<[string, string]>;
|
||||
/** Returns an array of key, value pairs for every entry in the search params. */
|
||||
entries(): BuiltinIterator<[string, string], BuiltinIteratorReturn>;
|
||||
entries(): URLSearchParamsIterator<[string, string]>;
|
||||
/** Returns a list of keys in the search params. */
|
||||
keys(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
keys(): URLSearchParamsIterator<string>;
|
||||
/** Returns a list of values in the search params. */
|
||||
values(): BuiltinIterator<string, BuiltinIteratorReturn>;
|
||||
values(): URLSearchParamsIterator<string>;
|
||||
}
|
||||
|
||||
interface WEBGL_draw_buffers {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+203
-186
@@ -31,8 +31,9 @@ import {
|
||||
DocumentRegistry,
|
||||
DocumentRegistryBucketKeyWithMode,
|
||||
emptyOptions,
|
||||
endsWith,
|
||||
ensureTrailingDirectorySeparator,
|
||||
equateStringsCaseInsensitive,
|
||||
equateStringsCaseSensitive,
|
||||
ExtendedConfigCacheEntry,
|
||||
FileExtensionInfo,
|
||||
fileExtensionIs,
|
||||
@@ -78,6 +79,7 @@ import {
|
||||
length,
|
||||
map,
|
||||
mapDefinedIterator,
|
||||
memoize,
|
||||
missingFileModifiedTime,
|
||||
MultiMap,
|
||||
noop,
|
||||
@@ -642,37 +644,10 @@ export interface ProjectServiceOptions {
|
||||
*/
|
||||
export type ConfigFileName = NormalizedPath | false;
|
||||
|
||||
/**
|
||||
* Stores cached config file name for info as well as ancestor so is a map
|
||||
* Key is false for Open ScriptInfo
|
||||
* Key is NormalizedPath for Config file name
|
||||
* @internal
|
||||
*/
|
||||
export type ConfigFileMapForOpenFile = Map<ConfigFileName, ConfigFileName>;
|
||||
|
||||
/**
|
||||
* The cache for open script info will have
|
||||
* ConfigFileName or false if ancestors are not looked up
|
||||
* Map if ancestors are looked up
|
||||
* @internal
|
||||
*/
|
||||
export type ConfigFileForOpenFile = ConfigFileName | ConfigFileMapForOpenFile;
|
||||
|
||||
/** Gets cached value of config file name based on open script info or ancestor script info */
|
||||
function getConfigFileNameFromCache(info: OpenScriptInfoOrClosedOrConfigFileInfo, cache: Map<Path, ConfigFileForOpenFile> | undefined): ConfigFileName | undefined {
|
||||
if (!cache) return undefined;
|
||||
const configFileForOpenFile = cache.get(info.path);
|
||||
if (configFileForOpenFile === undefined) return undefined;
|
||||
if (!isAncestorConfigFileInfo(info)) {
|
||||
return isString(configFileForOpenFile) || !configFileForOpenFile ?
|
||||
configFileForOpenFile : // direct result
|
||||
configFileForOpenFile.get(/*key*/ false); // Its a map, use false as the key for the info's config file name
|
||||
}
|
||||
else {
|
||||
return configFileForOpenFile && !isString(configFileForOpenFile) ? // Map with fileName as key
|
||||
configFileForOpenFile.get(info.fileName) :
|
||||
undefined; // No result for the config file name
|
||||
}
|
||||
function getConfigFileNameFromCache(info: OpenScriptInfoOrClosedOrConfigFileInfo, cache: Map<Path, ConfigFileName> | undefined): ConfigFileName | undefined {
|
||||
if (!cache || isAncestorConfigFileInfo(info)) return undefined;
|
||||
return cache.get(info.path);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -687,7 +662,6 @@ export interface AncestorConfigFileInfo {
|
||||
/** path of open file so we can look at correct root */
|
||||
path: Path;
|
||||
configFileInfo: true;
|
||||
isForDefaultProject: boolean;
|
||||
}
|
||||
/** @internal */
|
||||
export type OpenScriptInfoOrClosedFileInfo = ScriptInfo | OriginalFileInfo;
|
||||
@@ -736,8 +710,6 @@ function forEachAncestorProject<T>(
|
||||
allowDeferredClosed: boolean | undefined,
|
||||
/** Used with ConfiguredProjectLoadKind.Reload to check if this project was already reloaded */
|
||||
reloadedProjects: Set<ConfiguredProject> | undefined,
|
||||
/** true means we are looking for solution, so we can stop if found project is not composite to go into parent solution */
|
||||
searchOnlyPotentialSolution: boolean,
|
||||
/** Used with ConfiguredProjectLoadKind.Reload to specify delay reload, and also a set of configured projects already marked for delay load */
|
||||
delayReloadedConfiguredProjects?: Set<ConfiguredProject>,
|
||||
): T | undefined {
|
||||
@@ -747,10 +719,7 @@ function forEachAncestorProject<T>(
|
||||
if (
|
||||
!project.isInitialLoadPending() &&
|
||||
(
|
||||
(searchOnlyPotentialSolution && !project.getCompilerOptions().composite) ||
|
||||
// Currently disableSolutionSearching is shared for finding solution/project when
|
||||
// - loading solution for find all references
|
||||
// - trying to find default project
|
||||
!project.getCompilerOptions().composite ||
|
||||
project.getCompilerOptions().disableSolutionSearching
|
||||
)
|
||||
) return;
|
||||
@@ -760,7 +729,6 @@ function forEachAncestorProject<T>(
|
||||
fileName: project.getConfigFilePath(),
|
||||
path: info.path,
|
||||
configFileInfo: true,
|
||||
isForDefaultProject: !searchOnlyPotentialSolution,
|
||||
}, kind === ConfiguredProjectLoadKind.Find);
|
||||
if (!configFileName) return;
|
||||
|
||||
@@ -770,9 +738,9 @@ function forEachAncestorProject<T>(
|
||||
kind,
|
||||
reason,
|
||||
allowDeferredClosed,
|
||||
!searchOnlyPotentialSolution ? info.fileName : undefined, // Config Diag event for project if its for default project
|
||||
/*triggerFile*/ undefined,
|
||||
reloadedProjects,
|
||||
searchOnlyPotentialSolution, // Delay load if we are searching for solution
|
||||
/*delayLoad*/ true,
|
||||
delayReloadedConfiguredProjects,
|
||||
);
|
||||
if (!ancestor) return;
|
||||
@@ -1060,7 +1028,7 @@ export interface ParsedConfig {
|
||||
*/
|
||||
projects: Map<NormalizedPath, boolean>;
|
||||
parsedCommandLine?: ParsedCommandLine;
|
||||
watchedDirectories?: Map<string, WildcardDirectoryWatcher>;
|
||||
watchedDirectories?: Map<string, WildcardDirectoryWatcher<WildcardWatcher>>;
|
||||
/**
|
||||
* true if watchedDirectories need to be updated as per parsedCommandLine's updated watched directories
|
||||
*/
|
||||
@@ -1238,7 +1206,7 @@ export class ProjectService {
|
||||
*/
|
||||
readonly openFiles: Map<Path, NormalizedPath | undefined> = new Map<Path, NormalizedPath | undefined>();
|
||||
/** Config files looked up and cached config files for open script info */
|
||||
private readonly configFileForOpenFiles = new Map<Path, ConfigFileForOpenFile>();
|
||||
private readonly configFileForOpenFiles = new Map<Path, ConfigFileName>();
|
||||
/** Set of open script infos that are root of inferred project */
|
||||
private rootOfInferredProjects = new Set<ScriptInfo>();
|
||||
/**
|
||||
@@ -1277,7 +1245,7 @@ export class ProjectService {
|
||||
* All the open script info that needs recalculation of the default project,
|
||||
* this also caches config file info before config file change was detected to use it in case projects are not updated yet
|
||||
*/
|
||||
private pendingOpenFileProjectUpdates?: Map<Path, ConfigFileForOpenFile>;
|
||||
private pendingOpenFileProjectUpdates?: Map<Path, ConfigFileName>;
|
||||
/** @internal */
|
||||
pendingEnsureProjectForOpenFiles = false;
|
||||
|
||||
@@ -1852,80 +1820,22 @@ export class ProjectService {
|
||||
/**
|
||||
* This is to watch whenever files are added or removed to the wildcard directories
|
||||
*/
|
||||
private watchWildcardDirectory(directory: string, flags: WatchDirectoryFlags, configFileName: NormalizedPath, config: ParsedConfig) {
|
||||
private watchWildcardDirectory(
|
||||
directory: string,
|
||||
flags: WatchDirectoryFlags,
|
||||
configFileName: NormalizedPath,
|
||||
config: ParsedConfig,
|
||||
) {
|
||||
let watcher: FileWatcher | undefined = this.watchFactory.watchDirectory(
|
||||
directory,
|
||||
fileOrDirectory => {
|
||||
const fileOrDirectoryPath = this.toPath(fileOrDirectory);
|
||||
const fsResult = config.cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
|
||||
if (
|
||||
getBaseFileName(fileOrDirectoryPath) === "package.json" && !isInsideNodeModules(fileOrDirectoryPath) &&
|
||||
(fsResult && fsResult.fileExists || !fsResult && this.host.fileExists(fileOrDirectory))
|
||||
) {
|
||||
const file = this.getNormalizedAbsolutePath(fileOrDirectory);
|
||||
this.logger.info(`Config: ${configFileName} Detected new package.json: ${file}`);
|
||||
this.packageJsonCache.addOrUpdate(file, fileOrDirectoryPath);
|
||||
this.watchPackageJsonFile(file, fileOrDirectoryPath, result);
|
||||
}
|
||||
|
||||
const configuredProjectForConfig = this.findConfiguredProjectByProjectName(configFileName);
|
||||
if (
|
||||
isIgnoredFileFromWildCardWatching({
|
||||
watchedDirPath: this.toPath(directory),
|
||||
fileOrDirectory,
|
||||
fileOrDirectoryPath,
|
||||
configFileName,
|
||||
extraFileExtensions: this.hostConfiguration.extraFileExtensions,
|
||||
currentDirectory: this.currentDirectory,
|
||||
options: config.parsedCommandLine!.options,
|
||||
program: configuredProjectForConfig?.getCurrentProgram() || config.parsedCommandLine!.fileNames,
|
||||
useCaseSensitiveFileNames: this.host.useCaseSensitiveFileNames,
|
||||
writeLog: s => this.logger.info(s),
|
||||
toPath: s => this.toPath(s),
|
||||
getScriptKind: configuredProjectForConfig ? (fileName => configuredProjectForConfig.getScriptKind(fileName)) : undefined,
|
||||
})
|
||||
) return;
|
||||
|
||||
// Reload is pending, do the reload
|
||||
if (config.updateLevel !== ProgramUpdateLevel.Full) config.updateLevel = ProgramUpdateLevel.RootNamesAndUpdate;
|
||||
config.projects.forEach((watchWildcardDirectories, projectCanonicalPath) => {
|
||||
if (!watchWildcardDirectories) return;
|
||||
const project = this.getConfiguredProjectByCanonicalConfigFilePath(projectCanonicalPath);
|
||||
if (!project) return;
|
||||
|
||||
if (
|
||||
configuredProjectForConfig !== project &&
|
||||
this.getHostPreferences().includeCompletionsForModuleExports
|
||||
) {
|
||||
const path = this.toPath(configFileName);
|
||||
if (find(project.getCurrentProgram()?.getResolvedProjectReferences(), ref => ref?.sourceFile.path === path)) {
|
||||
project.markAutoImportProviderAsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
// Load root file names for configured project with the config file name
|
||||
// But only schedule update if project references this config file
|
||||
const updateLevel = configuredProjectForConfig === project ? ProgramUpdateLevel.RootNamesAndUpdate : ProgramUpdateLevel.Update;
|
||||
if (project.pendingUpdateLevel > updateLevel) return;
|
||||
|
||||
// don't trigger callback on open, existing files
|
||||
if (this.openFiles.has(fileOrDirectoryPath)) {
|
||||
const info = Debug.checkDefined(this.getScriptInfoForPath(fileOrDirectoryPath));
|
||||
if (info.isAttached(project)) {
|
||||
const loadLevelToSet = Math.max(updateLevel, project.openFileWatchTriggered.get(fileOrDirectoryPath) || ProgramUpdateLevel.Update) as ProgramUpdateLevel;
|
||||
project.openFileWatchTriggered.set(fileOrDirectoryPath, loadLevelToSet);
|
||||
}
|
||||
else {
|
||||
project.pendingUpdateLevel = updateLevel;
|
||||
this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project);
|
||||
}
|
||||
}
|
||||
else {
|
||||
project.pendingUpdateLevel = updateLevel;
|
||||
this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project);
|
||||
}
|
||||
});
|
||||
},
|
||||
fileOrDirectory =>
|
||||
this.onWildCardDirectoryWatcherInvoke(
|
||||
directory,
|
||||
configFileName,
|
||||
config,
|
||||
result,
|
||||
fileOrDirectory,
|
||||
),
|
||||
flags,
|
||||
this.getWatchOptionsFromProjectWatchOptions(config.parsedCommandLine!.watchOptions, getDirectoryPath(configFileName)),
|
||||
WatchType.WildcardDirectory,
|
||||
@@ -1949,6 +1859,89 @@ export class ProjectService {
|
||||
return result;
|
||||
}
|
||||
|
||||
private onWildCardDirectoryWatcherInvoke(
|
||||
directory: string,
|
||||
configFileName: NormalizedPath,
|
||||
config: ParsedConfig,
|
||||
wildCardWatcher: WildcardWatcher,
|
||||
fileOrDirectory: string,
|
||||
) {
|
||||
const fileOrDirectoryPath = this.toPath(fileOrDirectory);
|
||||
const fsResult = config.cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
|
||||
if (
|
||||
getBaseFileName(fileOrDirectoryPath) === "package.json" && !isInsideNodeModules(fileOrDirectoryPath) &&
|
||||
(fsResult && fsResult.fileExists || !fsResult && this.host.fileExists(fileOrDirectory))
|
||||
) {
|
||||
const file = this.getNormalizedAbsolutePath(fileOrDirectory);
|
||||
this.logger.info(`Config: ${configFileName} Detected new package.json: ${file}`);
|
||||
this.packageJsonCache.addOrUpdate(file, fileOrDirectoryPath);
|
||||
this.watchPackageJsonFile(file, fileOrDirectoryPath, wildCardWatcher);
|
||||
}
|
||||
|
||||
if (!fsResult?.fileExists) {
|
||||
// Ensure we send sourceFileChange
|
||||
this.sendSourceFileChange(fileOrDirectoryPath);
|
||||
}
|
||||
|
||||
const configuredProjectForConfig = this.findConfiguredProjectByProjectName(configFileName);
|
||||
if (
|
||||
isIgnoredFileFromWildCardWatching({
|
||||
watchedDirPath: this.toPath(directory),
|
||||
fileOrDirectory,
|
||||
fileOrDirectoryPath,
|
||||
configFileName,
|
||||
extraFileExtensions: this.hostConfiguration.extraFileExtensions,
|
||||
currentDirectory: this.currentDirectory,
|
||||
options: config.parsedCommandLine!.options,
|
||||
program: configuredProjectForConfig?.getCurrentProgram() || config.parsedCommandLine!.fileNames,
|
||||
useCaseSensitiveFileNames: this.host.useCaseSensitiveFileNames,
|
||||
writeLog: s => this.logger.info(s),
|
||||
toPath: s => this.toPath(s),
|
||||
getScriptKind: configuredProjectForConfig ? (fileName => configuredProjectForConfig.getScriptKind(fileName)) : undefined,
|
||||
})
|
||||
) return;
|
||||
|
||||
// Reload is pending, do the reload
|
||||
if (config.updateLevel !== ProgramUpdateLevel.Full) config.updateLevel = ProgramUpdateLevel.RootNamesAndUpdate;
|
||||
config.projects.forEach((watchWildcardDirectories, projectCanonicalPath) => {
|
||||
if (!watchWildcardDirectories) return;
|
||||
const project = this.getConfiguredProjectByCanonicalConfigFilePath(projectCanonicalPath);
|
||||
if (!project) return;
|
||||
|
||||
if (
|
||||
configuredProjectForConfig !== project &&
|
||||
this.getHostPreferences().includeCompletionsForModuleExports
|
||||
) {
|
||||
const path = this.toPath(configFileName);
|
||||
if (find(project.getCurrentProgram()?.getResolvedProjectReferences(), ref => ref?.sourceFile.path === path)) {
|
||||
project.markAutoImportProviderAsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
// Load root file names for configured project with the config file name
|
||||
// But only schedule update if project references this config file
|
||||
const updateLevel = configuredProjectForConfig === project ? ProgramUpdateLevel.RootNamesAndUpdate : ProgramUpdateLevel.Update;
|
||||
if (project.pendingUpdateLevel > updateLevel) return;
|
||||
|
||||
// don't trigger callback on open, existing files
|
||||
if (this.openFiles.has(fileOrDirectoryPath)) {
|
||||
const info = Debug.checkDefined(this.getScriptInfoForPath(fileOrDirectoryPath));
|
||||
if (info.isAttached(project)) {
|
||||
const loadLevelToSet = Math.max(updateLevel, project.openFileWatchTriggered.get(fileOrDirectoryPath) || ProgramUpdateLevel.Update) as ProgramUpdateLevel;
|
||||
project.openFileWatchTriggered.set(fileOrDirectoryPath, loadLevelToSet);
|
||||
}
|
||||
else {
|
||||
project.pendingUpdateLevel = updateLevel;
|
||||
this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project);
|
||||
}
|
||||
}
|
||||
else {
|
||||
project.pendingUpdateLevel = updateLevel;
|
||||
this.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(project);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalConfigFilePath: NormalizedPath, loadReason: string) {
|
||||
const configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath);
|
||||
if (!configFileExistenceInfo?.config) return false;
|
||||
@@ -2262,7 +2255,7 @@ export class ProjectService {
|
||||
const configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath);
|
||||
|
||||
let openFilesImpactedByConfigFile: Set<Path> | undefined;
|
||||
if (this.openFiles.has(info.path) && (!isAncestorConfigFileInfo(info) || info.isForDefaultProject)) {
|
||||
if (this.openFiles.has(info.path) && !isAncestorConfigFileInfo(info)) {
|
||||
// By default the info would get impacted by presence of config file since its in the detection path
|
||||
// Only adding the info as a root to inferred project will need the existence to be watched by file watcher
|
||||
if (configFileExistenceInfo) (configFileExistenceInfo.openFilesImpactedByConfigFile ??= new Set()).add(info.path);
|
||||
@@ -2455,39 +2448,31 @@ export class ProjectService {
|
||||
|
||||
// If projectRootPath doesn't contain info.path, then do normal search for config file
|
||||
const anySearchPathOk = !projectRootPath || !isSearchPathInProjectRoot();
|
||||
|
||||
let searchTsconfig = true;
|
||||
let searchJsconfig = true;
|
||||
if (isAncestorConfigFileInfo(info)) {
|
||||
// For ancestor of config file always ignore itself
|
||||
if (endsWith(info.fileName, "tsconfig.json")) searchTsconfig = false;
|
||||
else searchTsconfig = searchJsconfig = false;
|
||||
}
|
||||
// For ancestor of config file always ignore its own directory since its going to result in itself
|
||||
let searchInDirectory = !isAncestorConfigFileInfo(info);
|
||||
do {
|
||||
const canonicalSearchPath = normalizedPathToPath(searchPath, this.currentDirectory, this.toCanonicalFileName);
|
||||
if (searchTsconfig) {
|
||||
if (searchInDirectory) {
|
||||
const canonicalSearchPath = normalizedPathToPath(searchPath, this.currentDirectory, this.toCanonicalFileName);
|
||||
const tsconfigFileName = asNormalizedPath(combinePaths(searchPath, "tsconfig.json"));
|
||||
const result = action(combinePaths(canonicalSearchPath, "tsconfig.json") as NormalizedPath, tsconfigFileName);
|
||||
let result = action(combinePaths(canonicalSearchPath, "tsconfig.json") as NormalizedPath, tsconfigFileName);
|
||||
if (result) return tsconfigFileName;
|
||||
}
|
||||
|
||||
if (searchJsconfig) {
|
||||
const jsconfigFileName = asNormalizedPath(combinePaths(searchPath, "jsconfig.json"));
|
||||
const result = action(combinePaths(canonicalSearchPath, "jsconfig.json") as NormalizedPath, jsconfigFileName);
|
||||
result = action(combinePaths(canonicalSearchPath, "jsconfig.json") as NormalizedPath, jsconfigFileName);
|
||||
if (result) return jsconfigFileName;
|
||||
}
|
||||
|
||||
// If we started within node_modules, don't look outside node_modules.
|
||||
// Otherwise, we might pick up a very large project and pull in the world,
|
||||
// causing an editor delay.
|
||||
if (isNodeModulesDirectory(canonicalSearchPath)) {
|
||||
break;
|
||||
// If we started within node_modules, don't look outside node_modules.
|
||||
// Otherwise, we might pick up a very large project and pull in the world,
|
||||
// causing an editor delay.
|
||||
if (isNodeModulesDirectory(canonicalSearchPath)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const parentPath = asNormalizedPath(getDirectoryPath(searchPath));
|
||||
if (parentPath === searchPath) break;
|
||||
searchPath = parentPath;
|
||||
searchTsconfig = searchJsconfig = true;
|
||||
searchInDirectory = true;
|
||||
}
|
||||
while (anySearchPathOk || isSearchPathInProjectRoot());
|
||||
|
||||
@@ -2522,24 +2507,8 @@ export class ProjectService {
|
||||
configFileName: NormalizedPath | undefined,
|
||||
) {
|
||||
if (!this.openFiles.has(info.path)) return; // Dont cache for closed script infos
|
||||
const config = configFileName || false;
|
||||
if (!isAncestorConfigFileInfo(info)) {
|
||||
// Set value for open script info
|
||||
this.configFileForOpenFiles.set(info.path, config);
|
||||
}
|
||||
else {
|
||||
// Need to set value for ancestor in ConfigFileMapForOpenFile
|
||||
let configFileForOpenFile = this.configFileForOpenFiles.get(info.path)!;
|
||||
if (!configFileForOpenFile || isString(configFileForOpenFile)) {
|
||||
// We have value for open script info in cache, make a map with that as false key and set new vlaue
|
||||
this.configFileForOpenFiles.set(
|
||||
info.path,
|
||||
configFileForOpenFile = new Map().set(false, configFileForOpenFile),
|
||||
);
|
||||
}
|
||||
// Set value of for ancestor in the map
|
||||
configFileForOpenFile.set(info.fileName, config);
|
||||
}
|
||||
if (isAncestorConfigFileInfo(info)) return; // Dont cache for ancestors
|
||||
this.configFileForOpenFiles.set(info.path, configFileName || false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3816,6 +3785,34 @@ export class ProjectService {
|
||||
this.logger.close();
|
||||
}
|
||||
|
||||
private sendSourceFileChange(inPath: Path | undefined) {
|
||||
this.filenameToScriptInfo.forEach(info => {
|
||||
if (this.openFiles.has(info.path)) return; // Skip open files
|
||||
if (!info.fileWatcher) return; // not watched file
|
||||
const eventKind = memoize(() =>
|
||||
this.host.fileExists(info.fileName) ?
|
||||
info.deferredDelete ?
|
||||
FileWatcherEventKind.Created :
|
||||
FileWatcherEventKind.Changed :
|
||||
FileWatcherEventKind.Deleted
|
||||
);
|
||||
if (inPath) {
|
||||
// Skip node modules and files that are not in path
|
||||
if (isScriptInfoWatchedFromNodeModules(info) || !info.path.startsWith(inPath)) return;
|
||||
// If we are sending delete event and its already deleted, ignore
|
||||
if (eventKind() === FileWatcherEventKind.Deleted && info.deferredDelete) return;
|
||||
// In change cases, its hard to know if this is marked correctly across files and projects, so just send the event
|
||||
this.logger.info(`Invoking sourceFileChange on ${info.fileName}:: ${eventKind()}`);
|
||||
}
|
||||
|
||||
// Handle as if file is changed or deleted
|
||||
this.onSourceFileChanged(
|
||||
info,
|
||||
eventKind(),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This function rebuilds the project for every file opened by the client
|
||||
* This does not reload contents of open files from disk. But we could do that if needed
|
||||
@@ -3828,19 +3825,7 @@ export class ProjectService {
|
||||
// as there is no need to load contents of the files from the disk
|
||||
|
||||
// Reload script infos
|
||||
this.filenameToScriptInfo.forEach(info => {
|
||||
if (this.openFiles.has(info.path)) return; // Skip open files
|
||||
if (!info.fileWatcher) return; // not watched file
|
||||
// Handle as if file is changed or deleted
|
||||
this.onSourceFileChanged(
|
||||
info,
|
||||
this.host.fileExists(info.fileName) ?
|
||||
info.deferredDelete ?
|
||||
FileWatcherEventKind.Created :
|
||||
FileWatcherEventKind.Changed :
|
||||
FileWatcherEventKind.Deleted,
|
||||
);
|
||||
});
|
||||
this.sendSourceFileChange(/*inPath*/ undefined);
|
||||
// Cancel all project updates since we will be updating them now
|
||||
this.pendingProjectUpdates.forEach((_project, projectName) => {
|
||||
this.throttledOperations.cancel(projectName);
|
||||
@@ -4249,8 +4234,7 @@ export class ProjectService {
|
||||
function tryFindDefaultConfiguredProject(project: ConfiguredProject): ConfiguredProject | undefined {
|
||||
return isDefaultProject(project) ?
|
||||
defaultProject :
|
||||
(tryFindDefaultConfiguredProjectFromReferences(project) ??
|
||||
tryFindDefaultConfiguredProjectFromAncestor(project));
|
||||
tryFindDefaultConfiguredProjectFromReferences(project);
|
||||
}
|
||||
|
||||
function isDefaultProject(project: ConfiguredProject): ConfiguredProject | undefined {
|
||||
@@ -4280,19 +4264,6 @@ export class ProjectService {
|
||||
reloadedProjects,
|
||||
);
|
||||
}
|
||||
|
||||
function tryFindDefaultConfiguredProjectFromAncestor(project: ConfiguredProject) {
|
||||
return forEachAncestorProject( // If not in referenced projects, try ancestors and its references
|
||||
info,
|
||||
project,
|
||||
tryFindDefaultConfiguredProject,
|
||||
kind,
|
||||
`Creating possible configured project for ${info.fileName} to open`,
|
||||
allowDeferredClosed,
|
||||
reloadedProjects,
|
||||
/*searchOnlyPotentialSolution*/ false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4337,7 +4308,6 @@ export class ProjectService {
|
||||
`Creating project possibly referencing default composite project ${defaultProject.getProjectName()} of open file ${info.fileName}`,
|
||||
allowDeferredClosed,
|
||||
reloadedProjects,
|
||||
/*searchOnlyPotentialSolution*/ true,
|
||||
delayReloadedConfiguredProjects,
|
||||
);
|
||||
}
|
||||
@@ -4434,8 +4404,42 @@ export class ProjectService {
|
||||
this.removeOrphanScriptInfos();
|
||||
}
|
||||
|
||||
private tryInvokeWildCardDirectories(info: ScriptInfo) {
|
||||
// This might not have reflected in projects,
|
||||
this.configFileExistenceInfoCache.forEach((configFileExistenceInfo, config) => {
|
||||
if (
|
||||
!configFileExistenceInfo.config?.parsedCommandLine ||
|
||||
contains(
|
||||
configFileExistenceInfo.config.parsedCommandLine.fileNames,
|
||||
info.fileName,
|
||||
!this.host.useCaseSensitiveFileNames ? equateStringsCaseInsensitive : equateStringsCaseSensitive,
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
configFileExistenceInfo.config.watchedDirectories?.forEach((watcher, directory) => {
|
||||
if (containsPath(directory, info.fileName, !this.host.useCaseSensitiveFileNames)) {
|
||||
this.logger.info(`Invoking ${config}:: wildcard for open scriptInfo:: ${info.fileName}`);
|
||||
this.onWildCardDirectoryWatcherInvoke(
|
||||
directory,
|
||||
config,
|
||||
configFileExistenceInfo.config!,
|
||||
watcher.watcher,
|
||||
info.fileName,
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult {
|
||||
const existing = this.getScriptInfoForPath(normalizedPathToPath(
|
||||
fileName,
|
||||
projectRootPath ? this.getNormalizedAbsolutePath(projectRootPath) : this.currentDirectory,
|
||||
this.toCanonicalFileName,
|
||||
));
|
||||
const info = this.getOrCreateOpenScriptInfo(fileName, fileContent, scriptKind, hasMixedContent, projectRootPath);
|
||||
if (!existing && info && !info.isDynamic) this.tryInvokeWildCardDirectories(info);
|
||||
const { retainProjects, ...result } = this.assignProjectToOpenedScriptInfo(info);
|
||||
this.cleanupProjectsAndScriptInfos(
|
||||
retainProjects,
|
||||
@@ -4636,10 +4640,16 @@ export class ProjectService {
|
||||
|
||||
/** @internal */
|
||||
applyChangesInOpenFiles(openFiles: Iterable<OpenFileArguments> | undefined, changedFiles?: Iterable<ChangeFileArguments>, closedFiles?: string[]): void {
|
||||
let existingOpenScriptInfos: (ScriptInfo | undefined)[] | undefined;
|
||||
let openScriptInfos: ScriptInfo[] | undefined;
|
||||
let assignOrphanScriptInfosToInferredProject = false;
|
||||
if (openFiles) {
|
||||
for (const file of openFiles) {
|
||||
(existingOpenScriptInfos ??= []).push(this.getScriptInfoForPath(normalizedPathToPath(
|
||||
toNormalizedPath(file.fileName),
|
||||
file.projectRootPath ? this.getNormalizedAbsolutePath(file.projectRootPath) : this.currentDirectory,
|
||||
this.toCanonicalFileName,
|
||||
)));
|
||||
// Create script infos so we have the new content for all the open files before we do any updates to projects
|
||||
const info = this.getOrCreateOpenScriptInfo(
|
||||
toNormalizedPath(file.fileName),
|
||||
@@ -4670,6 +4680,13 @@ export class ProjectService {
|
||||
|
||||
// All the script infos now exist, so ok to go update projects for open files
|
||||
let retainProjects: Set<ConfiguredProject> | undefined;
|
||||
forEach(
|
||||
existingOpenScriptInfos,
|
||||
(existing, index) =>
|
||||
!existing && openScriptInfos![index] && !openScriptInfos![index].isDynamic ?
|
||||
this.tryInvokeWildCardDirectories(openScriptInfos![index]) :
|
||||
undefined,
|
||||
);
|
||||
openScriptInfos?.forEach(info => this.assignProjectToOpenedScriptInfo(info).retainProjects?.forEach(p => (retainProjects ??= new Set()).add(p)));
|
||||
|
||||
// While closing files there could be open files that needed assigning new inferred projects, do it now
|
||||
@@ -4972,7 +4989,7 @@ export class ProjectService {
|
||||
if (
|
||||
!pluginConfigEntry.name ||
|
||||
isExternalModuleNameRelative(pluginConfigEntry.name) ||
|
||||
/[\\/]\.\.?($|[\\/])/.test(pluginConfigEntry.name)
|
||||
/[\\/]\.\.?(?:$|[\\/])/.test(pluginConfigEntry.name)
|
||||
) {
|
||||
this.logger.info(`Skipped loading plugin ${pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)} because only package name is allowed plugin name`);
|
||||
return;
|
||||
|
||||
@@ -28,7 +28,7 @@ export function createModuleSpecifierCache(host: ModuleSpecifierResolutionCacheH
|
||||
return cache.get(toFileName);
|
||||
},
|
||||
set(fromFileName, toFileName, preferences, options, kind, modulePaths, moduleSpecifiers) {
|
||||
ensureCache(fromFileName, preferences, options).set(toFileName, createInfo(kind, modulePaths, moduleSpecifiers, /*isBlockedByPackageJsonDependencies*/ false));
|
||||
ensureCache(fromFileName, preferences, options).set(toFileName, createInfo(kind, modulePaths, moduleSpecifiers, /*packageName*/ undefined, /*isBlockedByPackageJsonDependencies*/ false));
|
||||
|
||||
// If any module specifiers were generated based off paths in node_modules,
|
||||
// a package.json file in that package was read and is an input to the cached.
|
||||
@@ -58,17 +58,18 @@ export function createModuleSpecifierCache(host: ModuleSpecifierResolutionCacheH
|
||||
info.modulePaths = modulePaths;
|
||||
}
|
||||
else {
|
||||
cache.set(toFileName, createInfo(/*kind*/ undefined, modulePaths, /*moduleSpecifiers*/ undefined, /*isBlockedByPackageJsonDependencies*/ undefined));
|
||||
cache.set(toFileName, createInfo(/*kind*/ undefined, modulePaths, /*moduleSpecifiers*/ undefined, /*packageName*/ undefined, /*isBlockedByPackageJsonDependencies*/ undefined));
|
||||
}
|
||||
},
|
||||
setBlockedByPackageJsonDependencies(fromFileName, toFileName, preferences, options, isBlockedByPackageJsonDependencies) {
|
||||
setBlockedByPackageJsonDependencies(fromFileName, toFileName, preferences, options, packageName, isBlockedByPackageJsonDependencies) {
|
||||
const cache = ensureCache(fromFileName, preferences, options);
|
||||
const info = cache.get(toFileName);
|
||||
if (info) {
|
||||
info.isBlockedByPackageJsonDependencies = isBlockedByPackageJsonDependencies;
|
||||
info.packageName = packageName;
|
||||
}
|
||||
else {
|
||||
cache.set(toFileName, createInfo(/*kind*/ undefined, /*modulePaths*/ undefined, /*moduleSpecifiers*/ undefined, isBlockedByPackageJsonDependencies));
|
||||
cache.set(toFileName, createInfo(/*kind*/ undefined, /*modulePaths*/ undefined, /*moduleSpecifiers*/ undefined, packageName, isBlockedByPackageJsonDependencies));
|
||||
}
|
||||
},
|
||||
clear() {
|
||||
@@ -103,8 +104,9 @@ export function createModuleSpecifierCache(host: ModuleSpecifierResolutionCacheH
|
||||
kind: ResolvedModuleSpecifierInfo["kind"] | undefined,
|
||||
modulePaths: readonly ModulePath[] | undefined,
|
||||
moduleSpecifiers: readonly string[] | undefined,
|
||||
packageName: string | undefined,
|
||||
isBlockedByPackageJsonDependencies: boolean | undefined,
|
||||
): ResolvedModuleSpecifierInfo {
|
||||
return { kind, modulePaths, moduleSpecifiers, isBlockedByPackageJsonDependencies };
|
||||
return { kind, modulePaths, moduleSpecifiers, packageName, isBlockedByPackageJsonDependencies };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -775,7 +775,8 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo
|
||||
// As an optimization, don't hit the disks for files we already know don't exist
|
||||
// (because we're watching for their creation).
|
||||
const path = this.toPath(file);
|
||||
return !this.isWatchedMissingFile(path) && this.directoryStructureHost.fileExists(file);
|
||||
return !!this.projectService.getScriptInfoForPath(path) ||
|
||||
(!this.isWatchedMissingFile(path) && this.directoryStructureHost.fileExists(file));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user