Merge remote-tracking branch 'upstream/main' into es2022

This commit is contained in:
Kagami Sascha Rosylight
2021-10-26 23:52:38 +02:00
313 changed files with 6643 additions and 1346 deletions
+33 -33
View File
@@ -325,18 +325,18 @@
}
},
"@octokit/openapi-types": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-11.1.0.tgz",
"integrity": "sha512-dWZfYvCCdjZzDYA3lIAMF72Q0jld8xidqCq5Ryw09eBJXZdcM6he0vWBTvw/b5UnGYqexxOyHWgfrsTlUJL3Gw==",
"version": "11.2.0",
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-11.2.0.tgz",
"integrity": "sha512-PBsVO+15KSlGmiI8QAzaqvsNlZlrDlyAJYcrXBCvVUxCp7VnXjkwPoFHgjEJXx3WF9BAwkA6nfCUA7i9sODzKA==",
"dev": true
},
"@octokit/plugin-paginate-rest": {
"version": "2.16.9",
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.16.9.tgz",
"integrity": "sha512-gfSCMgz5scFKsR0dW4jaYsDJVt/UwCHp4dF7sHlmSekZvwzvLiOAGZ4MQkEsL5DW9hIk2W+UQkYZMTA1b6Wsqw==",
"version": "2.17.0",
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.17.0.tgz",
"integrity": "sha512-tzMbrbnam2Mt4AhuyCHvpRkS0oZ5MvwwcQPYGtMv4tUa5kkzG58SVB0fcsLulOZQeRnOgdkZWkRUiyBlh0Bkyw==",
"dev": true,
"requires": {
"@octokit/types": "^6.33.0"
"@octokit/types": "^6.34.0"
}
},
"@octokit/plugin-request-log": {
@@ -346,12 +346,12 @@
"dev": true
},
"@octokit/plugin-rest-endpoint-methods": {
"version": "5.12.1",
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.12.1.tgz",
"integrity": "sha512-0nY3htfl6x9UkPcqv8pm9vOC/bTA7f4IMDWln13neHRdNWQvOQgZ9fRxK7BAc74rye4yVINEFi9Yb9rnGUvosA==",
"version": "5.13.0",
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.13.0.tgz",
"integrity": "sha512-uJjMTkN1KaOIgNtUPMtIXDOjx6dGYysdIFhgA52x4xSadQCz3b/zJexvITDVpANnfKPW/+E0xkOvLntqMYpviA==",
"dev": true,
"requires": {
"@octokit/types": "^6.33.0",
"@octokit/types": "^6.34.0",
"deprecation": "^2.3.1"
}
},
@@ -393,12 +393,12 @@
}
},
"@octokit/types": {
"version": "6.33.0",
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.33.0.tgz",
"integrity": "sha512-0zffZ048M0UhthyPXQHLz4038Ak46nMWZXkzlXvXB/M/L1jYPBceq4iZj4qjKVrvveaJrrgKdJ9+3yUuITfcCw==",
"version": "6.34.0",
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.34.0.tgz",
"integrity": "sha512-s1zLBjWhdEI2zwaoSgyOFoKSl109CUcVBCc7biPJ3aAf6LGLU6szDvi31JPU7bxfla2lqfhjbbg/5DdFNxOwHw==",
"dev": true,
"requires": {
"@octokit/openapi-types": "^11.1.0"
"@octokit/openapi-types": "^11.2.0"
}
},
"@types/browserify": {
@@ -430,9 +430,9 @@
"dev": true
},
"@types/glob": {
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.4.tgz",
"integrity": "sha512-w+LsMxKyYQm347Otw+IfBXOv9UWVjpHpCDdbBMt8Kz/xbvCYNjP+0qPh91Km3iKfSRLBB0P7fAMf0KHrPu+MyA==",
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz",
"integrity": "sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==",
"dev": true,
"requires": {
"@types/minimatch": "*",
@@ -676,9 +676,9 @@
"dev": true
},
"@types/node": {
"version": "16.10.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.10.3.tgz",
"integrity": "sha512-ho3Ruq+fFnBrZhUYI46n/bV2GjwzSkwuT4dTf0GkuNFmnb8nq4ny2z9JEVemFi6bdEJanHLlYfy9c6FN9B9McQ==",
"version": "16.11.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.6.tgz",
"integrity": "sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==",
"dev": true
},
"@types/node-fetch": {
@@ -1658,9 +1658,9 @@
}
},
"is-core-module": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.7.0.tgz",
"integrity": "sha512-ByY+tjCciCr+9nLryBYcSD50EOGWt95c7tIsKTG1J2ixKKXPvF7Ej3AVd+UfDydAJom3biBGDBALaO79ktwgEQ==",
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.0.tgz",
"integrity": "sha512-vd15qHsaqrRL7dtH6QNuy0ndJmRDrS9HAM1CAiSifNUFv4x1a0CCVsj18hJ1mShxIG6T2i1sO78MkP56r0nYRw==",
"dev": true,
"requires": {
"has": "^1.0.3"
@@ -5339,9 +5339,9 @@
"dev": true
},
"mocha": {
"version": "9.1.2",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.2.tgz",
"integrity": "sha512-ta3LtJ+63RIBP03VBjMGtSqbe6cWXRejF9SyM9Zyli1CKZJZ+vfCTj3oW24V7wAphMJdpOFLoMI3hjJ1LWbs0w==",
"version": "9.1.3",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-9.1.3.tgz",
"integrity": "sha512-Xcpl9FqXOAYqI3j79pEtHBBnQgVXIhpULjGQa7DVb0Po+VzmSIK9kanAiWLHoRR/dbZ2qpdPshuXr8l1VaHCzw==",
"dev": true,
"requires": {
"@ungap/promise-all-settled": "1.1.2",
@@ -5730,9 +5730,9 @@
}
},
"is-core-module": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.7.0.tgz",
"integrity": "sha512-ByY+tjCciCr+9nLryBYcSD50EOGWt95c7tIsKTG1J2ixKKXPvF7Ej3AVd+UfDydAJom3biBGDBALaO79ktwgEQ==",
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.0.tgz",
"integrity": "sha512-vd15qHsaqrRL7dtH6QNuy0ndJmRDrS9HAM1CAiSifNUFv4x1a0CCVsj18hJ1mShxIG6T2i1sO78MkP56r0nYRw==",
"dev": true,
"requires": {
"has": "^1.0.3"
@@ -6797,9 +6797,9 @@
}
},
"shell-quote": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.2.tgz",
"integrity": "sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==",
"version": "1.7.3",
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz",
"integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==",
"dev": true
},
"side-channel": {
+21
View File
@@ -0,0 +1,21 @@
const { join, resolve, dirname } = require("path");
const { existsSync } = require("fs");
// search directories upward to avoid hard-wired paths based on the
// build tree (same as src/harness/findUpDir.ts)
function findUpFile(name) {
let dir = __dirname;
while (true) {
const fullPath = join(dir, name);
if (existsSync(fullPath)) return fullPath;
const up = resolve(dir, "..");
if (up === dir) return name; // it'll fail anyway
dir = up;
}
}
exports.findUpFile = findUpFile;
const findUpRoot = () =>
findUpRoot.cached || (findUpRoot.cached = dirname(findUpFile("Gulpfile.js")));
exports.findUpRoot = findUpRoot;
+11 -3
View File
@@ -1,5 +1,7 @@
// @ts-check
const { exec, Debouncer } = require("./utils");
const { resolve } = require("path");
const { findUpRoot } = require("./findUpDir");
class ProjectQueue {
/**
@@ -33,7 +35,13 @@ class ProjectQueue {
}
}
const projectBuilder = new ProjectQueue((projects, lkg, force) => exec(process.execPath, [lkg ? "./lib/tsc" : "./built/local/tsc", "-b", ...(force ? ["--force"] : []), ...projects], { hidePrompt: true }));
const execTsc = (lkg, ...args) =>
exec(process.execPath,
[resolve(findUpRoot(), lkg ? "./lib/tsc" : "./built/local/tsc"),
"-b", ...args],
{ hidePrompt: true })
const projectBuilder = new ProjectQueue((projects, lkg, force) => execTsc(lkg, ...(force ? ["--force"] : []), ...projects));
/**
* @param {string} project
@@ -43,14 +51,14 @@ const projectBuilder = new ProjectQueue((projects, lkg, force) => exec(process.e
*/
exports.buildProject = (project, { lkg, force } = {}) => projectBuilder.enqueue(project, { lkg, force });
const projectCleaner = new ProjectQueue((projects, lkg) => exec(process.execPath, [lkg ? "./lib/tsc" : "./built/local/tsc", "-b", "--clean", ...projects], { hidePrompt: true }));
const projectCleaner = new ProjectQueue((projects, lkg) => execTsc(lkg, "--clean", ...projects));
/**
* @param {string} project
*/
exports.cleanProject = (project) => projectCleaner.enqueue(project);
const projectWatcher = new ProjectQueue((projects) => exec(process.execPath, ["./lib/tsc", "-b", "--watch", ...projects], { hidePrompt: true }));
const projectWatcher = new ProjectQueue((projects) => execTsc(true, "--watch", ...projects));
/**
* @param {string} project
+3 -2
View File
@@ -9,6 +9,7 @@ const log = require("fancy-log");
const cmdLineOptions = require("./options");
const { CancellationToken } = require("prex");
const { exec } = require("./utils");
const { findUpFile } = require("./findUpDir");
const mochaJs = require.resolve("mocha/bin/_mocha");
exports.localBaseline = "tests/baselines/local/";
@@ -73,11 +74,11 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode,
/** @type {string[]} */
let args = [];
// timeout normally isn"t necessary but Travis-CI has been timing out on compiler baselines occasionally
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
if (!runInParallel) {
args.push(mochaJs);
args.push("-R", "scripts/failed-tests");
args.push("-R", findUpFile("scripts/failed-tests.js"));
args.push("-O", '"reporter=' + reporter + (keepFailed ? ",keepFailed=true" : "") + '"');
if (tests) {
args.push("-g", `"${tests}"`);
+3 -15
View File
@@ -9,12 +9,11 @@ const del = require("del");
const File = require("vinyl");
const ts = require("../../lib/typescript");
const chalk = require("chalk");
const which = require("which");
const { spawn } = require("child_process");
const { CancellationToken, CancelError, Deferred } = require("prex");
const { Readable, Duplex } = require("stream");
const isWindows = /^win/.test(process.platform);
/**
* Executes the provided command once with the supplied arguments.
* @param {string} cmd
@@ -32,12 +31,8 @@ function exec(cmd, args, options = {}) {
const { ignoreExitCode, cancelToken = CancellationToken.none, waitForExit = true } = options;
cancelToken.throwIfCancellationRequested();
// TODO (weswig): Update child_process types to add windowsVerbatimArguments to the type definition
const subshellFlag = isWindows ? "/c" : "-c";
const command = isWindows ? [possiblyQuote(cmd), ...args] : [`${cmd} ${args.join(" ")}`];
if (!options.hidePrompt) log(`> ${chalk.green(cmd)} ${args.join(" ")}`);
const proc = spawn(isWindows ? "cmd" : "/bin/sh", [subshellFlag, ...command], { stdio: waitForExit ? "inherit" : "ignore", windowsVerbatimArguments: true });
const proc = spawn(which.sync(cmd), args, { stdio: waitForExit ? "inherit" : "ignore" });
const registration = cancelToken.register(() => {
log(`${chalk.red("killing")} '${chalk.green(cmd)} ${args.join(" ")}'...`);
proc.kill("SIGINT");
@@ -68,13 +63,6 @@ function exec(cmd, args, options = {}) {
}
exports.exec = exec;
/**
* @param {string} cmd
*/
function possiblyQuote(cmd) {
return cmd.indexOf(" ") >= 0 ? `"${cmd}"` : cmd;
}
/**
* @param {ts.Diagnostic[]} diagnostics
* @param {{ cwd?: string, pretty?: boolean }} [options]
@@ -440,4 +428,4 @@ class Debouncer {
}
}
}
exports.Debouncer = Debouncer;
exports.Debouncer = Debouncer;
+1
View File
@@ -2947,6 +2947,7 @@ namespace ts {
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.ClassStaticBlockDeclaration:
// this.foo assignment in a JavaScript class
// Bind this property to the containing class
const containingClass = thisContainer.parent;
+165 -122
View File
@@ -3275,21 +3275,40 @@ namespace ts {
const namespaceName = getFullyQualifiedName(namespace);
const declarationName = declarationNameToString(right);
const suggestionForNonexistentModule = getSuggestedSymbolForNonexistentModule(right, namespace);
const exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, SymbolFlags.Type));
const containingQualifiedName = isQualifiedName(name) && getContainingQualifiedNameNode(name);
const canSuggestTypeof = containingQualifiedName && !isTypeOfExpression(containingQualifiedName.parent) && tryGetQualifiedNameAsValue(containingQualifiedName);
if (suggestionForNonexistentModule) {
error(right, Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, namespaceName, declarationName, symbolToString(suggestionForNonexistentModule));
return undefined;
}
else if (canSuggestTypeof) {
error(containingQualifiedName, Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, entityNameToString(containingQualifiedName));
const containingQualifiedName = isQualifiedName(name) && getContainingQualifiedNameNode(name);
const canSuggestTypeof = globalObjectType // <-- can't pull on types if global types aren't initialized yet
&& (meaning & SymbolFlags.Type)
&& containingQualifiedName
&& !isTypeOfExpression(containingQualifiedName.parent)
&& tryGetQualifiedNameAsValue(containingQualifiedName);
if (canSuggestTypeof) {
error(
containingQualifiedName,
Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0,
entityNameToString(containingQualifiedName)
);
return undefined;
}
else if (meaning & SymbolFlags.Namespace && exportedTypeSymbol && isQualifiedName(name.parent)) {
error(name.parent.right, Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, symbolToString(exportedTypeSymbol), unescapeLeadingUnderscores(name.parent.right.escapedText));
}
else {
error(right, Diagnostics.Namespace_0_has_no_exported_member_1, namespaceName, declarationName);
if (meaning & SymbolFlags.Namespace && isQualifiedName(name.parent)) {
const exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, SymbolFlags.Type));
if (exportedTypeSymbol) {
error(
name.parent.right,
Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1,
symbolToString(exportedTypeSymbol),
unescapeLeadingUnderscores(name.parent.right.escapedText)
);
return undefined;
}
}
error(right, Diagnostics.Namespace_0_has_no_exported_member_1, namespaceName, declarationName);
}
return undefined;
}
@@ -3416,7 +3435,8 @@ namespace ts {
findAncestor(location, isExportDeclaration)?.moduleSpecifier ||
(isModuleDeclaration(location) ? location : location.parent && isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : undefined)?.name ||
(isLiteralImportTypeNode(location) ? location : undefined)?.argument.literal;
const resolvedModule = getResolvedModule(currentSourceFile, moduleReference, contextSpecifier && isStringLiteralLike(contextSpecifier) ? getModeForUsageLocation(currentSourceFile, contextSpecifier) : undefined)!; // TODO: GH#18217
const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
const resolvedModule = getResolvedModule(currentSourceFile, moduleReference, mode)!; // TODO: GH#18217
const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule);
const sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
if (sourceFile) {
@@ -3655,8 +3675,8 @@ namespace ts {
if (exportEquals !== moduleSymbol) {
const type = getTypeOfSymbol(exportEquals);
if (shouldTreatPropertiesOfExternalModuleAsExports(type)) {
getPropertiesOfType(type).forEach(symbol => {
cb(symbol, symbol.escapedName);
forEachPropertyOfType(type, (symbol, escapedName) => {
cb(symbol, escapedName);
});
}
}
@@ -4032,13 +4052,17 @@ namespace ts {
function getNamedMembers(members: SymbolTable): Symbol[] {
let result: Symbol[] | undefined;
members.forEach((symbol, id) => {
if (!isReservedMemberName(id) && symbolIsValue(symbol)) {
if (isNamedMember(symbol, id)) {
(result || (result = [])).push(symbol);
}
});
return result || emptyArray;
}
function isNamedMember(member: Symbol, escapedName: __String) {
return !isReservedMemberName(escapedName) && symbolIsValue(member);
}
function getNamedOrIndexSignatureMembers(members: SymbolTable): Symbol[] {
const result = getNamedMembers(members);
const index = getIndexSymbolFromSymbolTable(members);
@@ -4972,7 +4996,7 @@ namespace ts {
const typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode);
const nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type)!, context) : undefined;
const templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & MappedTypeModifiers.IncludeOptional)), context);
const mappedTypeNode = factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode);
const mappedTypeNode = factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined);
context.approximateLength += 10;
return setEmitFlags(mappedTypeNode, EmitFlags.SingleLine);
}
@@ -11570,6 +11594,17 @@ namespace ts {
getPropertiesOfObjectType(type);
}
function forEachPropertyOfType(type: Type, action: (symbol: Symbol, escapedName: __String) => void): void {
type = getReducedApparentType(type);
if (type.flags & TypeFlags.StructuredType) {
resolveStructuredTypeMembers(type as StructuredType).members.forEach((symbol, escapedName) => {
if (isNamedMember(symbol, escapedName)) {
action(symbol, escapedName);
}
});
}
}
function isTypeInvalidDueToUnionDiscriminant(contextualType: Type, obj: ObjectLiteralExpression | JsxAttributes): boolean {
const list = obj.properties as NodeArray<ObjectLiteralElementLike | JsxAttributeLike>;
return list.some(property => {
@@ -12580,7 +12615,7 @@ namespace ts {
if (!node) return false;
switch (node.kind) {
case SyntaxKind.Identifier:
return (node as Identifier).escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node as Identifier) === argumentsSymbol;
return (node as Identifier).escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node as Identifier) === argumentsSymbol;
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.MethodDeclaration:
@@ -14168,13 +14203,13 @@ namespace ts {
}
function removeStringLiteralsMatchedByTemplateLiterals(types: Type[]) {
const templates = filter(types, isPatternLiteralType);
const templates = filter(types, isPatternLiteralType) as TemplateLiteralType[];
if (templates.length) {
let i = types.length;
while (i > 0) {
i--;
const t = types[i];
if (t.flags & TypeFlags.StringLiteral && some(templates, template => isTypeSubtypeOf(t, template))) {
if (t.flags & TypeFlags.StringLiteral && some(templates, template => isTypeMatchedByTemplateLiteralType(t, template))) {
orderedRemoveItemAt(types, i);
}
}
@@ -15314,13 +15349,6 @@ namespace ts {
return type[cache] = type;
}
function isConditionalTypeAlwaysTrueDisregardingInferTypes(type: ConditionalType) {
const extendsInferParamMapper = type.root.inferTypeParameters && createTypeMapper(type.root.inferTypeParameters, map(type.root.inferTypeParameters, () => wildcardType));
const checkType = type.checkType;
const extendsType = type.extendsType;
return isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(instantiateType(extendsType, extendsInferParamMapper)));
}
function getSimplifiedConditionalType(type: ConditionalType, writing: boolean) {
const checkType = type.checkType;
const extendsType = type.extendsType;
@@ -15644,6 +15672,12 @@ namespace ts {
return result;
}
function isDistributionDependent(root: ConditionalRoot) {
return root.isDistributive && (
isTypeParameterPossiblyReferenced(root.checkType as TypeParameter, root.node.trueType) ||
isTypeParameterPossiblyReferenced(root.checkType as TypeParameter, root.node.falseType));
}
function getTypeFromConditionalTypeNode(node: ConditionalTypeNode): Type {
const links = getNodeLinks(node);
if (!links.resolvedType) {
@@ -18192,13 +18226,12 @@ namespace ts {
let result = Ternary.False;
const saveErrorInfo = captureErrorCalculationState();
// Note that these checks are specifically ordered to produce correct results. In particular,
// we need to deconstruct unions before intersections (because unions are always at the top),
// and we need to handle "each" relations before "some" relations for the same kind of type.
if (source.flags & TypeFlags.UnionOrIntersection || target.flags & TypeFlags.UnionOrIntersection) {
result = getConstituentCount(source) * getConstituentCount(target) >= 4 ?
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | IntersectionState.UnionIntersectionCheck, recursionFlags) :
structuredTypeRelatedTo(source, target, reportErrors, intersectionState | IntersectionState.UnionIntersectionCheck);
if ((source.flags & TypeFlags.Union || target.flags & TypeFlags.Union) && getConstituentCount(source) * getConstituentCount(target) < 4) {
// We skip caching when source or target is a union with no more than three constituents.
result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState | IntersectionState.UnionIntersectionCheck);
}
else if (source.flags & TypeFlags.UnionOrIntersection || target.flags & TypeFlags.UnionOrIntersection) {
result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | IntersectionState.UnionIntersectionCheck, recursionFlags);
}
if (!result && !(source.flags & TypeFlags.Union) && (source.flags & (TypeFlags.StructuredOrInstantiable) || target.flags & TypeFlags.StructuredOrInstantiable)) {
if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags)) {
@@ -18662,17 +18695,17 @@ namespace ts {
const maybeStart = maybeCount;
maybeKeys[maybeCount] = id;
maybeCount++;
const saveExpandingFlags = expandingFlags;
if (recursionFlags & RecursionFlags.Source) {
sourceStack[sourceDepth] = source;
sourceDepth++;
if (!(expandingFlags & ExpandingFlags.Source) && isDeeplyNestedType(source, sourceStack, sourceDepth)) expandingFlags |= ExpandingFlags.Source;
}
if (recursionFlags & RecursionFlags.Target) {
targetStack[targetDepth] = target;
targetDepth++;
if (!(expandingFlags & ExpandingFlags.Target) && isDeeplyNestedType(target, targetStack, targetDepth)) expandingFlags |= ExpandingFlags.Target;
}
const saveExpandingFlags = expandingFlags;
if (!(expandingFlags & ExpandingFlags.Source) && isDeeplyNestedType(source, sourceStack, sourceDepth)) expandingFlags |= ExpandingFlags.Source;
if (!(expandingFlags & ExpandingFlags.Target) && isDeeplyNestedType(target, targetStack, targetDepth)) expandingFlags |= ExpandingFlags.Target;
let originalHandler: typeof outofbandVarianceMarkerHandler;
let propagatingVarianceFlags: RelationComparisonResult = 0;
if (outofbandVarianceMarkerHandler) {
@@ -18698,13 +18731,13 @@ namespace ts {
if (outofbandVarianceMarkerHandler) {
outofbandVarianceMarkerHandler = originalHandler;
}
expandingFlags = saveExpandingFlags;
if (recursionFlags & RecursionFlags.Source) {
sourceDepth--;
}
if (recursionFlags & RecursionFlags.Target) {
targetDepth--;
}
expandingFlags = saveExpandingFlags;
if (result) {
if (result === Ternary.True || (sourceDepth === 0 && targetDepth === 0)) {
if (result === Ternary.True || result === Ternary.Maybe) {
@@ -19023,34 +19056,28 @@ namespace ts {
}
}
else if (target.flags & TypeFlags.Conditional) {
const c = target as ConditionalType;
// Check if the conditional is always true or always false but still deferred for distribution purposes
const skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
const skipFalse = !skipTrue && isConditionalTypeAlwaysTrueDisregardingInferTypes(c);
// Instantiate with a replacement mapper if the conditional is distributive, replacing the check type with a clone of itself,
// this way {x: string | number, y: string | number} -> (T extends T ? { x: T, y: T } : never) appropriately _fails_ when
// T = string | number (since that will end up distributing and producing `{x: string, y: string} | {x: number, y: number}`,
// to which `{x: string | number, y: string | number}` isn't assignable)
let distributionMapper: TypeMapper | undefined;
const checkVar = getActualTypeVariable(c.root.checkType);
if (c.root.isDistributive && checkVar.flags & TypeFlags.TypeParameter) {
const newParam = cloneTypeParameter(checkVar);
distributionMapper = prependTypeMapping(checkVar, newParam, c.mapper);
newParam.mapper = distributionMapper;
}
// TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't)
const expanding = isDeeplyNestedType(target, targetStack, targetDepth);
let localResult: Ternary | undefined = expanding ? Ternary.Maybe : undefined;
if (skipTrue || expanding || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.trueType), distributionMapper) : getTrueTypeFromConditionalType(c), RecursionFlags.Target, /*reportErrors*/ false))) {
if (!skipFalse && !expanding) {
localResult = (localResult || Ternary.Maybe) & isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.falseType), distributionMapper) : getFalseTypeFromConditionalType(c), RecursionFlags.Target, /*reportErrors*/ false);
}
}
if (localResult) {
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
// conditional type and bail out with a Ternary.Maybe result.
if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) {
resetErrorInfo(saveErrorInfo);
return localResult;
return Ternary.Maybe;
}
const c = target as ConditionalType;
// We check for a relationship to a conditional type target only when the conditional type has no
// 'infer' positions and is not distributive or is distributive but doesn't reference the check type
// parameter in either of the result types.
if (!c.root.inferTypeParameters && !isDistributionDependent(c.root)) {
// Check if the conditional is always true or always false but still deferred for distribution purposes.
const skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
const skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType));
// TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't)
if (result = skipTrue ? Ternary.True : isRelatedTo(source, getTrueTypeFromConditionalType(c), RecursionFlags.Target, /*reportErrors*/ false)) {
result &= skipFalse ? Ternary.True : isRelatedTo(source, getFalseTypeFromConditionalType(c), RecursionFlags.Target, /*reportErrors*/ false);
if (result) {
resetErrorInfo(saveErrorInfo);
return result;
}
}
}
}
else if (target.flags & TypeFlags.TemplateLiteral) {
@@ -19062,8 +19089,7 @@ namespace ts {
// For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string.
instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
}
const result = inferTypesFromTemplateLiteralType(source, target as TemplateLiteralType);
if (result && every(result, (r, i) => isValidTypeForTemplateLiteralPlaceholder(r, (target as TemplateLiteralType).types[i]))) {
if (isTypeMatchedByTemplateLiteralType(source, target as TemplateLiteralType)) {
return Ternary.True;
}
}
@@ -19122,33 +19148,34 @@ namespace ts {
}
}
else if (source.flags & TypeFlags.Conditional) {
// If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive
// conditional type and bail out with a Ternary.Maybe result.
if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) {
resetErrorInfo(saveErrorInfo);
return Ternary.Maybe;
}
if (target.flags & TypeFlags.Conditional) {
// If one of the conditionals under comparison seems to be infinitely expanding, stop comparing it - back out, try
// the constraint, and failing that, give up trying to relate the two. This is the only way we can handle recursive conditional
// types, which might expand forever.
if (!isDeeplyNestedType(source, sourceStack, sourceDepth) && !isDeeplyNestedType(target, targetStack, targetDepth)) {
// Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
// one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
// and Y1 is related to Y2.
const sourceParams = (source as ConditionalType).root.inferTypeParameters;
let sourceExtends = (source as ConditionalType).extendsType;
let mapper: TypeMapper | undefined;
if (sourceParams) {
// If the source has infer type parameters, we instantiate them in the context of the target
const ctx = createInferenceContext(sourceParams, /*signature*/ undefined, InferenceFlags.None, isRelatedToWorker);
inferTypes(ctx.inferences, (target as ConditionalType).extendsType, sourceExtends, InferencePriority.NoConstraints | InferencePriority.AlwaysStrict);
sourceExtends = instantiateType(sourceExtends, ctx.mapper);
mapper = ctx.mapper;
// Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if
// one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2,
// and Y1 is related to Y2.
const sourceParams = (source as ConditionalType).root.inferTypeParameters;
let sourceExtends = (source as ConditionalType).extendsType;
let mapper: TypeMapper | undefined;
if (sourceParams) {
// If the source has infer type parameters, we instantiate them in the context of the target
const ctx = createInferenceContext(sourceParams, /*signature*/ undefined, InferenceFlags.None, isRelatedToWorker);
inferTypes(ctx.inferences, (target as ConditionalType).extendsType, sourceExtends, InferencePriority.NoConstraints | InferencePriority.AlwaysStrict);
sourceExtends = instantiateType(sourceExtends, ctx.mapper);
mapper = ctx.mapper;
}
if (isTypeIdenticalTo(sourceExtends, (target as ConditionalType).extendsType) &&
(isRelatedTo((source as ConditionalType).checkType, (target as ConditionalType).checkType, RecursionFlags.Both) || isRelatedTo((target as ConditionalType).checkType, (source as ConditionalType).checkType, RecursionFlags.Both))) {
if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source as ConditionalType), mapper), getTrueTypeFromConditionalType(target as ConditionalType), RecursionFlags.Both, reportErrors)) {
result &= isRelatedTo(getFalseTypeFromConditionalType(source as ConditionalType), getFalseTypeFromConditionalType(target as ConditionalType), RecursionFlags.Both, reportErrors);
}
if (isTypeIdenticalTo(sourceExtends, (target as ConditionalType).extendsType) &&
(isRelatedTo((source as ConditionalType).checkType, (target as ConditionalType).checkType, RecursionFlags.Both) || isRelatedTo((target as ConditionalType).checkType, (source as ConditionalType).checkType, RecursionFlags.Both))) {
if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source as ConditionalType), mapper), getTrueTypeFromConditionalType(target as ConditionalType), RecursionFlags.Both, reportErrors)) {
result &= isRelatedTo(getFalseTypeFromConditionalType(source as ConditionalType), getFalseTypeFromConditionalType(target as ConditionalType), RecursionFlags.Both, reportErrors);
}
if (result) {
resetErrorInfo(saveErrorInfo);
return result;
}
if (result) {
resetErrorInfo(saveErrorInfo);
return result;
}
}
}
@@ -19164,18 +19191,13 @@ namespace ts {
}
}
// We'll repeatedly decompose source side conditionals if they're recursive - check if we've already recured on the constraint a lot and, if so, bail
// on the comparison.
if (!isDeeplyNestedType(source, sourceStack, sourceDepth)) {
// conditionals _can_ be related to one another via normal constraint, as, eg, `A extends B ? O : never` should be assignable to `O`
// when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!).
const defaultConstraint = getDefaultConstraintOfConditionalType(source as ConditionalType);
if (defaultConstraint) {
if (result = isRelatedTo(defaultConstraint, target, RecursionFlags.Source, reportErrors)) {
resetErrorInfo(saveErrorInfo);
return result;
}
// conditionals _can_ be related to one another via normal constraint, as, eg, `A extends B ? O : never` should be assignable to `O`
// when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!).
const defaultConstraint = getDefaultConstraintOfConditionalType(source as ConditionalType);
if (defaultConstraint) {
if (result = isRelatedTo(defaultConstraint, target, RecursionFlags.Source, reportErrors)) {
resetErrorInfo(saveErrorInfo);
return result;
}
}
}
@@ -20321,14 +20343,14 @@ namespace ts {
// `type A<T> = null extends T ? [A<NonNullable<T>>] : [T]`
// has expanded into `[A<NonNullable<NonNullable<NonNullable<NonNullable<NonNullable<T>>>>>>]`
// in such cases we need to terminate the expansion, and we do so here.
function isDeeplyNestedType(type: Type, stack: Type[], depth: number): boolean {
if (depth >= 5) {
function isDeeplyNestedType(type: Type, stack: Type[], depth: number, maxDepth = 5): boolean {
if (depth >= maxDepth) {
const identity = getRecursionIdentity(type);
let count = 0;
for (let i = 0; i < depth; i++) {
if (getRecursionIdentity(stack[i]) === identity) {
count++;
if (count >= 5) {
if (count >= maxDepth) {
return true;
}
}
@@ -21537,6 +21559,11 @@ namespace ts {
undefined;
}
function isTypeMatchedByTemplateLiteralType(source: Type, target: TemplateLiteralType): boolean {
const inferences = inferTypesFromTemplateLiteralType(source, target);
return !!inferences && every(inferences, (r, i) => isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]));
}
function getStringLikeTypeForType(type: Type) {
return type.flags & (TypeFlags.Any | TypeFlags.StringLike) ? type : getTemplateLiteralType(["", ""], [type]);
}
@@ -22326,12 +22353,11 @@ namespace ts {
if (signature) {
const inferredCovariantType = inference.candidates ? getCovariantInference(inference, signature) : undefined;
if (inference.contraCandidates) {
const inferredContravariantType = getContravariantInference(inference);
// If we have both co- and contra-variant inferences, we prefer the contra-variant inference
// unless the co-variant inference is a subtype and not 'never'.
// unless the co-variant inference is a subtype of some contra-variant inference and not 'never'.
inferredType = inferredCovariantType && !(inferredCovariantType.flags & TypeFlags.Never) &&
isTypeSubtypeOf(inferredCovariantType, inferredContravariantType) ?
inferredCovariantType : inferredContravariantType;
some(inference.contraCandidates, t => isTypeSubtypeOf(inferredCovariantType, t)) ?
inferredCovariantType : getContravariantInference(inference);
}
else if (inferredCovariantType) {
inferredType = inferredCovariantType;
@@ -22652,8 +22678,9 @@ namespace ts {
// constituent types keyed by the literal types of the property by that name in each constituent type.
function getKeyPropertyName(unionType: UnionType): __String | undefined {
const types = unionType.types;
// We only construct maps for large unions with non-primitive constituents.
if (types.length < 10 || getObjectFlags(unionType) & ObjectFlags.PrimitiveUnion) {
// We only construct maps for unions with many non-primitive constituents.
if (types.length < 10 || getObjectFlags(unionType) & ObjectFlags.PrimitiveUnion ||
countWhere(types, t => !!(t.flags & (TypeFlags.Object | TypeFlags.InstantiableNonPrimitive))) < 10) {
return undefined;
}
if (unionType.keyPropertyName === undefined) {
@@ -22687,7 +22714,7 @@ namespace ts {
const keyPropertyName = getKeyPropertyName(unionType);
const propNode = keyPropertyName && find(node.properties, p => p.symbol && p.kind === SyntaxKind.PropertyAssignment &&
p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer));
const propType = propNode && getTypeOfExpression((propNode as PropertyAssignment).initializer);
const propType = propNode && getContextFreeTypeOfExpression((propNode as PropertyAssignment).initializer);
return propType && getConstituentTypeForKeyType(unionType, propType);
}
@@ -23145,7 +23172,7 @@ namespace ts {
}
function getConstituentCount(type: Type) {
return type.flags & TypeFlags.UnionOrIntersection ? (type as UnionOrIntersectionType).types.length : 1;
return type.flags & TypeFlags.Union ? (type as UnionType).types.length : 1;
}
function extractTypesOfKind(type: Type, kind: TypeFlags) {
@@ -24731,7 +24758,7 @@ namespace ts {
return parent.kind === SyntaxKind.PropertyAccessExpression ||
parent.kind === SyntaxKind.CallExpression && (parent as CallExpression).expression === node ||
parent.kind === SyntaxKind.ElementAccessExpression && (parent as ElementAccessExpression).expression === node &&
!(isGenericTypeWithoutNullableConstraint(type) && isGenericIndexType(getTypeOfExpression((parent as ElementAccessExpression).argumentExpression)));
!(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression((parent as ElementAccessExpression).argumentExpression)));
}
function isGenericTypeWithUnionConstraint(type: Type) {
@@ -26194,7 +26221,7 @@ namespace ts {
concatenate(
map(
filter(node.properties, p => !!p.symbol && p.kind === SyntaxKind.JsxAttribute && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer))),
prop => ([!(prop as JsxAttribute).initializer ? (() => trueType) : (() => checkExpression((prop as JsxAttribute).initializer!)), prop.symbol.escapedName] as [() => Type, __String])
prop => ([!(prop as JsxAttribute).initializer ? (() => trueType) : (() => getContextFreeTypeOfExpression((prop as JsxAttribute).initializer!)), prop.symbol.escapedName] as [() => Type, __String])
),
map(
filter(getPropertiesOfType(contextualType), s => !!(s.flags & SymbolFlags.Optional) && !!node?.symbol?.members && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName)),
@@ -26807,6 +26834,10 @@ namespace ts {
function checkComputedPropertyName(node: ComputedPropertyName): Type {
const links = getNodeLinks(node.expression);
if (!links.resolvedType) {
if ((isTypeLiteralNode(node.parent.parent) || isClassLike(node.parent.parent) || isInterfaceDeclaration(node.parent.parent))
&& isBinaryExpression(node.expression) && node.expression.operatorToken.kind === SyntaxKind.InKeyword) {
return links.resolvedType = errorType;
}
links.resolvedType = checkExpression(node.expression);
// The computed property name of a non-static class field within a loop must be stored in a block-scoped binding.
// (It needs to be bound at class evaluation time.)
@@ -34632,7 +34663,7 @@ namespace ts {
forEach(node.members, checkSourceElement);
if (produceDiagnostics) {
const type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
checkIndexConstraints(type);
checkIndexConstraints(type, type.symbol);
checkTypeForDuplicateIndexSignatures(node);
checkObjectTypeForDuplicateDeclarations(node);
}
@@ -34732,6 +34763,7 @@ namespace ts {
}
function checkMappedType(node: MappedTypeNode) {
checkGrammarMappedType(node);
checkSourceElement(node.typeParameter);
checkSourceElement(node.nameType);
checkSourceElement(node.type);
@@ -34751,6 +34783,12 @@ namespace ts {
}
}
function checkGrammarMappedType(node: MappedTypeNode) {
if (node.members?.length) {
return grammarErrorOnNode(node.members[0], Diagnostics.A_mapped_type_may_not_declare_properties_or_methods);
}
}
function checkThisType(node: ThisTypeNode) {
getTypeFromThisTypeNode(node);
}
@@ -38065,7 +38103,7 @@ namespace ts {
}
}
function checkIndexConstraints(type: Type, isStaticIndex?: boolean) {
function checkIndexConstraints(type: Type, symbol: Symbol, isStaticIndex?: boolean) {
const indexInfos = getIndexInfosOfType(type);
if (indexInfos.length === 0) {
return;
@@ -38075,7 +38113,7 @@ namespace ts {
checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, TypeFlags.StringOrNumberLiteralOrUnique, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop));
}
}
const typeDeclaration = type.symbol.valueDeclaration;
const typeDeclaration = symbol.valueDeclaration;
if (typeDeclaration && isClassLike(typeDeclaration)) {
for (const member of typeDeclaration.members) {
// Only process instance properties with computed names here. Static properties cannot be in conflict with indexers,
@@ -38416,8 +38454,8 @@ namespace ts {
}
if (produceDiagnostics) {
checkIndexConstraints(type);
checkIndexConstraints(staticType, /*isStaticIndex*/ true);
checkIndexConstraints(type, symbol);
checkIndexConstraints(staticType, symbol, /*isStaticIndex*/ true);
checkTypeForDuplicateIndexSignatures(node);
checkPropertyInitialization(node);
}
@@ -38844,7 +38882,7 @@ namespace ts {
for (const baseType of getBaseTypes(type)) {
checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, Diagnostics.Interface_0_incorrectly_extends_interface_1);
}
checkIndexConstraints(type);
checkIndexConstraints(type, symbol);
}
}
checkObjectTypeForDuplicateDeclarations(node);
@@ -43413,6 +43451,11 @@ namespace ts {
}
function checkGrammarProperty(node: PropertyDeclaration | PropertySignature) {
if (isComputedPropertyName(node.name) && isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === SyntaxKind.InKeyword) {
return grammarErrorOnNode(
(node.parent as ClassLikeDeclaration | InterfaceDeclaration | TypeLiteralNode).members[0],
Diagnostics.A_mapped_type_may_not_declare_properties_or_methods);
}
if (isClassLike(node.parent)) {
if (isStringLiteral(node.name) && node.name.text === "constructor") {
return grammarErrorOnNode(node.name, Diagnostics.Classes_may_not_have_a_field_named_constructor);
@@ -43432,7 +43475,7 @@ namespace ts {
return grammarErrorOnNode(node.initializer, Diagnostics.An_interface_property_cannot_have_an_initializer);
}
}
else if (node.parent.kind === SyntaxKind.TypeLiteral) {
else if (isTypeLiteralNode(node.parent)) {
if (checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) {
return true;
}
+55 -28
View File
@@ -1,6 +1,6 @@
namespace ts {
/* @internal */
export const compileOnSaveCommandLineOption: CommandLineOption = { name: "compileOnSave", type: "boolean" };
export const compileOnSaveCommandLineOption: CommandLineOption = { name: "compileOnSave", type: "boolean", defaultValueDescription: "false" };
const jsxOptionMap = new Map(getEntries({
"preserve": JsxEmit.Preserve,
@@ -144,6 +144,7 @@ namespace ts {
type: "boolean",
category: Diagnostics.Watch_and_Build_Modes,
description: Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively,
defaultValueDescription: "false",
},
{
name: "excludeDirectories",
@@ -180,11 +181,13 @@ namespace ts {
showInSimplifiedHelpView: true,
category: Diagnostics.Command_line_Options,
description: Diagnostics.Print_this_message,
defaultValueDescription: "false",
},
{
name: "help",
shortName: "?",
type: "boolean"
type: "boolean",
defaultValueDescription: "false",
},
{
name: "watch",
@@ -194,6 +197,7 @@ namespace ts {
isCommandLineOnly: true,
category: Diagnostics.Command_line_Options,
description: Diagnostics.Watch_input_files,
defaultValueDescription: "false",
},
{
name: "preserveWatchOutput",
@@ -201,7 +205,7 @@ namespace ts {
showInSimplifiedHelpView: false,
category: Diagnostics.Output_Formatting,
description: Diagnostics.Disable_wiping_the_console_in_watch_mode,
defaultValueDescription: "n/a"
defaultValueDescription: "false",
},
{
name: "listFiles",
@@ -214,7 +218,8 @@ namespace ts {
name: "explainFiles",
type: "boolean",
category: Diagnostics.Compiler_Diagnostics,
description: Diagnostics.Print_files_read_during_the_compilation_including_why_it_was_included
description: Diagnostics.Print_files_read_during_the_compilation_including_why_it_was_included,
defaultValueDescription: "false",
},
{
name: "listEmittedFiles",
@@ -285,7 +290,8 @@ namespace ts {
affectsSemanticDiagnostics: true,
affectsEmit: true,
category: Diagnostics.Watch_and_Build_Modes,
description: Diagnostics.Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it
description: Diagnostics.Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it,
defaultValueDescription: "false",
},
{
name: "locale",
@@ -333,6 +339,7 @@ namespace ts {
showInSimplifiedHelpView: true,
category: Diagnostics.Command_line_Options,
description: Diagnostics.Show_all_compiler_options,
defaultValueDescription: "false",
},
{
name: "version",
@@ -341,6 +348,7 @@ namespace ts {
showInSimplifiedHelpView: true,
category: Diagnostics.Command_line_Options,
description: Diagnostics.Print_the_compiler_s_version,
defaultValueDescription: "false",
},
{
name: "init",
@@ -348,6 +356,7 @@ namespace ts {
showInSimplifiedHelpView: true,
category: Diagnostics.Command_line_Options,
description: Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file,
defaultValueDescription: "false",
},
{
name: "project",
@@ -365,7 +374,8 @@ namespace ts {
shortName: "b",
showInSimplifiedHelpView: true,
category: Diagnostics.Command_line_Options,
description: Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date
description: Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date,
defaultValueDescription: "false",
},
{
name: "showConfig",
@@ -373,7 +383,8 @@ namespace ts {
showInSimplifiedHelpView: true,
category: Diagnostics.Command_line_Options,
isCommandLineOnly: true,
description: Diagnostics.Print_the_final_configuration_instead_of_building
description: Diagnostics.Print_the_final_configuration_instead_of_building,
defaultValueDescription: "false",
},
{
name: "listFilesOnly",
@@ -382,7 +393,8 @@ namespace ts {
affectsSemanticDiagnostics: true,
affectsEmit: true,
isCommandLineOnly: true,
description: Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing
description: Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
defaultValueDescription: "false",
},
// Basic
@@ -504,7 +516,6 @@ namespace ts {
category: Diagnostics.Emit,
description: Diagnostics.Specify_a_file_that_bundles_all_outputs_into_one_JavaScript_file_If_declaration_is_true_also_designates_a_file_that_bundles_all_d_ts_output,
transpileOptionValue: undefined,
defaultValueDescription: "n/a"
},
{
name: "outDir",
@@ -515,7 +526,6 @@ namespace ts {
showInSimplifiedHelpView: true,
category: Diagnostics.Emit,
description: Diagnostics.Specify_an_output_folder_for_all_emitted_files,
defaultValueDescription: "n/a"
},
{
name: "rootDir",
@@ -673,6 +683,7 @@ namespace ts {
strictFlag: true,
category: Diagnostics.Type_Checking,
description: Diagnostics.Type_catch_clause_variables_as_unknown_instead_of_any,
defaultValueDescription: "false",
},
{
name: "alwaysStrict",
@@ -706,7 +717,8 @@ namespace ts {
type: "boolean",
affectsSemanticDiagnostics: true,
category: Diagnostics.Type_Checking,
description: Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined
description: Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined,
defaultValueDescription: "false",
},
{
name: "noImplicitReturns",
@@ -722,21 +734,24 @@ namespace ts {
affectsBindDiagnostics: true,
affectsSemanticDiagnostics: true,
category: Diagnostics.Type_Checking,
description: Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements
description: Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements,
defaultValueDescription: "false",
},
{
name: "noUncheckedIndexedAccess",
type: "boolean",
affectsSemanticDiagnostics: true,
category: Diagnostics.Type_Checking,
description: Diagnostics.Include_undefined_in_index_signature_results
description: Diagnostics.Include_undefined_in_index_signature_results,
defaultValueDescription: "false",
},
{
name: "noImplicitOverride",
type: "boolean",
affectsSemanticDiagnostics: true,
category: Diagnostics.Type_Checking,
description: Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier
description: Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier,
defaultValueDescription: "false",
},
{
name: "noPropertyAccessFromIndexSignature",
@@ -846,7 +861,7 @@ namespace ts {
type: "boolean",
category: Diagnostics.Interop_Constraints,
description: Diagnostics.Disable_resolving_symlinks_to_their_realpath_This_correlates_to_the_same_flag_in_node,
defaultValueDescription: "n/a"
defaultValueDescription: "false",
},
{
name: "allowUmdGlobalAccess",
@@ -897,7 +912,8 @@ namespace ts {
type: "boolean",
affectsSemanticDiagnostics: true,
category: Diagnostics.Language_and_Environment,
description: Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators
description: Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators,
defaultValueDescription: "false",
},
{
name: "emitDecoratorMetadata",
@@ -905,7 +921,8 @@ namespace ts {
affectsSemanticDiagnostics: true,
affectsEmit: true,
category: Diagnostics.Language_and_Environment,
description: Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files
description: Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files,
defaultValueDescription: "false",
},
// Advanced
@@ -950,7 +967,6 @@ namespace ts {
category: Diagnostics.Backwards_Compatibility,
paramType: Diagnostics.FILE,
transpileOptionValue: undefined,
defaultValueDescription: "n/a",
description: Diagnostics.Deprecated_setting_Use_outFile_instead,
},
{
@@ -1031,6 +1047,7 @@ namespace ts {
affectsEmit: true,
category: Diagnostics.Emit,
description: Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments,
defaultValueDescription: "false",
},
{
name: "disableSizeLimit",
@@ -1045,21 +1062,24 @@ namespace ts {
type: "boolean",
isTSConfigOnly: true,
category: Diagnostics.Projects,
description: Diagnostics.Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects
description: Diagnostics.Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects,
defaultValueDescription: "false",
},
{
name: "disableSolutionSearching",
type: "boolean",
isTSConfigOnly: true,
category: Diagnostics.Projects,
description: Diagnostics.Opt_a_project_out_of_multi_project_reference_checking_when_editing
description: Diagnostics.Opt_a_project_out_of_multi_project_reference_checking_when_editing,
defaultValueDescription: "false",
},
{
name: "disableReferencedProjectLoad",
type: "boolean",
isTSConfigOnly: true,
category: Diagnostics.Projects,
description: Diagnostics.Reduce_the_number_of_projects_loaded_automatically_by_TypeScript
description: Diagnostics.Reduce_the_number_of_projects_loaded_automatically_by_TypeScript,
defaultValueDescription: "false",
},
{
name: "noImplicitUseStrict",
@@ -1092,7 +1112,7 @@ namespace ts {
affectsEmit: true,
category: Diagnostics.Emit,
description: Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code,
defaultValueDescription: "n/a"
defaultValueDescription: "false",
},
{
name: "declarationDir",
@@ -1103,7 +1123,6 @@ namespace ts {
category: Diagnostics.Emit,
transpileOptionValue: undefined,
description: Diagnostics.Specify_the_output_directory_for_generated_declaration_files,
defaultValueDescription: "n/a"
},
{
name: "skipLibCheck",
@@ -1185,6 +1204,7 @@ namespace ts {
affectsEmit: true,
category: Diagnostics.Emit,
description: Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed,
defaultValueDescription: "false",
},
{
@@ -1247,27 +1267,31 @@ namespace ts {
shortName: "v",
category: Diagnostics.Command_line_Options,
description: Diagnostics.Enable_verbose_logging,
type: "boolean"
type: "boolean",
defaultValueDescription: "false",
},
{
name: "dry",
shortName: "d",
category: Diagnostics.Command_line_Options,
description: Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean,
type: "boolean"
type: "boolean",
defaultValueDescription: "false",
},
{
name: "force",
shortName: "f",
category: Diagnostics.Command_line_Options,
description: Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date,
type: "boolean"
type: "boolean",
defaultValueDescription: "false",
},
{
name: "clean",
category: Diagnostics.Command_line_Options,
description: Diagnostics.Delete_the_outputs_of_all_projects,
type: "boolean"
type: "boolean",
defaultValueDescription: "false",
}
];
@@ -1285,10 +1309,12 @@ namespace ts {
*/
name: "enableAutoDiscovery",
type: "boolean",
defaultValueDescription: "false",
},
{
name: "enable",
type: "boolean",
defaultValueDescription: "false",
},
{
name: "include",
@@ -1309,6 +1335,7 @@ namespace ts {
{
name: "disableFilenameBasedTypeAcquisition",
type: "boolean",
defaultValueDescription: "false",
},
];
@@ -2290,7 +2317,7 @@ namespace ts {
return getCustomTypeMapOfCommandLineOption(optionDefinition.element);
}
else {
return (optionDefinition as CommandLineOptionOfCustomType).type;
return optionDefinition.type;
}
}
-20
View File
@@ -1,25 +1,5 @@
/* @internal */
namespace ts {
type GetIteratorCallback = <I extends readonly any[] | ReadonlySet<any> | ReadonlyESMap<any, any> | undefined>(iterable: I) => Iterator<
I extends ReadonlyESMap<infer K, infer V> ? [K, V] :
I extends ReadonlySet<infer T> ? T :
I extends readonly (infer T)[] ? T :
I extends undefined ? undefined :
never>;
function getCollectionImplementation<
K1 extends MatchingKeys<typeof NativeCollections, () => any>,
K2 extends MatchingKeys<typeof ShimCollections, (getIterator?: GetIteratorCallback) => ReturnType<(typeof NativeCollections)[K1]>>
>(name: string, nativeFactory: K1, shimFactory: K2): NonNullable<ReturnType<(typeof NativeCollections)[K1]>> {
// NOTE: ts.ShimCollections will be defined for typescriptServices.js but not for tsc.js, so we must test for it.
const constructor = NativeCollections[nativeFactory]() ?? ShimCollections?.[shimFactory](getIterator);
if (constructor) return constructor as NonNullable<ReturnType<(typeof NativeCollections)[K1]>>;
throw new Error(`TypeScript requires an environment that provides a compatible native ${name} implementation.`);
}
export const Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
export const Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");
export function getIterator<I extends readonly any[] | ReadonlySet<any> | ReadonlyESMap<any, any> | undefined>(iterable: I): Iterator<
I extends ReadonlyESMap<infer K, infer V> ? [K, V] :
I extends ReadonlySet<infer T> ? T :
+26 -2
View File
@@ -113,7 +113,7 @@ namespace ts {
}
/* @internal */
export namespace NativeCollections {
namespace NativeCollections {
declare const Map: MapConstructor | undefined;
declare const Set: SetConstructor | undefined;
@@ -135,4 +135,28 @@ namespace ts {
return typeof Set !== "undefined" && "entries" in Set.prototype && new Set([0]).size === 1 ? Set : undefined;
}
}
}
/* @internal */
export const Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
/* @internal */
export const Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");
/* @internal */
type GetIteratorCallback = <I extends readonly any[] | ReadonlySet<any> | ReadonlyESMap<any, any> | undefined>(iterable: I) => Iterator<
I extends ReadonlyESMap<infer K, infer V> ? [K, V] :
I extends ReadonlySet<infer T> ? T :
I extends readonly (infer T)[] ? T :
I extends undefined ? undefined :
never>;
/* @internal */
function getCollectionImplementation<
K1 extends MatchingKeys<typeof NativeCollections, () => any>,
K2 extends MatchingKeys<typeof ShimCollections, (getIterator?: GetIteratorCallback) => ReturnType<(typeof NativeCollections)[K1]>>
>(name: string, nativeFactory: K1, shimFactory: K2): NonNullable<ReturnType<(typeof NativeCollections)[K1]>> {
// NOTE: ts.ShimCollections will be defined for typescriptServices.js but not for tsc.js, so we must test for it.
const constructor = NativeCollections[nativeFactory]() ?? ShimCollections?.[shimFactory](getIterator);
if (constructor) return constructor as NonNullable<ReturnType<(typeof NativeCollections)[K1]>>;
throw new Error(`TypeScript requires an environment that provides a compatible native ${name} implementation.`);
}
}
+10 -3
View File
@@ -1164,6 +1164,10 @@
"category": "Error",
"code": 1389
},
"'{0}' is not allowed as a parameter name.": {
"category": "Error",
"code": 1390
},
"An import alias cannot use 'import type'": {
"category": "Error",
"code": 1392
@@ -5993,7 +5997,10 @@
"category": "Error",
"code": 7060
},
"A mapped type may not declare properties or methods.": {
"category": "Error",
"code": 7061
},
"You cannot rename this element.": {
"category": "Error",
@@ -6216,7 +6223,7 @@
"code": 18003
},
"File is a CommonJS module; it may be converted to an ES6 module.": {
"File is a CommonJS module; it may be converted to an ES module.": {
"category": "Suggestion",
"code": 80001
},
@@ -6465,7 +6472,7 @@
"category": "Message",
"code": 95016
},
"Convert to ES6 module": {
"Convert to ES module": {
"category": "Message",
"code": 95017
},
+5 -3
View File
@@ -2112,25 +2112,27 @@ namespace ts {
}
// @api
function createMappedTypeNode(readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode {
function createMappedTypeNode(readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: readonly TypeElement[] | undefined): MappedTypeNode {
const node = createBaseNode<MappedTypeNode>(SyntaxKind.MappedType);
node.readonlyToken = readonlyToken;
node.typeParameter = typeParameter;
node.nameType = nameType;
node.questionToken = questionToken;
node.type = type;
node.members = members && createNodeArray(members);
node.transformFlags = TransformFlags.ContainsTypeScript;
return node;
}
// @api
function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode {
function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: NodeArray<TypeElement> | undefined): MappedTypeNode {
return node.readonlyToken !== readonlyToken
|| node.typeParameter !== typeParameter
|| node.nameType !== nameType
|| node.questionToken !== questionToken
|| node.type !== type
? update(createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type), node)
|| node.members !== members
? update(createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), node)
: node;
}
+27 -16
View File
@@ -212,7 +212,8 @@ namespace ts {
visitNode(cbNode, (node as MappedTypeNode).typeParameter) ||
visitNode(cbNode, (node as MappedTypeNode).nameType) ||
visitNode(cbNode, (node as MappedTypeNode).questionToken) ||
visitNode(cbNode, (node as MappedTypeNode).type);
visitNode(cbNode, (node as MappedTypeNode).type) ||
visitNodes(cbNode, cbNodes, (node as MappedTypeNode).members);
case SyntaxKind.LiteralType:
return visitNode(cbNode, (node as LiteralTypeNode).literal);
case SyntaxKind.NamedTupleMember:
@@ -2610,7 +2611,10 @@ namespace ts {
case ParsingContext.ObjectLiteralMembers: return parseErrorAtCurrentToken(Diagnostics.Property_assignment_expected);
case ParsingContext.ArrayLiteralMembers: return parseErrorAtCurrentToken(Diagnostics.Expression_or_comma_expected);
case ParsingContext.JSDocParameters: return parseErrorAtCurrentToken(Diagnostics.Parameter_declaration_expected);
case ParsingContext.Parameters: return parseErrorAtCurrentToken(Diagnostics.Parameter_declaration_expected);
case ParsingContext.Parameters:
return isKeyword(token())
? parseErrorAtCurrentToken(Diagnostics._0_is_not_allowed_as_a_parameter_name, tokenToString(token()))
: parseErrorAtCurrentToken(Diagnostics.Parameter_declaration_expected);
case ParsingContext.TypeParameters: return parseErrorAtCurrentToken(Diagnostics.Type_parameter_declaration_expected);
case ParsingContext.TypeArguments: return parseErrorAtCurrentToken(Diagnostics.Type_argument_expected);
case ParsingContext.TupleElementTypes: return parseErrorAtCurrentToken(Diagnostics.Type_expected);
@@ -3534,8 +3538,9 @@ namespace ts {
}
const type = parseTypeAnnotation();
parseSemicolon();
const members = parseList(ParsingContext.TypeMembers, parseTypeMember);
parseExpected(SyntaxKind.CloseBraceToken);
return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type), pos);
return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), pos);
}
function parseTupleElementType() {
@@ -7277,19 +7282,24 @@ namespace ts {
const pos = getNodePos();
parseExpected(SyntaxKind.AssertKeyword);
const openBracePosition = scanner.getTokenPos();
parseExpected(SyntaxKind.OpenBraceToken);
const multiLine = scanner.hasPrecedingLineBreak();
const elements = parseDelimitedList(ParsingContext.AssertEntries, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true);
if (!parseExpected(SyntaxKind.CloseBraceToken)) {
const lastError = lastOrUndefined(parseDiagnostics);
if (lastError && lastError.code === Diagnostics._0_expected.code) {
addRelatedInfo(
lastError,
createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)
);
if (parseExpected(SyntaxKind.OpenBraceToken)) {
const multiLine = scanner.hasPrecedingLineBreak();
const elements = parseDelimitedList(ParsingContext.AssertEntries, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true);
if (!parseExpected(SyntaxKind.CloseBraceToken)) {
const lastError = lastOrUndefined(parseDiagnostics);
if (lastError && lastError.code === Diagnostics._0_expected.code) {
addRelatedInfo(
lastError,
createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)
);
}
}
return finishNode(factory.createAssertClause(elements, multiLine), pos);
}
else {
const elements = createNodeArray([], getNodePos(), /*end*/ undefined, /*hasTrailingComma*/ false);
return finishNode(factory.createAssertClause(elements, /*multiLine*/ false), pos);
}
return finishNode(factory.createAssertClause(elements, multiLine), pos);
}
function tokenAfterImportDefinitelyProducesImportDeclaration() {
@@ -8256,8 +8266,9 @@ namespace ts {
}
function parseSeeTag(start: number, tagName: Identifier, indent?: number, indentText?: string): JSDocSeeTag {
const isLink = lookAhead(() => nextTokenJSDoc() === SyntaxKind.AtToken && tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link");
const nameExpression = isLink ? undefined : parseJSDocNameReference();
const isMarkdownOrJSDocLink = token() === SyntaxKind.OpenBracketToken
|| lookAhead(() => nextTokenJSDoc() === SyntaxKind.AtToken && tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link");
const nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference();
const comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined;
return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start);
}
+1 -1
View File
@@ -685,7 +685,7 @@ namespace ts {
break;
case FileIncludeKind.TypeReferenceDirective:
({ pos, end } = file.typeReferenceDirectives[index]);
packageId = file.resolvedTypeReferenceDirectiveNames?.get(toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), getModeForResolutionAtIndex(file, index))?.packageId;
packageId = file.resolvedTypeReferenceDirectiveNames?.get(toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), file.impliedNodeFormat)?.packageId;
break;
case FileIncludeKind.LibReferenceDirective:
({ pos, end } = file.libReferenceDirectives[index]);
+5
View File
@@ -1900,6 +1900,11 @@ namespace ts {
return sys!;
})();
/*@internal*/
export function setSys(s: System) {
sys = s;
}
if (sys && sys.getEnvironmentVariable) {
setCustomPollingValues(sys);
Debug.setAssertionLevel(/^development$/i.test(sys.getEnvironmentVariable("NODE_ENV"))
+1 -1
View File
@@ -566,7 +566,7 @@ namespace ts {
}
export const nullTransformationContext: TransformationContext = {
factory,
factory: factory, // eslint-disable-line object-shorthand
getCompilerOptions: () => ({}),
getEmitResolver: notImplemented,
getEmitHost: notImplemented,
+12 -76
View File
@@ -4102,86 +4102,22 @@ namespace ts {
* @param node A TemplateExpression node.
*/
function visitTemplateExpression(node: TemplateExpression): Expression {
const expressions: Expression[] = [];
addTemplateHead(expressions, node);
addTemplateSpans(expressions, node);
// createAdd will check if each expression binds less closely than binary '+'.
// If it does, it wraps the expression in parentheses. Otherwise, something like
// `abc${ 1 << 2 }`
// becomes
// "abc" + 1 << 2 + ""
// which is really
// ("abc" + 1) << (2 + "")
// rather than
// "abc" + (1 << 2) + ""
const expression = reduceLeft(expressions, factory.createAdd)!;
if (nodeIsSynthesized(expression)) {
setTextRange(expression, node);
}
return expression;
}
/**
* Gets a value indicating whether we need to include the head of a TemplateExpression.
*
* @param node A TemplateExpression node.
*/
function shouldAddTemplateHead(node: TemplateExpression) {
// If this expression has an empty head literal and the first template span has a non-empty
// literal, then emitting the empty head literal is not necessary.
// `${ foo } and ${ bar }`
// can be emitted as
// foo + " and " + bar
// This is because it is only required that one of the first two operands in the emit
// output must be a string literal, so that the other operand and all following operands
// are forced into strings.
//
// If the first template span has an empty literal, then the head must still be emitted.
// `${ foo }${ bar }`
// must still be emitted as
// "" + foo + bar
// There is always atleast one templateSpan in this code path, since
// NoSubstitutionTemplateLiterals are directly emitted via emitLiteral()
Debug.assert(node.templateSpans.length !== 0);
return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0;
}
/**
* Adds the head of a TemplateExpression to an array of expressions.
*
* @param expressions An array of expressions.
* @param node A TemplateExpression node.
*/
function addTemplateHead(expressions: Expression[], node: TemplateExpression): void {
if (!shouldAddTemplateHead(node)) {
return;
}
expressions.push(factory.createStringLiteral(node.head.text));
}
/**
* Visits and adds the template spans of a TemplateExpression to an array of expressions.
*
* @param expressions An array of expressions.
* @param node A TemplateExpression node.
*/
function addTemplateSpans(expressions: Expression[], node: TemplateExpression): void {
let expression: Expression = factory.createStringLiteral(node.head.text);
for (const span of node.templateSpans) {
expressions.push(visitNode(span.expression, visitor, isExpression));
const args = [visitNode(span.expression, visitor, isExpression)];
// Only emit if the literal is non-empty.
// The binary '+' operator is left-associative, so the first string concatenation
// with the head will force the result up to this point to be a string.
// Emitting a '+ ""' has no semantic effect for middles and tails.
if (span.literal.text.length !== 0) {
expressions.push(factory.createStringLiteral(span.literal.text));
if (span.literal.text.length > 0) {
args.push(factory.createStringLiteral(span.literal.text));
}
expression = factory.createCallExpression(
factory.createPropertyAccessExpression(expression, "concat"),
/*typeArguments*/ undefined,
args,
);
}
return setTextRange(expression, node);
}
/**
+50 -82
View File
@@ -200,59 +200,27 @@ namespace ts {
}
function convertJsxChildrenToChildrenPropObject(children: readonly JsxChild[]) {
const prop = convertJsxChildrenToChildrenPropAssignment(children);
return prop && factory.createObjectLiteralExpression([prop]);
}
function convertJsxChildrenToChildrenPropAssignment(children: readonly JsxChild[]) {
const nonWhitespaceChildren = getSemanticJsxChildren(children);
if (length(nonWhitespaceChildren) === 1) {
const result = transformJsxChildToExpression(nonWhitespaceChildren[0]);
return result && factory.createObjectLiteralExpression([
factory.createPropertyAssignment("children", result)
]);
return result && factory.createPropertyAssignment("children", result);
}
const result = mapDefined(children, transformJsxChildToExpression);
return !result.length ? undefined : factory.createObjectLiteralExpression([
factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result))
]);
return length(result) ? factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) : undefined;
}
function visitJsxOpeningLikeElementJSX(node: JsxOpeningLikeElement, children: readonly JsxChild[] | undefined, isChild: boolean, location: TextRange) {
const tagName = getTagName(node);
let objectProperties: Expression;
const childrenProp = children && children.length ? convertJsxChildrenToChildrenPropAssignment(children) : undefined;
const keyAttr = find(node.attributes.properties, p => !!p.name && isIdentifier(p.name) && p.name.escapedText === "key") as JsxAttribute | undefined;
const attrs = keyAttr ? filter(node.attributes.properties, p => p !== keyAttr) : node.attributes.properties;
let segments: Expression[] = [];
if (attrs.length) {
// Map spans of JsxAttribute nodes into object literals and spans
// of JsxSpreadAttribute nodes into expressions.
segments = flatten(
spanMap(attrs, isJsxSpreadAttribute, (attrs, isSpread) => isSpread
? map(attrs, transformJsxSpreadAttributeToExpression)
: factory.createObjectLiteralExpression(map(attrs, transformJsxAttributeToObjectLiteralElement))
)
);
if (isJsxSpreadAttribute(attrs[0])) {
// We must always emit at least one object literal before a spread
// argument.factory.createObjectLiteral
segments.unshift(factory.createObjectLiteralExpression());
}
}
if (children && children.length) {
const result = convertJsxChildrenToChildrenPropObject(children);
if (result) {
segments.push(result);
}
}
if (segments.length === 0) {
objectProperties = factory.createObjectLiteralExpression([]);
// When there are no attributes, React wants {}
}
else {
// Either emit one big object literal (no spread attribs), or
// a call to the __assign helper.
objectProperties = singleOrUndefined(segments) || emitHelpers().createAssignHelper(segments);
}
const objectProperties = length(attrs) ? transformJsxAttributesToObjectProps(attrs, childrenProp) :
factory.createObjectLiteralExpression(childrenProp ? [childrenProp] : emptyArray); // When there are no attributes, React wants {}
return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, length(getSemanticJsxChildren(children || emptyArray)), isChild, location);
}
@@ -285,47 +253,9 @@ namespace ts {
function visitJsxOpeningLikeElementCreateElement(node: JsxOpeningLikeElement, children: readonly JsxChild[] | undefined, isChild: boolean, location: TextRange) {
const tagName = getTagName(node);
let objectProperties: Expression | undefined;
const attrs = node.attributes.properties;
if (attrs.length === 0) {
objectProperties = factory.createNull();
// When there are no attributes, React wants "null"
}
else {
const target = getEmitScriptTarget(compilerOptions);
if (target && target >= ScriptTarget.ES2018) {
objectProperties = factory.createObjectLiteralExpression(
flatten<SpreadAssignment | PropertyAssignment>(
spanMap(attrs, isJsxSpreadAttribute, (attrs, isSpread) =>
isSpread ? map(attrs, transformJsxSpreadAttributeToSpreadAssignment) : map(attrs, transformJsxAttributeToObjectLiteralElement)
)
)
);
}
else {
// Map spans of JsxAttribute nodes into object literals and spans
// of JsxSpreadAttribute nodes into expressions.
const segments = flatten<Expression | ObjectLiteralExpression>(
spanMap(attrs, isJsxSpreadAttribute, (attrs, isSpread) => isSpread
? map(attrs, transformJsxSpreadAttributeToExpression)
: factory.createObjectLiteralExpression(map(attrs, transformJsxAttributeToObjectLiteralElement))
)
);
if (isJsxSpreadAttribute(attrs[0])) {
// We must always emit at least one object literal before a spread
// argument.factory.createObjectLiteral
segments.unshift(factory.createObjectLiteralExpression());
}
// Either emit one big object literal (no spread attribs), or
// a call to the __assign helper.
objectProperties = singleOrUndefined(segments);
if (!objectProperties) {
objectProperties = emitHelpers().createAssignHelper(segments);
}
}
}
const objectProperties = length(attrs) ? transformJsxAttributesToObjectProps(attrs) :
factory.createNull(); // When there are no attributes, React wants "null"
const callee = currentFileState.importSpecifier === undefined
? createJsxFactoryExpression(
@@ -392,6 +322,44 @@ namespace ts {
return factory.createSpreadAssignment(visitNode(node.expression, visitor, isExpression));
}
function transformJsxAttributesToObjectProps(attrs: readonly(JsxSpreadAttribute | JsxAttribute)[], children?: PropertyAssignment) {
const target = getEmitScriptTarget(compilerOptions);
return target && target >= ScriptTarget.ES2018 ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) :
transformJsxAttributesToExpression(attrs, children);
}
function transformJsxAttributesToProps(attrs: readonly(JsxSpreadAttribute | JsxAttribute)[], children?: PropertyAssignment) {
const props = flatten<SpreadAssignment | PropertyAssignment>(spanMap(attrs, isJsxSpreadAttribute, (attrs, isSpread) =>
map(attrs, attr => isSpread ? transformJsxSpreadAttributeToSpreadAssignment(attr as JsxSpreadAttribute) : transformJsxAttributeToObjectLiteralElement(attr as JsxAttribute))));
if (children) {
props.push(children);
}
return props;
}
function transformJsxAttributesToExpression(attrs: readonly(JsxSpreadAttribute | JsxAttribute)[], children?: PropertyAssignment) {
// Map spans of JsxAttribute nodes into object literals and spans
// of JsxSpreadAttribute nodes into expressions.
const expressions = flatten(
spanMap(attrs, isJsxSpreadAttribute, (attrs, isSpread) => isSpread
? map(attrs, transformJsxSpreadAttributeToExpression)
: factory.createObjectLiteralExpression(map(attrs, transformJsxAttributeToObjectLiteralElement))
)
);
if (isJsxSpreadAttribute(attrs[0])) {
// We must always emit at least one object literal before a spread
// argument.factory.createObjectLiteral
expressions.unshift(factory.createObjectLiteralExpression());
}
if (children) {
expressions.push(factory.createObjectLiteralExpression([children]));
}
return singleOrUndefined(expressions) || emitHelpers().createAssignHelper(expressions);
}
function transformJsxSpreadAttributeToExpression(node: JsxSpreadAttribute) {
return visitNode(node.expression, visitor, isExpression);
}
+20 -6
View File
@@ -1707,6 +1707,8 @@ namespace ts {
readonly nameType?: TypeNode;
readonly questionToken?: QuestionToken | PlusToken | MinusToken;
readonly type?: TypeNode;
/** Used only to produce grammar errors */
readonly members?: NodeArray<TypeElement>;
}
export interface LiteralTypeNode extends TypeNode {
@@ -6339,8 +6341,20 @@ namespace ts {
}
/* @internal */
export interface CommandLineOptionOfPrimitiveType extends CommandLineOptionBase {
type: "string" | "number" | "boolean";
export interface CommandLineOptionOfStringType extends CommandLineOptionBase {
type: "string";
}
/* @internal */
export interface CommandLineOptionOfNumberType extends CommandLineOptionBase {
type: "number";
defaultValueDescription: `${number | undefined}` | DiagnosticMessage;
}
/* @internal */
export interface CommandLineOptionOfBooleanType extends CommandLineOptionBase {
type: "boolean";
defaultValueDescription: `${boolean | undefined}` | DiagnosticMessage;
}
/* @internal */
@@ -6372,11 +6386,11 @@ namespace ts {
/* @internal */
export interface CommandLineOptionOfListType extends CommandLineOptionBase {
type: "list";
element: CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType | TsConfigOnlyOption;
element: CommandLineOptionOfCustomType | CommandLineOptionOfStringType | CommandLineOptionOfNumberType | CommandLineOptionOfBooleanType | TsConfigOnlyOption;
}
/* @internal */
export type CommandLineOption = CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType | TsConfigOnlyOption | CommandLineOptionOfListType;
export type CommandLineOption = CommandLineOptionOfCustomType | CommandLineOptionOfStringType | CommandLineOptionOfNumberType | CommandLineOptionOfBooleanType | TsConfigOnlyOption | CommandLineOptionOfListType;
/* @internal */
export const enum CharacterCodes {
@@ -7215,8 +7229,8 @@ namespace ts {
updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode;
createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
createMappedTypeNode(readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode;
updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode;
createMappedTypeNode(readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: NodeArray<TypeElement> | undefined): MappedTypeNode;
updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: NodeArray<TypeElement> | undefined): MappedTypeNode;
createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode;
updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode;
createTemplateLiteralType(head: TemplateHead, templateSpans: readonly TemplateLiteralTypeSpan[]): TemplateLiteralTypeNode;
+14 -14
View File
@@ -6627,7 +6627,7 @@ namespace ts {
includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"),
includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"),
excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"),
basePaths: getBasePaths(path, includes, useCaseSensitiveFileNames)
basePaths: getBasePaths(absolutePath, includes, useCaseSensitiveFileNames)
};
}
@@ -6651,22 +6651,22 @@ namespace ts {
const results: string[][] = includeFileRegexes ? includeFileRegexes.map(() => []) : [[]];
const visited = new Map<string, true>();
const toCanonical = createGetCanonicalFileName(useCaseSensitiveFileNames);
for (const basePath of patterns.basePaths) {
if (directoryExists(basePath)) {
visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth);
for (const absoluteBasePath of patterns.basePaths) {
if (directoryExists(absoluteBasePath)) {
visitDirectory(absoluteBasePath, depth);
}
}
return flatten(results);
function visitDirectory(path: string, absolutePath: string, depth: number | undefined) {
function visitDirectory(absolutePath: string, depth: number | undefined) {
const canonicalPath = toCanonical(realpath(absolutePath));
if (visited.has(canonicalPath)) return;
visited.set(canonicalPath, true);
const { files, directories } = getFileSystemEntries(path);
const { files, directories } = getFileSystemEntries(absolutePath);
for (const current of sort<string>(files, compareStringsCaseSensitive)) {
const name = combinePaths(path, current);
const name = combinePaths(absolutePath, current);
const absoluteName = combinePaths(absolutePath, current);
if (extensions && !fileExtensionIsOneOf(name, extensions)) continue;
if (excludeRegex && excludeRegex.test(absoluteName)) continue;
@@ -6689,11 +6689,10 @@ namespace ts {
}
for (const current of sort<string>(directories, compareStringsCaseSensitive)) {
const name = combinePaths(path, current);
const absoluteName = combinePaths(absolutePath, current);
if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) &&
(!excludeRegex || !excludeRegex.test(absoluteName))) {
visitDirectory(name, absoluteName, depth);
visitDirectory(absoluteName, depth);
}
}
}
@@ -6701,10 +6700,11 @@ namespace ts {
/**
* Computes the unique non-wildcard base paths amongst the provided include patterns.
* @returns Absolute directory paths
*/
function getBasePaths(path: string, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean): string[] {
function getBasePaths(absoluteTsconfigPath: string, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean): string[] {
// Storage for our results in the form of literal paths (e.g. the paths as written by the user).
const basePaths: string[] = [path];
const basePaths: string[] = [absoluteTsconfigPath];
if (includes) {
// Storage for literal base paths amongst the include patterns.
@@ -6712,9 +6712,9 @@ namespace ts {
for (const include of includes) {
// We also need to check the relative paths by converting them to absolute and normalizing
// in case they escape the base path (e.g "..\somedirectory")
const absolute: string = isRootedDiskPath(include) ? include : normalizePath(combinePaths(path, include));
const absoluteIncludePath: string = isRootedDiskPath(include) ? include : normalizePath(combinePaths(absoluteTsconfigPath, include));
// Append the literal and canonical candidate base paths.
includeBasePaths.push(getIncludeBasePath(absolute));
includeBasePaths.push(getIncludeBasePath(absoluteIncludePath));
}
// Sort the offsets array using either the literal or canonical path representations.
@@ -6723,7 +6723,7 @@ namespace ts {
// Iterate over each include base path and include unique base paths that are not a
// subpath of an existing base path
for (const includeBasePath of includeBasePaths) {
if (every(basePaths, basePath => !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames))) {
if (every(basePaths, basePath => !containsPath(basePath, includeBasePath, absoluteTsconfigPath, !useCaseSensitiveFileNames))) {
basePaths.push(includeBasePath);
}
}
+2 -1
View File
@@ -629,7 +629,8 @@ namespace ts {
nodeVisitor(node.typeParameter, visitor, isTypeParameterDeclaration),
nodeVisitor(node.nameType, visitor, isTypeNode),
nodeVisitor(node.questionToken, tokenVisitor, isQuestionOrPlusOrMinusToken),
nodeVisitor(node.type, visitor, isTypeNode));
nodeVisitor(node.type, visitor, isTypeNode),
nodesVisitor(node.members, visitor, isTypeElement));
case SyntaxKind.LiteralType:
Debug.type<LiteralTypeNode>(node);
+3
View File
@@ -560,6 +560,9 @@ namespace ts {
sourceFilesCache.set(path, false);
}
}
if (sourceFile) {
sourceFile.impliedNodeFormat = getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings());
}
return sourceFile;
}
return hostSourceFile.sourceFile;
+21
View File
@@ -0,0 +1,21 @@
namespace findUpDir {
import { join, resolve, dirname } from "path";
import { existsSync } from "fs";
// search directories upward to avoid hard-wired paths based on the
// build tree (same as scripts/build/findUpDir.js)
export function findUpFile(name: string) {
let dir = __dirname;
while (true) {
const fullPath = join(dir, name);
if (existsSync(fullPath)) return fullPath;
const up = resolve(dir, "..");
if (up === dir) return name; // it'll fail anyway
dir = up;
}
}
export const findUpRoot: { (): string; cached?: string; } = () =>
findUpRoot.cached ||= dirname(findUpFile("Gulpfile.js"));
}
+7 -7
View File
@@ -303,21 +303,21 @@ namespace Harness {
// Additional options not already in ts.optionDeclarations
const harnessOptionDeclarations: ts.CommandLineOption[] = [
{ name: "allowNonTsExtensions", type: "boolean" },
{ name: "useCaseSensitiveFileNames", type: "boolean" },
{ name: "allowNonTsExtensions", type: "boolean", defaultValueDescription: "false" },
{ name: "useCaseSensitiveFileNames", type: "boolean", defaultValueDescription: "false" },
{ name: "baselineFile", type: "string" },
{ name: "includeBuiltFile", type: "string" },
{ name: "fileName", type: "string" },
{ name: "libFiles", type: "string" },
{ name: "noErrorTruncation", type: "boolean" },
{ name: "suppressOutputPathCheck", type: "boolean" },
{ name: "noImplicitReferences", type: "boolean" },
{ name: "noErrorTruncation", type: "boolean", defaultValueDescription: "false" },
{ name: "suppressOutputPathCheck", type: "boolean", defaultValueDescription: "false" },
{ name: "noImplicitReferences", type: "boolean", defaultValueDescription: "false" },
{ name: "currentDirectory", type: "string" },
{ name: "symlink", type: "string" },
{ name: "link", type: "string" },
{ name: "noTypesAndSymbols", type: "boolean" },
{ name: "noTypesAndSymbols", type: "boolean", defaultValueDescription: "false" },
// Emitted js baseline will print full paths for every output file
{ name: "fullEmitPaths", type: "boolean" }
{ name: "fullEmitPaths", type: "boolean", defaultValueDescription: "false" }
];
let optionsIndex: ts.ESMap<string, ts.CommandLineOption>;
+2 -2
View File
@@ -196,13 +196,13 @@ interface ObjectConstructor {
/**
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
* @param a Object on which to lock the attributes.
*/
freeze<T>(a: T[]): readonly T[];
/**
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
* @param o Object on which to lock the attributes.
* @param f Object on which to lock the attributes.
*/
freeze<T extends Function>(f: T): T;
@@ -468,6 +468,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_mapped_type_may_not_declare_properties_or_methods_7061" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A mapped type may not declare properties or methods.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[映射的类型可能不声明属性或方法。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.]]></Val>
@@ -4065,11 +4074,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Convert_to_ES6_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Convert_to_ES_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Convert to ES6 module]]></Val>
<Val><![CDATA[Convert to ES module]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[转换为 ES6 模块]]></Val>
<Val><![CDATA[转换为 ES 模块]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -6294,11 +6303,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES6 module.]]></Val>
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[文件是 CommonJS 模块它可能会转换为 ES6 模块。]]></Val>
<Val><![CDATA[文件是 CommonJS 模块; 它可能会转换为 ES 模块。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -15258,6 +15267,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_parameter_name_1390" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a parameter name.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[不允许将 '{0}' 作为参数名。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_variable_declaration_name_1389" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a variable declaration name.]]></Val>
@@ -468,6 +468,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_mapped_type_may_not_declare_properties_or_methods_7061" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A mapped type may not declare properties or methods.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[對應型別不能宣告屬性或方法。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.]]></Val>
@@ -4065,11 +4074,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Convert_to_ES6_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Convert_to_ES_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Convert to ES6 module]]></Val>
<Val><![CDATA[Convert to ES module]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[轉換為 ES6 模組]]></Val>
<Val><![CDATA[轉換為 ES 模組]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -6294,11 +6303,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES6 module.]]></Val>
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[檔案為 CommonJS 模組; 其可轉換為 ES6 模組。]]></Val>
<Val><![CDATA[檔案為 CommonJS 模組; 其可轉換為 ES 模組。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -15258,6 +15267,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_parameter_name_1390" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a parameter name.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[不允許 '{0}' 做為參數名稱。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_variable_declaration_name_1389" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a variable declaration name.]]></Val>
@@ -477,6 +477,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_mapped_type_may_not_declare_properties_or_methods_7061" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A mapped type may not declare properties or methods.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Mapovaný typ nemůže deklarovat vlastnosti nebo metody.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.]]></Val>
@@ -4074,11 +4083,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Convert_to_ES6_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Convert_to_ES_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Convert to ES6 module]]></Val>
<Val><![CDATA[Convert to ES module]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Převést na modul ES6]]></Val>
<Val><![CDATA[Převést na modul ES]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -6303,11 +6312,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES6 module.]]></Val>
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Soubor je modul CommonJS; může se převést na modul ES6.]]></Val>
<Val><![CDATA[Soubor je modul CommonJS; může být převeden na modul ES.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -15267,6 +15276,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_parameter_name_1390" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a parameter name.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[{0} není povolen jako název parametru.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_variable_declaration_name_1389" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a variable declaration name.]]></Val>
@@ -468,6 +468,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_mapped_type_may_not_declare_properties_or_methods_7061" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A mapped type may not declare properties or methods.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Ein zugeordneter Typ darf keine Eigenschaften oder Methoden deklarieren.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.]]></Val>
@@ -4062,11 +4071,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Convert_to_ES6_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Convert_to_ES_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Convert to ES6 module]]></Val>
<Val><![CDATA[Convert to ES module]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[In ES6-Modul konvertieren]]></Val>
<Val><![CDATA[In ES-Modul konvertieren]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -6291,11 +6300,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES6 module.]]></Val>
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Die Datei ist ein CommonJS-Modul, sie kann in ein ES6-Modul konvertiert werden.]]></Val>
<Val><![CDATA[Die Datei ist ein CommonJS-Modul und kann möglicherweise in ein ES-Modul konvertiert werden.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -15252,6 +15261,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_parameter_name_1390" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a parameter name.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA["{0}" ist als Parametername nicht zulässig.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_variable_declaration_name_1389" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a variable declaration name.]]></Val>
@@ -477,6 +477,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_mapped_type_may_not_declare_properties_or_methods_7061" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A mapped type may not declare properties or methods.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Un tipo asignado no puede declarar propiedades ni métodos.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.]]></Val>
@@ -4077,11 +4086,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Convert_to_ES6_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Convert_to_ES_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Convert to ES6 module]]></Val>
<Val><![CDATA[Convert to ES module]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Convertir en módulo ES6]]></Val>
<Val><![CDATA[Convertir en módulo ES]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -6306,11 +6315,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES6 module.]]></Val>
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[El archivo es un módulo CommonJS; se puede convertir a un módulo ES6.]]></Val>
<Val><![CDATA[El archivo es un módulo CommonJS; se puede convertir en un módulo ES.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -15270,6 +15279,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_parameter_name_1390" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a parameter name.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[No se permite “{0}” como nombre de parámetro.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_variable_declaration_name_1389" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a variable declaration name.]]></Val>
@@ -477,6 +477,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_mapped_type_may_not_declare_properties_or_methods_7061" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A mapped type may not declare properties or methods.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Un type mappé ne peut pas déclarer de propriétés ou de méthodes.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.]]></Val>
@@ -4077,11 +4086,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Convert_to_ES6_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Convert_to_ES_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Convert to ES6 module]]></Val>
<Val><![CDATA[Convert to ES module]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Convertir en module ES6]]></Val>
<Val><![CDATA[Convertir en module ES]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -6306,11 +6315,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES6 module.]]></Val>
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Le fichier est un module CommonJS ; il peut être converti en module ES6.]]></Val>
<Val><![CDATA[Le fichier est un module CommonJS ; il peut être converti en module ES.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -15270,6 +15279,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_parameter_name_1390" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a parameter name.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['{0}' n'est pas autorisé comme nom de paramètre.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_variable_declaration_name_1389" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a variable declaration name.]]></Val>
@@ -468,6 +468,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_mapped_type_may_not_declare_properties_or_methods_7061" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A mapped type may not declare properties or methods.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Un tipo di cui è stato eseguito il mapping non può dichiarare proprietà o metodi.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.]]></Val>
@@ -4065,11 +4074,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Convert_to_ES6_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Convert_to_ES_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Convert to ES6 module]]></Val>
<Val><![CDATA[Convert to ES module]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Convertire nel modulo ES6]]></Val>
<Val><![CDATA[Converti nel modulo ES6]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -6294,11 +6303,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES6 module.]]></Val>
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Il file è un modulo CommonJS; può essere convertito in un modulo ES6.]]></Val>
<Val><![CDATA[Il file è un modulo CommonJS e può essere convertito in un modulo ES6.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -15258,6 +15267,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_parameter_name_1390" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a parameter name.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['{0}' non è un nome di parametro consentito.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_variable_declaration_name_1389" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a variable declaration name.]]></Val>
@@ -468,6 +468,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_mapped_type_may_not_declare_properties_or_methods_7061" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A mapped type may not declare properties or methods.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[マップされた型では、プロパティまたはメソッドを宣言しない場合があります。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.]]></Val>
@@ -4065,11 +4074,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Convert_to_ES6_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Convert_to_ES_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Convert to ES6 module]]></Val>
<Val><![CDATA[Convert to ES module]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[ES6 モジュールに変換します]]></Val>
<Val><![CDATA[ES モジュールに変換す]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -6294,11 +6303,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES6 module.]]></Val>
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[ファイルは CommonJS モジュールです。ES6 モジュールに変換される可能性があります。]]></Val>
<Val><![CDATA[ファイルは CommonJS モジュールです。ES モジュールに変換される可能性があります。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -15258,6 +15267,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_parameter_name_1390" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a parameter name.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['{0}' はパラメーター名として使用できません。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_variable_declaration_name_1389" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a variable declaration name.]]></Val>
@@ -468,6 +468,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_mapped_type_may_not_declare_properties_or_methods_7061" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A mapped type may not declare properties or methods.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[매핑된 형식은 속성 또는 메서드를 선언할 수 없습니다.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.]]></Val>
@@ -4065,11 +4074,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Convert_to_ES6_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Convert_to_ES_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Convert to ES6 module]]></Val>
<Val><![CDATA[Convert to ES module]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[ES6 모듈로 변환]]></Val>
<Val><![CDATA[ES 모듈로 변환]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -6294,11 +6303,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES6 module.]]></Val>
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[파일이 CommonJS 모듈입니다. ES6 모듈로 변환될 수 있습니다.]]></Val>
<Val><![CDATA[파일이 CommonJS 모듈입니다. ES 모듈로 변환될 수 있습니다.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -15258,6 +15267,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_parameter_name_1390" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a parameter name.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['{0}'은(는) 매개 변수 이름으로 사용할 수 없습니다.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_variable_declaration_name_1389" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a variable declaration name.]]></Val>
@@ -461,6 +461,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_mapped_type_may_not_declare_properties_or_methods_7061" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A mapped type may not declare properties or methods.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Zmapowany typ nie może deklarować właściwości ani metod.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.]]></Val>
@@ -4055,11 +4064,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Convert_to_ES6_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Convert_to_ES_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Convert to ES6 module]]></Val>
<Val><![CDATA[Convert to ES module]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Konwertuj na moduł ES6]]></Val>
<Val><![CDATA[Konwertuj na moduł ES]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -6284,11 +6293,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES6 module.]]></Val>
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Plik jest modułem CommonJS. Może zostać przekonwertowany na moduł ES6.]]></Val>
<Val><![CDATA[Plik jest modułem CommonJS; może zostać przekonwertowany na moduł ES.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -15245,6 +15254,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_parameter_name_1390" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a parameter name.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[„{0}” jest niedozwolone jako nazwa parametru.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_variable_declaration_name_1389" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a variable declaration name.]]></Val>
@@ -461,6 +461,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_mapped_type_may_not_declare_properties_or_methods_7061" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A mapped type may not declare properties or methods.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Um tipo mapeado não pode declarar propriedades ou métodos.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.]]></Val>
@@ -4058,11 +4067,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Convert_to_ES6_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Convert_to_ES_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Convert to ES6 module]]></Val>
<Val><![CDATA[Convert to ES module]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Converter em módulo ES6]]></Val>
<Val><![CDATA[Converter em módulo ES]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -6287,11 +6296,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES6 module.]]></Val>
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[O arquivo é um módulo CommonJS; ele pode ser convertido em um módulo ES6.]]></Val>
<Val><![CDATA[O arquivo é um módulo CommonJS; ele pode ser convertido em um módulo ES.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -15248,6 +15257,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_parameter_name_1390" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a parameter name.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['{0}' não é permitido como um nome de parâmetro.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_variable_declaration_name_1389" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a variable declaration name.]]></Val>
@@ -467,6 +467,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_mapped_type_may_not_declare_properties_or_methods_7061" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A mapped type may not declare properties or methods.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Сопоставленный тип не может объявлять свойства и методы.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.]]></Val>
@@ -4064,11 +4073,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Convert_to_ES6_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Convert_to_ES_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Convert to ES6 module]]></Val>
<Val><![CDATA[Convert to ES module]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Преобразовать в модуль ES6]]></Val>
<Val><![CDATA[Преобразовать в модуль ES]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -6293,11 +6302,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES6 module.]]></Val>
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Файл является модулем CommonJS; его можно преобразовать в модуль ES6.]]></Val>
<Val><![CDATA[Файл является модулем CommonJS. Его можно преобразовать в модуль ES.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -15257,6 +15266,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_parameter_name_1390" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a parameter name.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA["{0}" не является допустимым именем параметра.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_variable_declaration_name_1389" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a variable declaration name.]]></Val>
@@ -461,6 +461,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_mapped_type_may_not_declare_properties_or_methods_7061" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A mapped type may not declare properties or methods.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Eşlenmiş bir tür özellik veya metot bildiremez.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.]]></Val>
@@ -4058,11 +4067,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Convert_to_ES6_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";Convert_to_ES_module_95017" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Convert to ES6 module]]></Val>
<Val><![CDATA[Convert to ES module]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[ES6 modülüne dönüştür]]></Val>
<Val><![CDATA[ES modülüne dönüştür]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -6287,11 +6296,11 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Item ItemId=";File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES6 module.]]></Val>
<Val><![CDATA[File is a CommonJS module; it may be converted to an ES module.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Bir CommonJS modülü olan dosya, ES6 modülüne dönüştürülebilir.]]></Val>
<Val><![CDATA[Bir CommonJS modülü olan dosya bir ES modülüne dönüştürülebilir.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -15251,6 +15260,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_parameter_name_1390" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a parameter name.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['{0}' öğesine parametre adı olarak izin verilmiyor.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";_0_is_not_allowed_as_a_variable_declaration_name_1389" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['{0}' is not allowed as a variable declaration name.]]></Val>
+5 -1
View File
@@ -1,4 +1,4 @@
namespace Playback {
namespace Playback { // eslint-disable-line one-namespace-per-file
interface FileInformation {
contents?: string;
contentsPath?: string;
@@ -445,3 +445,7 @@ namespace Playback {
return wrapper;
}
}
// empty modules for the module migration script
namespace ts.server { } // eslint-disable-line one-namespace-per-file
namespace Harness { } // eslint-disable-line one-namespace-per-file
@@ -47,7 +47,12 @@ namespace ts.codefix {
}
function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, { container, typeNode, constraint, name }: Info): void {
changes.replaceNode(sourceFile, container, factory.createMappedTypeNode(/*readonlyToken*/ undefined,
factory.createTypeParameterDeclaration(name, factory.createTypeReferenceNode(constraint)), /*nameType*/ undefined, /*questionToken*/ undefined, typeNode));
changes.replaceNode(sourceFile, container, factory.createMappedTypeNode(
/*readonlyToken*/ undefined,
factory.createTypeParameterDeclaration(name, factory.createTypeReferenceNode(constraint)),
/*nameType*/ undefined,
/*questionToken*/ undefined,
typeNode,
/*members*/ undefined));
}
}
@@ -1,11 +1,11 @@
/* @internal */
namespace ts.codefix {
registerCodeFix({
errorCodes: [Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module.code],
errorCodes: [Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module.code],
getCodeActions(context) {
const { sourceFile, program, preferences } = context;
const changes = textChanges.ChangeTracker.with(context, changes => {
const moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, getEmitScriptTarget(program.getCompilerOptions()), getQuotePreference(sourceFile, preferences));
const moduleExportsChangedToDefault = convertFileToEsModule(sourceFile, program.getTypeChecker(), changes, getEmitScriptTarget(program.getCompilerOptions()), getQuotePreference(sourceFile, preferences));
if (moduleExportsChangedToDefault) {
for (const importingFile of program.getSourceFiles()) {
fixImportOfModuleExports(importingFile, sourceFile, changes, getQuotePreference(importingFile, preferences));
@@ -13,7 +13,7 @@ namespace ts.codefix {
}
});
// No support for fix-all since this applies to the whole file at once anyway.
return [createCodeFixActionWithoutFixAll("convertToEs6Module", changes, Diagnostics.Convert_to_ES6_module)];
return [createCodeFixActionWithoutFixAll("convertToEsModule", changes, Diagnostics.Convert_to_ES_module)];
},
});
@@ -39,7 +39,7 @@ namespace ts.codefix {
}
/** @returns Whether we converted a `module.exports =` to a default export. */
function convertFileToEs6Module(sourceFile: SourceFile, checker: TypeChecker, changes: textChanges.ChangeTracker, target: ScriptTarget, quotePreference: QuotePreference): ModuleExportsChanged {
function convertFileToEsModule(sourceFile: SourceFile, checker: TypeChecker, changes: textChanges.ChangeTracker, target: ScriptTarget, quotePreference: QuotePreference): ModuleExportsChanged {
const identifiers: Identifiers = { original: collectFreeIdentifiers(sourceFile), additional: new Set() };
const exports = collectExportRenames(sourceFile, checker, identifiers);
convertExportsAccesses(sourceFile, exports, changes);
@@ -210,7 +210,7 @@ namespace ts.codefix {
// `const a = require("b").c` --> `import { c as a } from "./b";
return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]);
default:
return Debug.assertNever(name, `Convert to ES6 module got invalid syntax form ${(name as BindingName).kind}`);
return Debug.assertNever(name, `Convert to ES module got invalid syntax form ${(name as BindingName).kind}`);
}
}
@@ -430,7 +430,7 @@ namespace ts.codefix {
case SyntaxKind.Identifier:
return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference);
default:
return Debug.assertNever(name, `Convert to ES6 module got invalid name kind ${(name as BindingName).kind}`);
return Debug.assertNever(name, `Convert to ES module got invalid name kind ${(name as BindingName).kind}`);
}
}
@@ -46,7 +46,8 @@ namespace ts.codefix {
mappedTypeParameter,
/*nameType*/ undefined,
indexSignature.questionToken,
indexSignature.type);
indexSignature.type,
/*members*/ undefined);
const intersectionType = factory.createIntersectionTypeNode([
...getAllSuperTypeNodes(container),
mappedIntersectionType,
@@ -53,7 +53,8 @@ namespace ts.codefix {
insertBefore = findChildOfKind(containingFunction, SyntaxKind.FunctionKeyword, sourceFile);
break;
case SyntaxKind.ArrowFunction:
insertBefore = findChildOfKind(containingFunction, SyntaxKind.OpenParenToken, sourceFile) || first(containingFunction.parameters);
const kind = containingFunction.typeParameters ? SyntaxKind.LessThanToken : SyntaxKind.OpenParenToken;
insertBefore = findChildOfKind(containingFunction, kind, sourceFile) || first(containingFunction.parameters);
break;
default:
return;
+14 -8
View File
@@ -268,7 +268,7 @@ namespace ts.codefix {
}
export function getImportCompletionAction(
exportedSymbol: Symbol,
targetSymbol: Symbol,
moduleSymbol: Symbol,
sourceFile: SourceFile,
symbolName: string,
@@ -280,8 +280,8 @@ namespace ts.codefix {
): { readonly moduleSpecifier: string, readonly codeAction: CodeAction } {
const compilerOptions = program.getCompilerOptions();
const exportInfos = pathIsBareSpecifier(stripQuotes(moduleSymbol.name))
? [getSymbolExportInfoForSymbol(exportedSymbol, moduleSymbol, program, host)]
: getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, host, program, preferences, /*useAutoImportProvider*/ true);
? [getSymbolExportInfoForSymbol(targetSymbol, moduleSymbol, program, host)]
: getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, host, program, preferences, /*useAutoImportProvider*/ true);
const useRequire = shouldUseRequire(sourceFile, program);
const isValidTypeOnlyUseSite = isValidTypeOnlyAliasUseSite(getTokenAtPosition(sourceFile, position));
const fix = Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
@@ -326,7 +326,7 @@ namespace ts.codefix {
}
}
function getAllReExportingModules(importingFile: SourceFile, exportedSymbol: Symbol, exportingModuleSymbol: Symbol, symbolName: string, host: LanguageServiceHost, program: Program, preferences: UserPreferences, useAutoImportProvider: boolean): readonly SymbolExportInfo[] {
function getAllReExportingModules(importingFile: SourceFile, targetSymbol: Symbol, exportingModuleSymbol: Symbol, symbolName: string, host: LanguageServiceHost, program: Program, preferences: UserPreferences, useAutoImportProvider: boolean): readonly SymbolExportInfo[] {
const result: SymbolExportInfo[] = [];
const compilerOptions = program.getCompilerOptions();
const getModuleSpecifierResolutionHost = memoizeOne((isFromPackageJson: boolean) => {
@@ -341,12 +341,12 @@ namespace ts.codefix {
}
const defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, getEmitScriptTarget(compilerOptions)) === symbolName) && skipAlias(defaultInfo.symbol, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, getEmitScriptTarget(compilerOptions)) === symbolName) && skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
result.push({ symbol: defaultInfo.symbol, moduleSymbol, moduleFileName: moduleFile?.fileName, exportKind: defaultInfo.exportKind, targetFlags: skipAlias(defaultInfo.symbol, checker).flags, isFromPackageJson });
}
for (const exported of checker.getExportsAndPropertiesOfModule(moduleSymbol)) {
if (exported.name === symbolName && skipAlias(exported, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
if (exported.name === symbolName && checker.getMergedSymbol(skipAlias(exported, checker)) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
result.push({ symbol: exported, moduleSymbol, moduleFileName: moduleFile?.fileName, exportKind: ExportKind.Named, targetFlags: skipAlias(exported, checker).flags, isFromPackageJson });
}
}
@@ -663,13 +663,15 @@ namespace ts.codefix {
}
const { allowsImportingSpecifier } = createPackageJsonImportFilter(sourceFile, preferences, host);
return fixes.reduce((best, fix) =>
// Takes true branch of conditional if `fix` is better than `best`
compareModuleSpecifiers(fix, best, sourceFile, program, allowsImportingSpecifier) === Comparison.LessThan ? fix : best
);
}
/** @returns `Comparison.LessThan` if `a` is better than `b`. */
function compareModuleSpecifiers(a: ImportFix, b: ImportFix, importingFile: SourceFile, program: Program, allowsImportingSpecifier: (specifier: string) => boolean): Comparison {
if (a.kind !== ImportFixKind.UseNamespace && b.kind !== ImportFixKind.UseNamespace) {
return compareBooleans(allowsImportingSpecifier(a.moduleSpecifier), allowsImportingSpecifier(b.moduleSpecifier))
return compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
|| compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
|| compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
}
@@ -766,9 +768,13 @@ namespace ts.codefix {
return { fixes, symbolName };
}
function jsxModeNeedsExplicitImport(jsx: JsxEmit | undefined) {
return jsx === JsxEmit.React || jsx === JsxEmit.ReactNative;
}
function getSymbolName(sourceFile: SourceFile, checker: TypeChecker, symbolToken: Identifier, compilerOptions: CompilerOptions): string {
const parent = symbolToken.parent;
if ((isJsxOpeningLikeElement(parent) || isJsxClosingElement(parent)) && parent.tagName === symbolToken && compilerOptions.jsx !== JsxEmit.ReactJSX && compilerOptions.jsx !== JsxEmit.ReactJSXDev) {
if ((isJsxOpeningLikeElement(parent) || isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
const jsxNamespace = checker.getJsxNamespace(sourceFile);
if (isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, SymbolFlags.Value, /*excludeGlobals*/ true)) {
return jsxNamespace;
+16 -9
View File
@@ -1183,9 +1183,9 @@ namespace ts.Completions {
const checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider!()!.getTypeChecker() : program.getTypeChecker();
const { moduleSymbol } = origin;
const exportedSymbol = checker.getMergedSymbol(skipAlias(symbol.exportSymbol || symbol, checker));
const targetSymbol = checker.getMergedSymbol(skipAlias(symbol.exportSymbol || symbol, checker));
const { moduleSpecifier, codeAction } = codefix.getImportCompletionAction(
exportedSymbol,
targetSymbol,
moduleSymbol,
sourceFile,
getNameForExportedSymbol(symbol, getEmitScriptTarget(compilerOptions)),
@@ -1993,10 +1993,10 @@ namespace ts.Completions {
if (isNonContextualObjectLiteral) return false;
// If not already a module, must have modules enabled.
if (!preferences.includeCompletionsForModuleExports) return false;
// If already using ES6 modules, OK to continue using them.
// If already using ES modules, OK to continue using them.
if (sourceFile.externalModuleIndicator || sourceFile.commonJsModuleIndicator) return true;
// If module transpilation is enabled or we're targeting es6 or above, or not emitting, OK.
if (compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) return true;
if (compilerOptionsIndicateEsModules(program.getCompilerOptions())) return true;
// If some file is using ES6 modules, assume that it's OK to add more.
return programContainsModules(program);
}
@@ -2209,8 +2209,9 @@ namespace ts.Completions {
function isNewIdentifierDefinitionLocation(): boolean {
if (contextToken) {
const containingNodeKind = contextToken.parent.kind;
const tokenKind = keywordForNode(contextToken);
// Previous token may have been a keyword that was converted to an identifier.
switch (keywordForNode(contextToken)) {
switch (tokenKind) {
case SyntaxKind.CommaToken:
return containingNodeKind === SyntaxKind.CallExpression // func( a, |
|| containingNodeKind === SyntaxKind.Constructor // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */
@@ -2254,10 +2255,16 @@ namespace ts.Completions {
case SyntaxKind.TemplateMiddle:
return containingNodeKind === SyntaxKind.TemplateSpan; // `aa ${10} dd ${|
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.ProtectedKeyword:
return containingNodeKind === SyntaxKind.PropertyDeclaration; // class A{ public |
case SyntaxKind.AsyncKeyword:
return containingNodeKind === SyntaxKind.MethodDeclaration // const obj = { async c|()
|| containingNodeKind === SyntaxKind.ShorthandPropertyAssignment; // const obj = { async c|
case SyntaxKind.AsteriskToken:
return containingNodeKind === SyntaxKind.MethodDeclaration; // const obj = { * c|
}
if (isClassMemberCompletionKeyword(tokenKind)) {
return true;
}
}
+10 -6
View File
@@ -79,10 +79,14 @@ namespace ts {
}
const isDefault = exportKind === ExportKind.Default;
const namedSymbol = isDefault && getLocalSymbolForExportDefault(symbol) || symbol;
// A re-export merged with an export from a module augmentation can result in `symbol`
// being an external module symbol; the name it is re-exported by will be `symbolTableKey`
// (which comes from the keys of `moduleSymbol.exports`.)
const importedName = isExternalModuleSymbol(namedSymbol)
// 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`.
// 2. A re-export merged with an export from a module augmentation can result in `symbol`
// being an external module symbol; the name it is re-exported by will be `symbolTableKey`
// (which comes from the keys of `moduleSymbol.exports`.)
// 3. Otherwise, we have a default/namespace import that can be imported by any name, and
// `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to
// get a better name.
const importedName = exportKind === ExportKind.Named || isExternalModuleSymbol(namedSymbol)
? unescapeLeadingUnderscores(symbolTableKey)
: getNameForExportedSymbol(namedSymbol, scriptTarget);
const moduleName = stripQuotes(moduleSymbol.name);
@@ -321,7 +325,7 @@ namespace ts {
let moduleCount = 0;
forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, (moduleSymbol, moduleFile, program, isFromPackageJson) => {
if (++moduleCount % 100 === 0) cancellationToken?.throwIfCancellationRequested();
const seenExports = new Map<Symbol, true>();
const seenExports = new Map<__String, true>();
const checker = program.getTypeChecker();
const defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
// Note: I think we shouldn't actually see resolved module symbols here, but weird merges
@@ -339,7 +343,7 @@ namespace ts {
checker);
}
checker.forEachExportAndPropertyOfModule(moduleSymbol, (exported, key) => {
if (exported !== defaultInfo?.symbol && isImportableSymbol(exported, checker) && addToSeen(seenExports, exported)) {
if (exported !== defaultInfo?.symbol && isImportableSymbol(exported, checker) && addToSeen(seenExports, key)) {
cache.add(
importingFile.path,
exported,
+7 -7
View File
@@ -138,9 +138,9 @@ namespace ts.refactor {
return [...prologueDirectives, ...toMove.all];
}
const useEs6ModuleSyntax = !!oldFile.externalModuleIndicator;
const useEsModuleSyntax = !!oldFile.externalModuleIndicator;
const quotePreference = getQuotePreference(oldFile, preferences);
const importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax, quotePreference);
const importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEsModuleSyntax, quotePreference);
if (importsFromNewFile) {
insertImports(changes, oldFile, importsFromNewFile, /*blankLineBetween*/ true);
}
@@ -149,8 +149,8 @@ namespace ts.refactor {
deleteMovedStatements(oldFile, toMove.ranges, changes);
updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName);
const imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference);
const body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax);
const imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEsModuleSyntax, quotePreference);
const body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax);
if (imports.length && body.length) {
return [
...prologueDirectives,
@@ -429,7 +429,7 @@ namespace ts.refactor {
newFileImportsFromOldFile: ReadonlySymbolSet,
changes: textChanges.ChangeTracker,
checker: TypeChecker,
useEs6ModuleSyntax: boolean,
useEsModuleSyntax: boolean,
quotePreference: QuotePreference,
): readonly SupportedImportStatement[] {
const copiedOldImports: SupportedImportStatement[] = [];
@@ -454,7 +454,7 @@ namespace ts.refactor {
const top = getTopLevelDeclarationStatement(decl);
if (markSeenTop(top)) {
addExportToChanges(oldFile, top, name, changes, useEs6ModuleSyntax);
addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax);
}
if (hasSyntacticModifier(decl, ModifierFlags.Default)) {
oldFileDefault = name;
@@ -465,7 +465,7 @@ namespace ts.refactor {
}
});
append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, removeFileExtension(getBaseFileName(oldFile.fileName)), useEs6ModuleSyntax, quotePreference));
append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, removeFileExtension(getBaseFileName(oldFile.fileName)), useEsModuleSyntax, quotePreference));
return copiedOldImports;
}
+6 -4
View File
@@ -6,11 +6,13 @@ namespace ts {
program.getSemanticDiagnostics(sourceFile, cancellationToken);
const diags: DiagnosticWithLocation[] = [];
const checker = program.getTypeChecker();
const isCommonJSFile = sourceFile.impliedNodeFormat === ModuleKind.CommonJS || fileExtensionIsOneOf(sourceFile.fileName, [Extension.Cts, Extension.Cjs]) ;
if (sourceFile.commonJsModuleIndicator &&
(programContainsEs6Modules(program) || compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) &&
if (!isCommonJSFile &&
sourceFile.commonJsModuleIndicator &&
(programContainsEsModules(program) || compilerOptionsIndicateEsModules(program.getCompilerOptions())) &&
containsTopLevelCommonjs(sourceFile)) {
diags.push(createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module));
diags.push(createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module));
}
const isJsFile = isSourceFileJS(sourceFile);
@@ -64,7 +66,7 @@ namespace ts {
}
}
// convertToEs6Module only works on top-level, so don't trigger it if commonjs code only appears in nested scopes.
// convertToEsModule only works on top-level, so don't trigger it if commonjs code only appears in nested scopes.
function containsTopLevelCommonjs(sourceFile: SourceFile): boolean {
return sourceFile.statements.some(statement => {
switch (statement.kind) {
+1 -1
View File
@@ -61,7 +61,7 @@
"codefixes/annotateWithTypeFromJSDoc.ts",
"codefixes/convertFunctionToEs6Class.ts",
"codefixes/convertToAsyncFunction.ts",
"codefixes/convertToEs6Module.ts",
"codefixes/convertToEsModule.ts",
"codefixes/correctQualifiedNameToIndexedAccessType.ts",
"codefixes/convertToTypeOnlyExport.ts",
"codefixes/convertToTypeOnlyImport.ts",
+24 -7
View File
@@ -1897,10 +1897,10 @@ namespace ts {
export function programContainsModules(program: Program): boolean {
return program.getSourceFiles().some(s => !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!(s.externalModuleIndicator || s.commonJsModuleIndicator));
}
export function programContainsEs6Modules(program: Program): boolean {
export function programContainsEsModules(program: Program): boolean {
return program.getSourceFiles().some(s => !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!s.externalModuleIndicator);
}
export function compilerOptionsIndicateEs6Modules(compilerOptions: CompilerOptions): boolean {
export function compilerOptionsIndicateEsModules(compilerOptions: CompilerOptions): boolean {
return !!compilerOptions.module || getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 || !!compilerOptions.noEmit;
}
@@ -2290,9 +2290,9 @@ namespace ts {
return displayPart(text, SymbolDisplayPartKind.linkText);
}
export function linkNamePart(name: EntityName | JSDocMemberName, target: Declaration): JSDocLinkDisplayPart {
export function linkNamePart(text: string, target: Declaration): JSDocLinkDisplayPart {
return {
text: getTextOfNode(name),
text,
kind: SymbolDisplayPartKind[SymbolDisplayPartKind.linkName],
target: {
fileName: getSourceFileOfNode(target).fileName,
@@ -2315,19 +2315,36 @@ namespace ts {
}
else {
const symbol = checker?.getSymbolAtLocation(link.name);
const suffix = findLinkNameEnd(link.text);
const name = getTextOfNode(link.name) + link.text.slice(0, suffix);
const text = link.text.slice(suffix);
const decl = symbol?.valueDeclaration || symbol?.declarations?.[0];
if (decl) {
parts.push(linkNamePart(link.name, decl));
if (link.text) parts.push(linkTextPart(link.text));
parts.push(linkNamePart(name, decl));
if (text) parts.push(linkTextPart(text));
}
else {
parts.push(linkTextPart(getTextOfNode(link.name) + " " + link.text));
parts.push(linkTextPart(name + (suffix ? "" : " ") + text));
}
}
parts.push(linkPart("}"));
return parts;
}
function findLinkNameEnd(text: string) {
if (text.indexOf("()") === 0) return 2;
if (text[0] !== "<") return 0;
let brackets = 0;
let i = 0;
while (i < text.length) {
if (text[i] === "<") brackets++;
if (text[i] === ">") brackets--;
i++;
if (!brackets) return i;
}
return 0;
}
const carriageReturnLineFeed = "\r\n";
/**
* The default is CRLF.
+2
View File
@@ -100,6 +100,7 @@
"unittests/evaluation/optionalCall.ts",
"unittests/evaluation/objectRest.ts",
"unittests/evaluation/superInStaticInitializer.ts",
"unittests/evaluation/templateLiteral.ts",
"unittests/evaluation/updateExpressionInModule.ts",
"unittests/services/cancellableLanguageServiceOperations.ts",
"unittests/services/colorization.ts",
@@ -157,6 +158,7 @@
"unittests/tsc/runWithoutArgs.ts",
"unittests/tscWatch/consoleClearing.ts",
"unittests/tscWatch/emit.ts",
"unittests/tscWatch/nodeNextWatch.ts",
"unittests/tscWatch/emitAndErrorUpdates.ts",
"unittests/tscWatch/forceConsistentCasingInFileNames.ts",
"unittests/tscWatch/incremental.ts",
@@ -526,7 +526,7 @@ namespace ts {
nonNullValue,
diagnosticMessage: Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line,
workerDiagnostic: () => {
const optionDeclarations = [
const optionDeclarations: CommandLineOption[] = [
...compilerOptionsDidYouMeanDiagnostics.optionDeclarations,
{
name: "optionName",
@@ -534,6 +534,7 @@ namespace ts {
isTSConfigOnly: true,
category: Diagnostics.Backwards_Compatibility,
description: Diagnostics.Enable_project_compilation,
defaultValueDescription: "undefined",
}
];
return {
@@ -0,0 +1,40 @@
describe("unittests:: evaluation:: templateLiteral", () => {
it("toString() over valueOf()", () => {
const result = evaluator.evaluateTypeScript(`
class C {
toString() {
return "toString";
}
valueOf() {
return "valueOf";
}
}
export const output = \`\${new C}\`;
`);
assert.strictEqual(result.output, "toString");
});
it("correct evaluation order", () => {
const result = evaluator.evaluateTypeScript(`
class C {
counter: number;
constructor() {
this.counter = 0;
}
get foo() {
this.counter++;
return {
toString: () => this.counter++,
};
}
}
const c = new C;
export const output = \`\${c.foo} \${c.foo}\`;
`);
assert.strictEqual(result.output, "1 3");
});
});
+31
View File
@@ -182,3 +182,34 @@ describe("unittests:: Public APIs:: getChild* methods on EndOfFileToken with JSD
assert.equal(endOfFileToken.getChildCount(), 1);
assert.notEqual(endOfFileToken.getChildAt(0), /*expected*/ undefined);
});
describe("unittests:: Public APIs:: sys", () => {
it("readDirectory", () => {
// #45990, testing passing a non-absolute path
// `sys.readDirectory` is just `matchFiles` plugged into the real FS
const read = ts.matchFiles(
/*path*/ "",
/*extensions*/ [".ts", ".tsx"],
/*excludes*/ ["node_modules", "dist"],
/*includes*/ ["**/*"],
/*useCaseSensitiveFileNames*/ true,
/*currentDirectory*/ "/",
/*depth*/ undefined,
/*getFileSystemEntries*/ path => {
switch (path) {
case "/": return { directories: [], files: ["file.ts"] };
default: return { directories: [], files: [] };
}
},
/*realpath*/ ts.identity,
/*directoryExists*/ path => {
switch (path) {
case "/": return true;
default: return false;
}
}
);
assert.deepEqual(read, ["/file.ts"]);
});
});
@@ -0,0 +1,58 @@
namespace ts.tscWatch {
describe("unittests:: tsc-watch:: nodeNextWatch:: emit when module emit is specified as nodenext", () => {
verifyTscWatch({
scenario: "nodenext watch emit",
subScenario: "esm-mode file is edited",
commandLineArgs: ["--w", "--p", "/project/tsconfig.json"],
sys: () => {
const configFile: File = {
path: "/project/tsconfig.json",
content: JSON.stringify({
compilerOptions: {
strict: true,
target: "es2020",
module: "nodenext",
moduleResolution: "nodenext",
outDir: "../dist"
}
})
};
const packageFile: File = {
path: "/project/package.json",
content: JSON.stringify({
name: "some-proj",
version: "1.0.0",
description: "",
type: "module",
main: "index.js",
})
};
const file1: File = {
path: "/project/src/index.ts",
content: Utils.dedent`
import * as Thing from "thing";
Thing.fn();`
};
const declFile: File = {
path: "/project/src/deps.d.ts",
content: `declare module "thing";`
};
return createWatchedSystem([configFile, file1, declFile, packageFile, { ...libFile, path: "/a/lib/lib.es2020.full.d.ts" }]);
},
changes: [
{
caption: "Modify typescript file",
change: sys => sys.modifyFile(
"/project/src/index.ts",
Utils.dedent`
import * as Thing from "thing";
Thing.fn();`,
{},
),
timeouts: runQueuedTimeoutCallbacks,
}
],
});
});
}
+1 -1
View File
@@ -78,7 +78,7 @@ namespace ts.server {
};
// Do this after sys has been set as findArguments is going to work only then
const sys = server.createWebSystem(webHost, args, () => findArgument("--executingFilePath") || location + "");
ts.sys = sys;
setSys(sys);
const localeStr = findArgument("--locale");
if (localeStr) {
validateLocaleAndSetLanguage(localeStr, sys);
@@ -66,10 +66,10 @@ function compile(fileNames, options) {
return;
}
var _a = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start), line = _a.line, character = _a.character;
console.log(diagnostic.file.fileName + " (" + (line + 1) + "," + (character + 1) + "): " + message);
console.log("".concat(diagnostic.file.fileName, " (").concat(line + 1, ",").concat(character + 1, "): ").concat(message));
});
var exitCode = emitResult.emitSkipped ? 1 : 0;
console.log("Process exiting with code '" + exitCode + "'.");
console.log("Process exiting with code '".concat(exitCode, "'."));
process.exit(exitCode);
}
exports.compile = compile;
@@ -114,7 +114,7 @@ function delint(sourceFile) {
}
function report(node, message) {
var _a = sourceFile.getLineAndCharacterOfPosition(node.getStart()), line = _a.line, character = _a.character;
console.log(sourceFile.fileName + " (" + (line + 1) + "," + (character + 1) + "): " + message);
console.log("".concat(sourceFile.fileName, " (").concat(line + 1, ",").concat(character + 1, "): ").concat(message));
}
}
exports.delint = delint;
@@ -56,7 +56,7 @@ function printError(error) {
if (!error) {
return;
}
console.log((error.file && error.file.fileName) + ": " + error.messageText);
console.log("".concat(error.file && error.file.fileName, ": ").concat(error.messageText));
}
function createProgram(rootFiles, compilerOptionsJson) {
var _a = ts.parseConfigFileTextToJson("tsconfig.json", compilerOptionsJson), config = _a.config, error = _a.error;
@@ -166,10 +166,10 @@ function watch(rootFileNames, options) {
function emitFile(fileName) {
var output = services.getEmitOutput(fileName);
if (!output.emitSkipped) {
console.log("Emitting " + fileName);
console.log("Emitting ".concat(fileName));
}
else {
console.log("Emitting " + fileName + " failed");
console.log("Emitting ".concat(fileName, " failed"));
logErrors(fileName);
}
output.outputFiles.forEach(function (o) {
@@ -184,10 +184,10 @@ function watch(rootFileNames, options) {
var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
if (diagnostic.file) {
var _a = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start), line = _a.line, character = _a.character;
console.log(" Error " + diagnostic.file.fileName + " (" + (line + 1) + "," + (character + 1) + "): " + message);
console.log(" Error ".concat(diagnostic.file.fileName, " (").concat(line + 1, ",").concat(character + 1, "): ").concat(message));
}
else {
console.log(" Error: " + message);
console.log(" Error: ".concat(message));
}
});
}
@@ -2,4 +2,4 @@
var v = `foo ${ a
//// [TemplateExpression1.js]
var v = "foo " + a;
var v = "foo ".concat(a);
+6 -4
View File
@@ -973,6 +973,8 @@ declare namespace ts {
readonly nameType?: TypeNode;
readonly questionToken?: QuestionToken | PlusToken | MinusToken;
readonly type?: TypeNode;
/** Used only to produce grammar errors */
readonly members?: NodeArray<TypeElement>;
}
export interface LiteralTypeNode extends TypeNode {
readonly kind: SyntaxKind.LiteralType;
@@ -3421,8 +3423,8 @@ declare namespace ts {
updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode;
createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
createMappedTypeNode(readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode;
updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode;
createMappedTypeNode(readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: NodeArray<TypeElement> | undefined): MappedTypeNode;
updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: NodeArray<TypeElement> | undefined): MappedTypeNode;
createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode;
updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode;
createTemplateLiteralType(head: TemplateHead, templateSpans: readonly TemplateLiteralTypeSpan[]): TemplateLiteralTypeNode;
@@ -10781,9 +10783,9 @@ declare namespace ts {
/** @deprecated Use `factory.updateIndexedAccessTypeNode` or the factory supplied by your transformation context instead. */
const updateIndexedAccessTypeNode: (node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode) => IndexedAccessTypeNode;
/** @deprecated Use `factory.createMappedTypeNode` or the factory supplied by your transformation context instead. */
const createMappedTypeNode: (readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined) => MappedTypeNode;
const createMappedTypeNode: (readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: NodeArray<TypeElement> | undefined) => MappedTypeNode;
/** @deprecated Use `factory.updateMappedTypeNode` or the factory supplied by your transformation context instead. */
const updateMappedTypeNode: (node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined) => MappedTypeNode;
const updateMappedTypeNode: (node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: NodeArray<TypeElement> | undefined) => MappedTypeNode;
/** @deprecated Use `factory.createLiteralTypeNode` or the factory supplied by your transformation context instead. */
const createLiteralTypeNode: (literal: LiteralExpression | BooleanLiteral | PrefixUnaryExpression | NullLiteral) => LiteralTypeNode;
/** @deprecated Use `factory.updateLiteralTypeNode` or the factory supplied by your transformation context instead. */
+6 -4
View File
@@ -973,6 +973,8 @@ declare namespace ts {
readonly nameType?: TypeNode;
readonly questionToken?: QuestionToken | PlusToken | MinusToken;
readonly type?: TypeNode;
/** Used only to produce grammar errors */
readonly members?: NodeArray<TypeElement>;
}
export interface LiteralTypeNode extends TypeNode {
readonly kind: SyntaxKind.LiteralType;
@@ -3421,8 +3423,8 @@ declare namespace ts {
updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode;
createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
createMappedTypeNode(readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode;
updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode;
createMappedTypeNode(readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: NodeArray<TypeElement> | undefined): MappedTypeNode;
updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: NodeArray<TypeElement> | undefined): MappedTypeNode;
createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode;
updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode;
createTemplateLiteralType(head: TemplateHead, templateSpans: readonly TemplateLiteralTypeSpan[]): TemplateLiteralTypeNode;
@@ -6979,9 +6981,9 @@ declare namespace ts {
/** @deprecated Use `factory.updateIndexedAccessTypeNode` or the factory supplied by your transformation context instead. */
const updateIndexedAccessTypeNode: (node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode) => IndexedAccessTypeNode;
/** @deprecated Use `factory.createMappedTypeNode` or the factory supplied by your transformation context instead. */
const createMappedTypeNode: (readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined) => MappedTypeNode;
const createMappedTypeNode: (readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: NodeArray<TypeElement> | undefined) => MappedTypeNode;
/** @deprecated Use `factory.updateMappedTypeNode` or the factory supplied by your transformation context instead. */
const updateMappedTypeNode: (node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined) => MappedTypeNode;
const updateMappedTypeNode: (node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: NodeArray<TypeElement> | undefined) => MappedTypeNode;
/** @deprecated Use `factory.createLiteralTypeNode` or the factory supplied by your transformation context instead. */
const createLiteralTypeNode: (literal: LiteralExpression | BooleanLiteral | PrefixUnaryExpression | NullLiteral) => LiteralTypeNode;
/** @deprecated Use `factory.updateLiteralTypeNode` or the factory supplied by your transformation context instead. */
@@ -0,0 +1,32 @@
/a.js(16,9): error TS18004: No value exists in scope for the shorthand property 'arguments'. Either declare one or provide an initializer.
==== /a.js (1 errors) ====
const a = () => {
return {
arguments: [],
};
};
const b = () => {
const c = {
arguments: [],
}
return c;
};
const c = () => {
return {
arguments,
~~~~~~~~~
!!! error TS18004: No value exists in scope for the shorthand property 'arguments'. Either declare one or provide an initializer.
};
}
const d = () => {
const arguments = undefined;
return {
arguments,
};
}
@@ -0,0 +1,51 @@
//// [a.js]
const a = () => {
return {
arguments: [],
};
};
const b = () => {
const c = {
arguments: [],
}
return c;
};
const c = () => {
return {
arguments,
};
}
const d = () => {
const arguments = undefined;
return {
arguments,
};
}
//// [a.js]
const a = () => {
return {
arguments: [],
};
};
const b = () => {
const c = {
arguments: [],
};
return c;
};
const c = () => {
return {
arguments,
};
};
const d = () => {
const arguments = undefined;
return {
arguments,
};
};
@@ -0,0 +1,49 @@
=== /a.js ===
const a = () => {
>a : Symbol(a, Decl(a.js, 0, 5))
return {
arguments: [],
>arguments : Symbol(arguments, Decl(a.js, 1, 12))
};
};
const b = () => {
>b : Symbol(b, Decl(a.js, 6, 5))
const c = {
>c : Symbol(c, Decl(a.js, 7, 9))
arguments: [],
>arguments : Symbol(arguments, Decl(a.js, 7, 15))
}
return c;
>c : Symbol(c, Decl(a.js, 7, 9))
};
const c = () => {
>c : Symbol(c, Decl(a.js, 13, 5))
return {
arguments,
>arguments : Symbol(arguments, Decl(a.js, 14, 12))
};
}
const d = () => {
>d : Symbol(d, Decl(a.js, 19, 5))
const arguments = undefined;
>arguments : Symbol(arguments, Decl(a.js, 20, 9))
>undefined : Symbol(undefined)
return {
arguments,
>arguments : Symbol(arguments, Decl(a.js, 21, 12))
};
}
@@ -0,0 +1,62 @@
=== /a.js ===
const a = () => {
>a : () => { arguments: any[]; }
>() => { return { arguments: [], };} : () => { arguments: any[]; }
return {
>{ arguments: [], } : { arguments: undefined[]; }
arguments: [],
>arguments : undefined[]
>[] : undefined[]
};
};
const b = () => {
>b : () => { arguments: any[]; }
>() => { const c = { arguments: [], } return c;} : () => { arguments: any[]; }
const c = {
>c : { arguments: any[]; }
>{ arguments: [], } : { arguments: undefined[]; }
arguments: [],
>arguments : undefined[]
>[] : undefined[]
}
return c;
>c : { arguments: any[]; }
};
const c = () => {
>c : () => { arguments: any; }
>() => { return { arguments, };} : () => { arguments: any; }
return {
>{ arguments, } : { arguments: any; }
arguments,
>arguments : any
};
}
const d = () => {
>d : () => { arguments: any; }
>() => { const arguments = undefined; return { arguments, };} : () => { arguments: any; }
const arguments = undefined;
>arguments : any
>undefined : undefined
return {
>{ arguments, } : { arguments: any; }
arguments,
>arguments : any
};
}
+5 -5
View File
@@ -15,11 +15,11 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
var a = "" + (123 + 456);
var b = "leading " + (123 + 456);
var c = 123 + 456 + " trailing";
var d = "Hello " + 123 + " World";
var a = "".concat(123 + 456);
var b = "leading ".concat(123 + 456);
var c = "".concat(123 + 456, " trailing");
var d = "Hello ".concat(123, " World");
var e = "Hello";
var f = 1 + (1 + " end of string");
var f = 1 + "".concat(1, " end of string");
var g = tag(__makeTemplateObject(["Hello ", " World"], ["Hello ", " World"]), 123);
var h = tag(__makeTemplateObject(["Hello"], ["Hello"]));
@@ -16,7 +16,7 @@ stringIndex[s].toFixed();
// @ts-check
var _a, _b;
var n = Math.random();
var s = "" + n;
var s = "".concat(n);
var numericIndex = (_a = {}, _a[n] = 1, _a);
numericIndex[n].toFixed();
var stringIndex = (_b = {}, _b[s] = 1, _b);
@@ -19,8 +19,8 @@ var MyClass = /** @class */ (function () {
function MyClass() {
var variable = 'something';
this.property = "foo"; // Correctly inferred as `string`
this.property2 = "foo-" + variable; // Causes an error
var localProperty = "foo-" + variable; // Correctly inferred as `string`
this.property2 = "foo-".concat(variable); // Causes an error
var localProperty = "foo-".concat(variable); // Correctly inferred as `string`
}
return MyClass;
}());
@@ -0,0 +1,74 @@
//// [coAndContraVariantInferences.ts]
type A = { kind: 'a' };
type B = { kind: 'b' };
declare const a: A;
declare const b: B;
declare function fab(arg: A | B): void;
declare function foo<T>(x: { kind: T }, f: (arg: { kind: T }) => void): void;
foo(a, fab);
foo(b, fab);
// Repro from #45603
interface Action<TName extends string,TPayload> {
name: TName,
payload: TPayload
}
const actionA = { payload: 'any-string' } as Action<'ACTION_A', string>;
const actionB = { payload: true } as Action<'ACTION_B', boolean>;
function call<TName extends string,TPayload>(
action: Action<TName,TPayload>,
fn: (action: Action<TName,TPayload>)=> any,
) {
fn(action);
}
const printFn = (action: typeof actionA | typeof actionB)=> console.log(action);
call(actionA, printFn);
call(actionB, printFn);
//// [coAndContraVariantInferences.js]
"use strict";
foo(a, fab);
foo(b, fab);
var actionA = { payload: 'any-string' };
var actionB = { payload: true };
function call(action, fn) {
fn(action);
}
var printFn = function (action) { return console.log(action); };
call(actionA, printFn);
call(actionB, printFn);
//// [coAndContraVariantInferences.d.ts]
declare type A = {
kind: 'a';
};
declare type B = {
kind: 'b';
};
declare const a: A;
declare const b: B;
declare function fab(arg: A | B): void;
declare function foo<T>(x: {
kind: T;
}, f: (arg: {
kind: T;
}) => void): void;
interface Action<TName extends string, TPayload> {
name: TName;
payload: TPayload;
}
declare const actionA: Action<"ACTION_A", string>;
declare const actionB: Action<"ACTION_B", boolean>;
declare function call<TName extends string, TPayload>(action: Action<TName, TPayload>, fn: (action: Action<TName, TPayload>) => any): void;
declare const printFn: (action: typeof actionA | typeof actionB) => void;
@@ -0,0 +1,114 @@
=== tests/cases/compiler/coAndContraVariantInferences.ts ===
type A = { kind: 'a' };
>A : Symbol(A, Decl(coAndContraVariantInferences.ts, 0, 0))
>kind : Symbol(kind, Decl(coAndContraVariantInferences.ts, 0, 10))
type B = { kind: 'b' };
>B : Symbol(B, Decl(coAndContraVariantInferences.ts, 0, 23))
>kind : Symbol(kind, Decl(coAndContraVariantInferences.ts, 1, 10))
declare const a: A;
>a : Symbol(a, Decl(coAndContraVariantInferences.ts, 3, 13))
>A : Symbol(A, Decl(coAndContraVariantInferences.ts, 0, 0))
declare const b: B;
>b : Symbol(b, Decl(coAndContraVariantInferences.ts, 4, 13))
>B : Symbol(B, Decl(coAndContraVariantInferences.ts, 0, 23))
declare function fab(arg: A | B): void;
>fab : Symbol(fab, Decl(coAndContraVariantInferences.ts, 4, 19))
>arg : Symbol(arg, Decl(coAndContraVariantInferences.ts, 6, 21))
>A : Symbol(A, Decl(coAndContraVariantInferences.ts, 0, 0))
>B : Symbol(B, Decl(coAndContraVariantInferences.ts, 0, 23))
declare function foo<T>(x: { kind: T }, f: (arg: { kind: T }) => void): void;
>foo : Symbol(foo, Decl(coAndContraVariantInferences.ts, 6, 39))
>T : Symbol(T, Decl(coAndContraVariantInferences.ts, 8, 21))
>x : Symbol(x, Decl(coAndContraVariantInferences.ts, 8, 24))
>kind : Symbol(kind, Decl(coAndContraVariantInferences.ts, 8, 28))
>T : Symbol(T, Decl(coAndContraVariantInferences.ts, 8, 21))
>f : Symbol(f, Decl(coAndContraVariantInferences.ts, 8, 39))
>arg : Symbol(arg, Decl(coAndContraVariantInferences.ts, 8, 44))
>kind : Symbol(kind, Decl(coAndContraVariantInferences.ts, 8, 50))
>T : Symbol(T, Decl(coAndContraVariantInferences.ts, 8, 21))
foo(a, fab);
>foo : Symbol(foo, Decl(coAndContraVariantInferences.ts, 6, 39))
>a : Symbol(a, Decl(coAndContraVariantInferences.ts, 3, 13))
>fab : Symbol(fab, Decl(coAndContraVariantInferences.ts, 4, 19))
foo(b, fab);
>foo : Symbol(foo, Decl(coAndContraVariantInferences.ts, 6, 39))
>b : Symbol(b, Decl(coAndContraVariantInferences.ts, 4, 13))
>fab : Symbol(fab, Decl(coAndContraVariantInferences.ts, 4, 19))
// Repro from #45603
interface Action<TName extends string,TPayload> {
>Action : Symbol(Action, Decl(coAndContraVariantInferences.ts, 11, 12))
>TName : Symbol(TName, Decl(coAndContraVariantInferences.ts, 15, 17))
>TPayload : Symbol(TPayload, Decl(coAndContraVariantInferences.ts, 15, 38))
name: TName,
>name : Symbol(Action.name, Decl(coAndContraVariantInferences.ts, 15, 49))
>TName : Symbol(TName, Decl(coAndContraVariantInferences.ts, 15, 17))
payload: TPayload
>payload : Symbol(Action.payload, Decl(coAndContraVariantInferences.ts, 16, 16))
>TPayload : Symbol(TPayload, Decl(coAndContraVariantInferences.ts, 15, 38))
}
const actionA = { payload: 'any-string' } as Action<'ACTION_A', string>;
>actionA : Symbol(actionA, Decl(coAndContraVariantInferences.ts, 20, 5))
>payload : Symbol(payload, Decl(coAndContraVariantInferences.ts, 20, 17))
>Action : Symbol(Action, Decl(coAndContraVariantInferences.ts, 11, 12))
const actionB = { payload: true } as Action<'ACTION_B', boolean>;
>actionB : Symbol(actionB, Decl(coAndContraVariantInferences.ts, 21, 5))
>payload : Symbol(payload, Decl(coAndContraVariantInferences.ts, 21, 17))
>Action : Symbol(Action, Decl(coAndContraVariantInferences.ts, 11, 12))
function call<TName extends string,TPayload>(
>call : Symbol(call, Decl(coAndContraVariantInferences.ts, 21, 65))
>TName : Symbol(TName, Decl(coAndContraVariantInferences.ts, 23, 14))
>TPayload : Symbol(TPayload, Decl(coAndContraVariantInferences.ts, 23, 35))
action: Action<TName,TPayload>,
>action : Symbol(action, Decl(coAndContraVariantInferences.ts, 23, 45))
>Action : Symbol(Action, Decl(coAndContraVariantInferences.ts, 11, 12))
>TName : Symbol(TName, Decl(coAndContraVariantInferences.ts, 23, 14))
>TPayload : Symbol(TPayload, Decl(coAndContraVariantInferences.ts, 23, 35))
fn: (action: Action<TName,TPayload>)=> any,
>fn : Symbol(fn, Decl(coAndContraVariantInferences.ts, 24, 33))
>action : Symbol(action, Decl(coAndContraVariantInferences.ts, 25, 7))
>Action : Symbol(Action, Decl(coAndContraVariantInferences.ts, 11, 12))
>TName : Symbol(TName, Decl(coAndContraVariantInferences.ts, 23, 14))
>TPayload : Symbol(TPayload, Decl(coAndContraVariantInferences.ts, 23, 35))
) {
fn(action);
>fn : Symbol(fn, Decl(coAndContraVariantInferences.ts, 24, 33))
>action : Symbol(action, Decl(coAndContraVariantInferences.ts, 23, 45))
}
const printFn = (action: typeof actionA | typeof actionB)=> console.log(action);
>printFn : Symbol(printFn, Decl(coAndContraVariantInferences.ts, 30, 5))
>action : Symbol(action, Decl(coAndContraVariantInferences.ts, 30, 17))
>actionA : Symbol(actionA, Decl(coAndContraVariantInferences.ts, 20, 5))
>actionB : Symbol(actionB, Decl(coAndContraVariantInferences.ts, 21, 5))
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>action : Symbol(action, Decl(coAndContraVariantInferences.ts, 30, 17))
call(actionA, printFn);
>call : Symbol(call, Decl(coAndContraVariantInferences.ts, 21, 65))
>actionA : Symbol(actionA, Decl(coAndContraVariantInferences.ts, 20, 5))
>printFn : Symbol(printFn, Decl(coAndContraVariantInferences.ts, 30, 5))
call(actionB, printFn);
>call : Symbol(call, Decl(coAndContraVariantInferences.ts, 21, 65))
>actionB : Symbol(actionB, Decl(coAndContraVariantInferences.ts, 21, 5))
>printFn : Symbol(printFn, Decl(coAndContraVariantInferences.ts, 30, 5))
@@ -0,0 +1,104 @@
=== tests/cases/compiler/coAndContraVariantInferences.ts ===
type A = { kind: 'a' };
>A : A
>kind : "a"
type B = { kind: 'b' };
>B : B
>kind : "b"
declare const a: A;
>a : A
declare const b: B;
>b : B
declare function fab(arg: A | B): void;
>fab : (arg: A | B) => void
>arg : A | B
declare function foo<T>(x: { kind: T }, f: (arg: { kind: T }) => void): void;
>foo : <T>(x: { kind: T;}, f: (arg: { kind: T;}) => void) => void
>x : { kind: T; }
>kind : T
>f : (arg: { kind: T;}) => void
>arg : { kind: T; }
>kind : T
foo(a, fab);
>foo(a, fab) : void
>foo : <T>(x: { kind: T; }, f: (arg: { kind: T; }) => void) => void
>a : A
>fab : (arg: A | B) => void
foo(b, fab);
>foo(b, fab) : void
>foo : <T>(x: { kind: T; }, f: (arg: { kind: T; }) => void) => void
>b : B
>fab : (arg: A | B) => void
// Repro from #45603
interface Action<TName extends string,TPayload> {
name: TName,
>name : TName
payload: TPayload
>payload : TPayload
}
const actionA = { payload: 'any-string' } as Action<'ACTION_A', string>;
>actionA : Action<"ACTION_A", string>
>{ payload: 'any-string' } as Action<'ACTION_A', string> : Action<"ACTION_A", string>
>{ payload: 'any-string' } : { payload: string; }
>payload : string
>'any-string' : "any-string"
const actionB = { payload: true } as Action<'ACTION_B', boolean>;
>actionB : Action<"ACTION_B", boolean>
>{ payload: true } as Action<'ACTION_B', boolean> : Action<"ACTION_B", boolean>
>{ payload: true } : { payload: true; }
>payload : true
>true : true
function call<TName extends string,TPayload>(
>call : <TName extends string, TPayload>(action: Action<TName, TPayload>, fn: (action: Action<TName, TPayload>) => any) => void
action: Action<TName,TPayload>,
>action : Action<TName, TPayload>
fn: (action: Action<TName,TPayload>)=> any,
>fn : (action: Action<TName, TPayload>) => any
>action : Action<TName, TPayload>
) {
fn(action);
>fn(action) : any
>fn : (action: Action<TName, TPayload>) => any
>action : Action<TName, TPayload>
}
const printFn = (action: typeof actionA | typeof actionB)=> console.log(action);
>printFn : (action: typeof actionA | typeof actionB) => void
>(action: typeof actionA | typeof actionB)=> console.log(action) : (action: typeof actionA | typeof actionB) => void
>action : Action<"ACTION_A", string> | Action<"ACTION_B", boolean>
>actionA : Action<"ACTION_A", string>
>actionB : Action<"ACTION_B", boolean>
>console.log(action) : void
>console.log : (...data: any[]) => void
>console : Console
>log : (...data: any[]) => void
>action : Action<"ACTION_A", string> | Action<"ACTION_B", boolean>
call(actionA, printFn);
>call(actionA, printFn) : void
>call : <TName extends string, TPayload>(action: Action<TName, TPayload>, fn: (action: Action<TName, TPayload>) => any) => void
>actionA : Action<"ACTION_A", string>
>printFn : (action: Action<"ACTION_A", string> | Action<"ACTION_B", boolean>) => void
call(actionB, printFn);
>call(actionB, printFn) : void
>call : <TName extends string, TPayload>(action: Action<TName, TPayload>, fn: (action: Action<TName, TPayload>) => any) => void
>actionB : Action<"ACTION_B", boolean>
>printFn : (action: Action<"ACTION_A", string> | Action<"ACTION_B", boolean>) => void
@@ -9,16 +9,14 @@ tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.t
Type '"text" | "email"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
Type '"text"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
Type '"text"' is not assignable to type 'T & "text"'.
Type '"text"' is not assignable to type 'T'.
'"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'.
Type 'T' is not assignable to type 'T & "text"'.
Type '"text" | "email"' is not assignable to type 'T & "text"'.
Type '"text"' is not assignable to type 'T & "text"'.
Type '"text"' is not assignable to type 'T'.
'"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'.
Type 'T' is not assignable to type '"text"'.
Type '"text" | "email"' is not assignable to type '"text"'.
Type '"email"' is not assignable to type '"text"'.
Type 'T' is not assignable to type 'T & "text"'.
Type '"text" | "email"' is not assignable to type 'T & "text"'.
Type '"text"' is not assignable to type 'T & "text"'.
Type '"text"' is not assignable to type 'T'.
'"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'.
Type 'T' is not assignable to type '"text"'.
Type '"text" | "email"' is not assignable to type '"text"'.
Type '"email"' is not assignable to type '"text"'.
==== tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.ts (1 errors) ====
@@ -67,16 +65,14 @@ tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.t
!!! error TS2322: Type '"text" | "email"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
!!! error TS2322: Type '"text"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
!!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'.
!!! error TS2322: Type '"text"' is not assignable to type 'T'.
!!! error TS2322: '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'.
!!! error TS2322: Type 'T' is not assignable to type 'T & "text"'.
!!! error TS2322: Type '"text" | "email"' is not assignable to type 'T & "text"'.
!!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'.
!!! error TS2322: Type '"text"' is not assignable to type 'T'.
!!! error TS2322: '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'.
!!! error TS2322: Type 'T' is not assignable to type '"text"'.
!!! error TS2322: Type '"text" | "email"' is not assignable to type '"text"'.
!!! error TS2322: Type '"email"' is not assignable to type '"text"'.
!!! error TS2322: Type 'T' is not assignable to type 'T & "text"'.
!!! error TS2322: Type '"text" | "email"' is not assignable to type 'T & "text"'.
!!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'.
!!! error TS2322: Type '"text"' is not assignable to type 'T'.
!!! error TS2322: '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'.
!!! error TS2322: Type 'T' is not assignable to type '"text"'.
!!! error TS2322: Type '"text" | "email"' is not assignable to type '"text"'.
!!! error TS2322: Type '"email"' is not assignable to type '"text"'.
}
const newTextChannel = makeNewChannel('text');
@@ -32,5 +32,5 @@ var v = (_a = {},
_a[a] = function () { },
_a[true] = function () { },
_a["hello bye"] = function () { },
_a["hello " + a + " bye"] = function () { },
_a["hello ".concat(a, " bye")] = function () { },
_a);
@@ -72,7 +72,7 @@ var v = (_a = {},
enumerable: false,
configurable: true
}),
Object.defineProperty(_a, "hello " + a + " bye", {
Object.defineProperty(_a, "hello ".concat(a, " bye"), {
get: function () { return 0; },
enumerable: false,
configurable: true
@@ -27,7 +27,7 @@ var C = /** @class */ (function () {
this["hello bye"] = 0;
}
var _a, _b, _c;
_a = n, s + s, _b = s + n, +s, _c = "hello " + a + " bye";
_a = n, s + s, _b = s + n, +s, _c = "hello ".concat(a, " bye");
C[_c] = 0;
return C;
}());
@@ -33,6 +33,6 @@ var C = /** @class */ (function () {
C.prototype[a] = function () { };
C[true] = function () { };
C.prototype["hello bye"] = function () { };
C["hello " + a + " bye"] = function () { };
C["hello ".concat(a, " bye")] = function () { };
return C;
}());
@@ -73,7 +73,7 @@ var C = /** @class */ (function () {
enumerable: false,
configurable: true
});
Object.defineProperty(C.prototype, "hello " + a + " bye", {
Object.defineProperty(C.prototype, "hello ".concat(a, " bye"), {
get: function () { return 0; },
enumerable: false,
configurable: true
@@ -32,5 +32,5 @@ var v = (_a = {},
_a[a] = 1,
_a[true] = 0,
_a["hello bye"] = 0,
_a["hello " + a + " bye"] = 0,
_a["hello ".concat(a, " bye")] = 0,
_a);
+1 -1
View File
@@ -52,7 +52,7 @@ var E;
var y0 = E2[1];
var name = "A";
var y1 = E2[name];
var y2 = E2["" + name];
var y2 = E2["".concat(name)];
var x = E2;
var y = [E2];
function foo(t) {
@@ -220,4 +220,24 @@ tests/cases/conformance/controlFlow/controlFlowGenericTypes.ts(168,9): error TS2
this.validateRow(row);
}
}
// Repro from #46495
interface Button {
type: "button";
text: string;
}
interface Checkbox {
type: "checkbox";
isChecked: boolean;
}
type Control = Button | Checkbox;
function update<T extends Control, K extends keyof T>(control : T | undefined, key: K, value: T[K]): void {
if (control !== undefined) {
control[key] = value;
}
}
@@ -190,6 +190,26 @@ class SqlTable<T> {
this.validateRow(row);
}
}
// Repro from #46495
interface Button {
type: "button";
text: string;
}
interface Checkbox {
type: "checkbox";
isChecked: boolean;
}
type Control = Button | Checkbox;
function update<T extends Control, K extends keyof T>(control : T | undefined, key: K, value: T[K]): void {
if (control !== undefined) {
control[key] = value;
}
}
//// [controlFlowGenericTypes.js]
@@ -343,3 +363,8 @@ var SqlTable = /** @class */ (function () {
};
return SqlTable;
}());
function update(control, key, value) {
if (control !== undefined) {
control[key] = value;
}
}
@@ -574,3 +574,55 @@ class SqlTable<T> {
}
}
// Repro from #46495
interface Button {
>Button : Symbol(Button, Decl(controlFlowGenericTypes.ts, 190, 1))
type: "button";
>type : Symbol(Button.type, Decl(controlFlowGenericTypes.ts, 194, 18))
text: string;
>text : Symbol(Button.text, Decl(controlFlowGenericTypes.ts, 195, 19))
}
interface Checkbox {
>Checkbox : Symbol(Checkbox, Decl(controlFlowGenericTypes.ts, 197, 1))
type: "checkbox";
>type : Symbol(Checkbox.type, Decl(controlFlowGenericTypes.ts, 199, 20))
isChecked: boolean;
>isChecked : Symbol(Checkbox.isChecked, Decl(controlFlowGenericTypes.ts, 200, 21))
}
type Control = Button | Checkbox;
>Control : Symbol(Control, Decl(controlFlowGenericTypes.ts, 202, 1))
>Button : Symbol(Button, Decl(controlFlowGenericTypes.ts, 190, 1))
>Checkbox : Symbol(Checkbox, Decl(controlFlowGenericTypes.ts, 197, 1))
function update<T extends Control, K extends keyof T>(control : T | undefined, key: K, value: T[K]): void {
>update : Symbol(update, Decl(controlFlowGenericTypes.ts, 204, 33))
>T : Symbol(T, Decl(controlFlowGenericTypes.ts, 206, 16))
>Control : Symbol(Control, Decl(controlFlowGenericTypes.ts, 202, 1))
>K : Symbol(K, Decl(controlFlowGenericTypes.ts, 206, 34))
>T : Symbol(T, Decl(controlFlowGenericTypes.ts, 206, 16))
>control : Symbol(control, Decl(controlFlowGenericTypes.ts, 206, 54))
>T : Symbol(T, Decl(controlFlowGenericTypes.ts, 206, 16))
>key : Symbol(key, Decl(controlFlowGenericTypes.ts, 206, 78))
>K : Symbol(K, Decl(controlFlowGenericTypes.ts, 206, 34))
>value : Symbol(value, Decl(controlFlowGenericTypes.ts, 206, 86))
>T : Symbol(T, Decl(controlFlowGenericTypes.ts, 206, 16))
>K : Symbol(K, Decl(controlFlowGenericTypes.ts, 206, 34))
if (control !== undefined) {
>control : Symbol(control, Decl(controlFlowGenericTypes.ts, 206, 54))
>undefined : Symbol(undefined)
control[key] = value;
>control : Symbol(control, Decl(controlFlowGenericTypes.ts, 206, 54))
>key : Symbol(key, Decl(controlFlowGenericTypes.ts, 206, 78))
>value : Symbol(value, Decl(controlFlowGenericTypes.ts, 206, 86))
}
}
@@ -542,3 +542,44 @@ class SqlTable<T> {
}
}
// Repro from #46495
interface Button {
type: "button";
>type : "button"
text: string;
>text : string
}
interface Checkbox {
type: "checkbox";
>type : "checkbox"
isChecked: boolean;
>isChecked : boolean
}
type Control = Button | Checkbox;
>Control : Control
function update<T extends Control, K extends keyof T>(control : T | undefined, key: K, value: T[K]): void {
>update : <T extends Control, K extends keyof T>(control: T | undefined, key: K, value: T[K]) => void
>control : T | undefined
>key : K
>value : T[K]
if (control !== undefined) {
>control !== undefined : boolean
>control : T | undefined
>undefined : undefined
control[key] = value;
>control[key] = value : T[K]
>control[key] : T[K]
>control : T
>key : K
>value : T[K]
}
}
@@ -54,7 +54,7 @@ exports.CKind = exports.BKind = exports.AKind = void 0;
var kindCache = {};
function register(kind) {
if (kindCache[kind]) {
throw new Error("Class with kind \"" + kind + "\" is already registered.");
throw new Error("Class with kind \"".concat(kind, "\" is already registered."));
}
kindCache[kind] = true;
}
@@ -46,4 +46,23 @@ tests/cases/compiler/deepComparisons.ts(4,9): error TS2322: Type 'T[K1][K2]' is
function f3<U>() {
let x: Foo1<U> = 0 as any as Bar<U>; // No error!
}
}
// Repro from #46500
type F<T> = {} & (
T extends [any, ...any[]]
? { [K in keyof T]?: F<T[K]> }
: T extends any[]
? F<T[number]>[]
: T extends { [K: string]: any }
? { [K in keyof T]?: F<T[K]> }
: { x: string }
);
declare function f<T = any>(): F<T>;
function g() {
return f() as F<any>;
}
+23 -1
View File
@@ -17,7 +17,26 @@ type Foo2<T> = { x: Foo1<T> };
function f3<U>() {
let x: Foo1<U> = 0 as any as Bar<U>; // No error!
}
}
// Repro from #46500
type F<T> = {} & (
T extends [any, ...any[]]
? { [K in keyof T]?: F<T[K]> }
: T extends any[]
? F<T[number]>[]
: T extends { [K: string]: any }
? { [K in keyof T]?: F<T[K]> }
: { x: string }
);
declare function f<T = any>(): F<T>;
function g() {
return f() as F<any>;
}
//// [deepComparisons.js]
function f1() {
@@ -31,3 +50,6 @@ function f2() {
function f3() {
var x = 0; // No error!
}
function g() {
return f();
}
@@ -84,3 +84,57 @@ function f3<U>() {
>Bar : Symbol(Bar, Decl(deepComparisons.ts, 6, 28))
>U : Symbol(U, Decl(deepComparisons.ts, 16, 12))
}
// Repro from #46500
type F<T> = {} & (
>F : Symbol(F, Decl(deepComparisons.ts, 18, 1))
>T : Symbol(T, Decl(deepComparisons.ts, 22, 7))
T extends [any, ...any[]]
>T : Symbol(T, Decl(deepComparisons.ts, 22, 7))
? { [K in keyof T]?: F<T[K]> }
>K : Symbol(K, Decl(deepComparisons.ts, 24, 13))
>T : Symbol(T, Decl(deepComparisons.ts, 22, 7))
>F : Symbol(F, Decl(deepComparisons.ts, 18, 1))
>T : Symbol(T, Decl(deepComparisons.ts, 22, 7))
>K : Symbol(K, Decl(deepComparisons.ts, 24, 13))
: T extends any[]
>T : Symbol(T, Decl(deepComparisons.ts, 22, 7))
? F<T[number]>[]
>F : Symbol(F, Decl(deepComparisons.ts, 18, 1))
>T : Symbol(T, Decl(deepComparisons.ts, 22, 7))
: T extends { [K: string]: any }
>T : Symbol(T, Decl(deepComparisons.ts, 22, 7))
>K : Symbol(K, Decl(deepComparisons.ts, 27, 27))
? { [K in keyof T]?: F<T[K]> }
>K : Symbol(K, Decl(deepComparisons.ts, 28, 21))
>T : Symbol(T, Decl(deepComparisons.ts, 22, 7))
>F : Symbol(F, Decl(deepComparisons.ts, 18, 1))
>T : Symbol(T, Decl(deepComparisons.ts, 22, 7))
>K : Symbol(K, Decl(deepComparisons.ts, 28, 21))
: { x: string }
>x : Symbol(x, Decl(deepComparisons.ts, 29, 19))
);
declare function f<T = any>(): F<T>;
>f : Symbol(f, Decl(deepComparisons.ts, 30, 2))
>T : Symbol(T, Decl(deepComparisons.ts, 32, 19))
>F : Symbol(F, Decl(deepComparisons.ts, 18, 1))
>T : Symbol(T, Decl(deepComparisons.ts, 32, 19))
function g() {
>g : Symbol(g, Decl(deepComparisons.ts, 32, 36))
return f() as F<any>;
>f : Symbol(f, Decl(deepComparisons.ts, 30, 2))
>F : Symbol(F, Decl(deepComparisons.ts, 18, 1))
}
@@ -56,3 +56,34 @@ function f3<U>() {
>0 as any : any
>0 : 0
}
// Repro from #46500
type F<T> = {} & (
>F : F<T>
T extends [any, ...any[]]
? { [K in keyof T]?: F<T[K]> }
: T extends any[]
? F<T[number]>[]
: T extends { [K: string]: any }
>K : string
? { [K in keyof T]?: F<T[K]> }
: { x: string }
>x : string
);
declare function f<T = any>(): F<T>;
>f : <T = any>() => F<T>
function g() {
>g : () => F<any>
return f() as F<any>;
>f() as F<any> : F<any>
>f() : F<any>
>f : <T = any>() => F<T>
}
@@ -55,7 +55,7 @@ var Parent = function (_a) {
};
var Child = function (_a) {
var children = _a.children, _b = _a.name, name = _b === void 0 ? "Artemis" : _b, props = __rest(_a, ["children", "name"]);
return "name: " + name + " props: " + JSON.stringify(props);
return "name: ".concat(name, " props: ").concat(JSON.stringify(props));
};
f(function (_a) {
var _1 = _a[0], _b = _a[1], _2 = _b === void 0 ? undefined : _b;
@@ -0,0 +1,57 @@
//// [discriminatedUnionJsxElement.tsx]
// Repro from #46021
interface IData<MenuItemVariant extends ListItemVariant = ListItemVariant.OneLine> {
menuItemsVariant?: MenuItemVariant;
}
function Menu<MenuItemVariant extends ListItemVariant = ListItemVariant.OneLine>(data: IData<MenuItemVariant>) {
const listItemVariant = data.menuItemsVariant ?? ListItemVariant.OneLine;
return <ListItem variant={listItemVariant} />;
}
type IListItemData = { variant: ListItemVariant.Avatar; } | { variant: ListItemVariant.OneLine; };
enum ListItemVariant {
OneLine,
Avatar,
}
function ListItem(_data: IListItemData) {
return null;
}
//// [discriminatedUnionJsxElement.jsx]
"use strict";
// Repro from #46021
function Menu(data) {
var _a;
var listItemVariant = (_a = data.menuItemsVariant) !== null && _a !== void 0 ? _a : ListItemVariant.OneLine;
return <ListItem variant={listItemVariant}/>;
}
var ListItemVariant;
(function (ListItemVariant) {
ListItemVariant[ListItemVariant["OneLine"] = 0] = "OneLine";
ListItemVariant[ListItemVariant["Avatar"] = 1] = "Avatar";
})(ListItemVariant || (ListItemVariant = {}));
function ListItem(_data) {
return null;
}
//// [discriminatedUnionJsxElement.d.ts]
interface IData<MenuItemVariant extends ListItemVariant = ListItemVariant.OneLine> {
menuItemsVariant?: MenuItemVariant;
}
declare function Menu<MenuItemVariant extends ListItemVariant = ListItemVariant.OneLine>(data: IData<MenuItemVariant>): any;
declare type IListItemData = {
variant: ListItemVariant.Avatar;
} | {
variant: ListItemVariant.OneLine;
};
declare enum ListItemVariant {
OneLine = 0,
Avatar = 1
}
declare function ListItem(_data: IListItemData): null;
@@ -0,0 +1,67 @@
=== tests/cases/compiler/discriminatedUnionJsxElement.tsx ===
// Repro from #46021
interface IData<MenuItemVariant extends ListItemVariant = ListItemVariant.OneLine> {
>IData : Symbol(IData, Decl(discriminatedUnionJsxElement.tsx, 0, 0))
>MenuItemVariant : Symbol(MenuItemVariant, Decl(discriminatedUnionJsxElement.tsx, 2, 16))
>ListItemVariant : Symbol(ListItemVariant, Decl(discriminatedUnionJsxElement.tsx, 11, 98))
>ListItemVariant : Symbol(ListItemVariant, Decl(discriminatedUnionJsxElement.tsx, 11, 98))
>OneLine : Symbol(ListItemVariant.OneLine, Decl(discriminatedUnionJsxElement.tsx, 13, 22))
menuItemsVariant?: MenuItemVariant;
>menuItemsVariant : Symbol(IData.menuItemsVariant, Decl(discriminatedUnionJsxElement.tsx, 2, 84))
>MenuItemVariant : Symbol(MenuItemVariant, Decl(discriminatedUnionJsxElement.tsx, 2, 16))
}
function Menu<MenuItemVariant extends ListItemVariant = ListItemVariant.OneLine>(data: IData<MenuItemVariant>) {
>Menu : Symbol(Menu, Decl(discriminatedUnionJsxElement.tsx, 4, 1))
>MenuItemVariant : Symbol(MenuItemVariant, Decl(discriminatedUnionJsxElement.tsx, 6, 14))
>ListItemVariant : Symbol(ListItemVariant, Decl(discriminatedUnionJsxElement.tsx, 11, 98))
>ListItemVariant : Symbol(ListItemVariant, Decl(discriminatedUnionJsxElement.tsx, 11, 98))
>OneLine : Symbol(ListItemVariant.OneLine, Decl(discriminatedUnionJsxElement.tsx, 13, 22))
>data : Symbol(data, Decl(discriminatedUnionJsxElement.tsx, 6, 81))
>IData : Symbol(IData, Decl(discriminatedUnionJsxElement.tsx, 0, 0))
>MenuItemVariant : Symbol(MenuItemVariant, Decl(discriminatedUnionJsxElement.tsx, 6, 14))
const listItemVariant = data.menuItemsVariant ?? ListItemVariant.OneLine;
>listItemVariant : Symbol(listItemVariant, Decl(discriminatedUnionJsxElement.tsx, 7, 9))
>data.menuItemsVariant : Symbol(IData.menuItemsVariant, Decl(discriminatedUnionJsxElement.tsx, 2, 84))
>data : Symbol(data, Decl(discriminatedUnionJsxElement.tsx, 6, 81))
>menuItemsVariant : Symbol(IData.menuItemsVariant, Decl(discriminatedUnionJsxElement.tsx, 2, 84))
>ListItemVariant.OneLine : Symbol(ListItemVariant.OneLine, Decl(discriminatedUnionJsxElement.tsx, 13, 22))
>ListItemVariant : Symbol(ListItemVariant, Decl(discriminatedUnionJsxElement.tsx, 11, 98))
>OneLine : Symbol(ListItemVariant.OneLine, Decl(discriminatedUnionJsxElement.tsx, 13, 22))
return <ListItem variant={listItemVariant} />;
>ListItem : Symbol(ListItem, Decl(discriminatedUnionJsxElement.tsx, 16, 1))
>variant : Symbol(variant, Decl(discriminatedUnionJsxElement.tsx, 8, 20))
>listItemVariant : Symbol(listItemVariant, Decl(discriminatedUnionJsxElement.tsx, 7, 9))
}
type IListItemData = { variant: ListItemVariant.Avatar; } | { variant: ListItemVariant.OneLine; };
>IListItemData : Symbol(IListItemData, Decl(discriminatedUnionJsxElement.tsx, 9, 1))
>variant : Symbol(variant, Decl(discriminatedUnionJsxElement.tsx, 11, 22))
>ListItemVariant : Symbol(ListItemVariant, Decl(discriminatedUnionJsxElement.tsx, 11, 98))
>Avatar : Symbol(ListItemVariant.Avatar, Decl(discriminatedUnionJsxElement.tsx, 14, 12))
>variant : Symbol(variant, Decl(discriminatedUnionJsxElement.tsx, 11, 61))
>ListItemVariant : Symbol(ListItemVariant, Decl(discriminatedUnionJsxElement.tsx, 11, 98))
>OneLine : Symbol(ListItemVariant.OneLine, Decl(discriminatedUnionJsxElement.tsx, 13, 22))
enum ListItemVariant {
>ListItemVariant : Symbol(ListItemVariant, Decl(discriminatedUnionJsxElement.tsx, 11, 98))
OneLine,
>OneLine : Symbol(ListItemVariant.OneLine, Decl(discriminatedUnionJsxElement.tsx, 13, 22))
Avatar,
>Avatar : Symbol(ListItemVariant.Avatar, Decl(discriminatedUnionJsxElement.tsx, 14, 12))
}
function ListItem(_data: IListItemData) {
>ListItem : Symbol(ListItem, Decl(discriminatedUnionJsxElement.tsx, 16, 1))
>_data : Symbol(_data, Decl(discriminatedUnionJsxElement.tsx, 18, 18))
>IListItemData : Symbol(IListItemData, Decl(discriminatedUnionJsxElement.tsx, 9, 1))
return null;
}
@@ -0,0 +1,57 @@
=== tests/cases/compiler/discriminatedUnionJsxElement.tsx ===
// Repro from #46021
interface IData<MenuItemVariant extends ListItemVariant = ListItemVariant.OneLine> {
>ListItemVariant : any
menuItemsVariant?: MenuItemVariant;
>menuItemsVariant : MenuItemVariant | undefined
}
function Menu<MenuItemVariant extends ListItemVariant = ListItemVariant.OneLine>(data: IData<MenuItemVariant>) {
>Menu : <MenuItemVariant extends ListItemVariant = ListItemVariant.OneLine>(data: IData<MenuItemVariant>) => any
>ListItemVariant : any
>data : IData<MenuItemVariant>
const listItemVariant = data.menuItemsVariant ?? ListItemVariant.OneLine;
>listItemVariant : ListItemVariant.OneLine | NonNullable<MenuItemVariant>
>data.menuItemsVariant ?? ListItemVariant.OneLine : ListItemVariant.OneLine | NonNullable<MenuItemVariant>
>data.menuItemsVariant : MenuItemVariant | undefined
>data : IData<MenuItemVariant>
>menuItemsVariant : MenuItemVariant | undefined
>ListItemVariant.OneLine : ListItemVariant.OneLine
>ListItemVariant : typeof ListItemVariant
>OneLine : ListItemVariant.OneLine
return <ListItem variant={listItemVariant} />;
><ListItem variant={listItemVariant} /> : error
>ListItem : (_data: IListItemData) => null
>variant : ListItemVariant
>listItemVariant : ListItemVariant
}
type IListItemData = { variant: ListItemVariant.Avatar; } | { variant: ListItemVariant.OneLine; };
>IListItemData : IListItemData
>variant : ListItemVariant.Avatar
>ListItemVariant : any
>variant : ListItemVariant.OneLine
>ListItemVariant : any
enum ListItemVariant {
>ListItemVariant : ListItemVariant
OneLine,
>OneLine : ListItemVariant.OneLine
Avatar,
>Avatar : ListItemVariant.Avatar
}
function ListItem(_data: IListItemData) {
>ListItem : (_data: IListItemData) => null
>_data : IListItemData
return null;
>null : null
}
@@ -31,22 +31,22 @@ var t1 = 10;
var t2 = 10;
var s;
// With TemplateTail
Math.pow(t1, -t2) + " world";
Math.pow((-t1), t2) - t1 + " world";
Math.pow((-++t1), t2) - t1 + " world";
Math.pow((-t1++), t2) - t1 + " world";
Math.pow((~t1), Math.pow(t2, --t1)) + " world";
typeof (Math.pow(t1, Math.pow(t2, t1))) + " world";
"".concat(Math.pow(t1, -t2), " world");
"".concat(Math.pow((-t1), t2) - t1, " world");
"".concat(Math.pow((-++t1), t2) - t1, " world");
"".concat(Math.pow((-t1++), t2) - t1, " world");
"".concat(Math.pow((~t1), Math.pow(t2, --t1)), " world");
"".concat(typeof (Math.pow(t1, Math.pow(t2, t1))), " world");
// TempateHead & TemplateTail are empt
Math.pow(t1, -t2) + " hello world " + Math.pow(t1, -t2);
Math.pow((-t1), t2) - t1 + " hello world " + (Math.pow((-t1), t2) - t1);
Math.pow((-++t1), t2) - t1 + " hello world " + Math.pow(t1, Math.pow((-++t1), -t1));
Math.pow((-t1++), t2) - t1 + " hello world " + Math.pow(t2, Math.pow((-t1++), -t1));
Math.pow((~t1), Math.pow(t2, --t1)) + " hello world " + Math.pow((~t1), Math.pow(t2, --t1));
typeof (Math.pow(t1, Math.pow(t2, t1))) + " hello world " + typeof (Math.pow(t1, Math.pow(t2, t1)));
"".concat(Math.pow(t1, -t2), " hello world ").concat(Math.pow(t1, -t2));
"".concat(Math.pow((-t1), t2) - t1, " hello world ").concat(Math.pow((-t1), t2) - t1);
"".concat(Math.pow((-++t1), t2) - t1, " hello world ").concat(Math.pow(t1, Math.pow((-++t1), -t1)));
"".concat(Math.pow((-t1++), t2) - t1, " hello world ").concat(Math.pow(t2, Math.pow((-t1++), -t1)));
"".concat(Math.pow((~t1), Math.pow(t2, --t1)), " hello world ").concat(Math.pow((~t1), Math.pow(t2, --t1)));
"".concat(typeof (Math.pow(t1, Math.pow(t2, t1))), " hello world ").concat(typeof (Math.pow(t1, Math.pow(t2, t1))));
// With templateHead
"hello " + (Math.pow((-t1), t2) - t1);
"hello " + (Math.pow((-++t1), t2) - t1);
"hello " + (Math.pow((-t1++), t2) - t1);
"hello " + Math.pow((~t1), Math.pow(t2, --t1));
"hello " + typeof (Math.pow(t1, Math.pow(t2, t1)));
"hello ".concat(Math.pow((-t1), t2) - t1);
"hello ".concat(Math.pow((-++t1), t2) - t1);
"hello ".concat(Math.pow((-t1++), t2) - t1);
"hello ".concat(Math.pow((~t1), Math.pow(t2, --t1)));
"hello ".concat(typeof (Math.pow(t1, Math.pow(t2, t1))));
@@ -31,22 +31,22 @@ var t1 = 10;
var t2 = 10;
var s;
// TempateHead & TemplateTail are empty
"" + Math.pow(t1, t2);
"" + Math.pow(t1, Math.pow(t2, t1));
"" + (t1 + Math.pow(t2, t1));
"" + (Math.pow(t1, t2) + t1);
"" + (t1 + Math.pow(t2, t2) + t1);
"" + typeof (Math.pow(t1, Math.pow(t2, t1)));
"" + (1 + typeof (Math.pow(t1, Math.pow(t2, t1))));
"" + Math.pow(t1, t2) + Math.pow(t1, t2);
"" + Math.pow(t1, Math.pow(t2, t1)) + Math.pow(t1, Math.pow(t2, t1));
"" + (t1 + Math.pow(t2, t1)) + (t1 + Math.pow(t2, t1));
"" + (Math.pow(t1, t2) + t1) + (Math.pow(t1, t2) + t1);
"" + (t1 + Math.pow(t2, t2) + t1) + (t1 + Math.pow(t2, t2) + t1);
"" + typeof (Math.pow(t1, Math.pow(t2, t1))) + typeof (Math.pow(t1, Math.pow(t2, t1)));
Math.pow(t1, t2) + " hello world " + Math.pow(t1, t2);
Math.pow(t1, Math.pow(t2, t1)) + " hello world " + Math.pow(t1, Math.pow(t2, t1));
t1 + Math.pow(t2, t1) + " hello world " + (t1 + Math.pow(t2, t1));
Math.pow(t1, t2) + t1 + " hello world " + (Math.pow(t1, t2) + t1);
t1 + Math.pow(t2, t2) + t1 + " hello world " + (t1 + Math.pow(t2, t2) + t1);
typeof (Math.pow(t1, Math.pow(t2, t1))) + " hello world " + typeof (Math.pow(t1, Math.pow(t2, t1)));
"".concat(Math.pow(t1, t2));
"".concat(Math.pow(t1, Math.pow(t2, t1)));
"".concat(t1 + Math.pow(t2, t1));
"".concat(Math.pow(t1, t2) + t1);
"".concat(t1 + Math.pow(t2, t2) + t1);
"".concat(typeof (Math.pow(t1, Math.pow(t2, t1))));
"".concat(1 + typeof (Math.pow(t1, Math.pow(t2, t1))));
"".concat(Math.pow(t1, t2)).concat(Math.pow(t1, t2));
"".concat(Math.pow(t1, Math.pow(t2, t1))).concat(Math.pow(t1, Math.pow(t2, t1)));
"".concat(t1 + Math.pow(t2, t1)).concat(t1 + Math.pow(t2, t1));
"".concat(Math.pow(t1, t2) + t1).concat(Math.pow(t1, t2) + t1);
"".concat(t1 + Math.pow(t2, t2) + t1).concat(t1 + Math.pow(t2, t2) + t1);
"".concat(typeof (Math.pow(t1, Math.pow(t2, t1)))).concat(typeof (Math.pow(t1, Math.pow(t2, t1))));
"".concat(Math.pow(t1, t2), " hello world ").concat(Math.pow(t1, t2));
"".concat(Math.pow(t1, Math.pow(t2, t1)), " hello world ").concat(Math.pow(t1, Math.pow(t2, t1)));
"".concat(t1 + Math.pow(t2, t1), " hello world ").concat(t1 + Math.pow(t2, t1));
"".concat(Math.pow(t1, t2) + t1, " hello world ").concat(Math.pow(t1, t2) + t1);
"".concat(t1 + Math.pow(t2, t2) + t1, " hello world ").concat(t1 + Math.pow(t2, t2) + t1);
"".concat(typeof (Math.pow(t1, Math.pow(t2, t1))), " hello world ").concat(typeof (Math.pow(t1, Math.pow(t2, t1))));
@@ -31,22 +31,22 @@ var t1 = 10;
var t2 = 10;
var s;
// With templateHead
"hello " + Math.pow(t1, t2);
"hello " + Math.pow(t1, Math.pow(t2, t1));
"hello " + (t1 + Math.pow(t2, t1));
"hello " + (Math.pow(t1, t2) + t1);
"hello " + (t1 + Math.pow(t2, t2) + t1);
"hello " + typeof (Math.pow(t1, Math.pow(t2, t1)));
"hello " + (1 + typeof (Math.pow(t1, Math.pow(t2, t1))));
"hello " + Math.pow(t1, t2) + Math.pow(t1, t2);
"hello " + Math.pow(t1, Math.pow(t2, t1)) + Math.pow(t1, Math.pow(t2, t1));
"hello " + (t1 + Math.pow(t2, t1)) + (t1 + Math.pow(t2, t1));
"hello " + (Math.pow(t1, t2) + t1) + (Math.pow(t1, t2) + t1);
"hello " + (t1 + Math.pow(t2, t2) + t1) + (t1 + Math.pow(t2, t2) + t1);
"hello " + typeof (Math.pow(t1, Math.pow(t2, t1))) + typeof (Math.pow(t1, Math.pow(t2, t1)));
"hello " + Math.pow(t1, t2) + " hello world " + Math.pow(t1, t2);
"hello " + Math.pow(t1, Math.pow(t2, t1)) + " hello world " + Math.pow(t1, Math.pow(t2, t1));
"hello " + (t1 + Math.pow(t2, t1)) + " hello world " + (t1 + Math.pow(t2, t1));
"hello " + (Math.pow(t1, t2) + t1) + " hello world " + (Math.pow(t1, t2) + t1);
"hello " + (t1 + Math.pow(t2, t2) + t1) + " hello world " + (t1 + Math.pow(t2, t2) + t1);
"hello " + typeof (Math.pow(t1, Math.pow(t2, t1))) + " hello world " + typeof (Math.pow(t1, Math.pow(t2, t1)));
"hello ".concat(Math.pow(t1, t2));
"hello ".concat(Math.pow(t1, Math.pow(t2, t1)));
"hello ".concat(t1 + Math.pow(t2, t1));
"hello ".concat(Math.pow(t1, t2) + t1);
"hello ".concat(t1 + Math.pow(t2, t2) + t1);
"hello ".concat(typeof (Math.pow(t1, Math.pow(t2, t1))));
"hello ".concat(1 + typeof (Math.pow(t1, Math.pow(t2, t1))));
"hello ".concat(Math.pow(t1, t2)).concat(Math.pow(t1, t2));
"hello ".concat(Math.pow(t1, Math.pow(t2, t1))).concat(Math.pow(t1, Math.pow(t2, t1)));
"hello ".concat(t1 + Math.pow(t2, t1)).concat(t1 + Math.pow(t2, t1));
"hello ".concat(Math.pow(t1, t2) + t1).concat(Math.pow(t1, t2) + t1);
"hello ".concat(t1 + Math.pow(t2, t2) + t1).concat(t1 + Math.pow(t2, t2) + t1);
"hello ".concat(typeof (Math.pow(t1, Math.pow(t2, t1)))).concat(typeof (Math.pow(t1, Math.pow(t2, t1))));
"hello ".concat(Math.pow(t1, t2), " hello world ").concat(Math.pow(t1, t2));
"hello ".concat(Math.pow(t1, Math.pow(t2, t1)), " hello world ").concat(Math.pow(t1, Math.pow(t2, t1)));
"hello ".concat(t1 + Math.pow(t2, t1), " hello world ").concat(t1 + Math.pow(t2, t1));
"hello ".concat(Math.pow(t1, t2) + t1, " hello world ").concat(Math.pow(t1, t2) + t1);
"hello ".concat(t1 + Math.pow(t2, t2) + t1, " hello world ").concat(t1 + Math.pow(t2, t2) + t1);
"hello ".concat(typeof (Math.pow(t1, Math.pow(t2, t1))), " hello world ").concat(typeof (Math.pow(t1, Math.pow(t2, t1))));
@@ -32,22 +32,22 @@ var t1 = 10;
var t2 = 10;
var s;
// With TemplateTail
Math.pow(t1, t2) + " world";
Math.pow(t1, Math.pow(t2, t1)) + " world";
t1 + Math.pow(t2, t1) + " world";
Math.pow(t1, t2) + t1 + " world";
t1 + Math.pow(t2, t2) + t1 + " world";
typeof (Math.pow(t1, Math.pow(t2, t1))) + " world";
1 + typeof (Math.pow(t1, Math.pow(t2, t1))) + " world";
"" + Math.pow(t1, t2) + Math.pow(t1, t2) + " world";
"" + Math.pow(t1, Math.pow(t2, t1)) + Math.pow(t1, Math.pow(t2, t1)) + " world";
"" + (t1 + Math.pow(t2, t1)) + (t1 + Math.pow(t2, t1)) + " world";
"" + (Math.pow(t1, t2) + t1) + (Math.pow(t1, t2) + t1) + " world";
"" + (t1 + Math.pow(t2, t2) + t1) + (t1 + Math.pow(t2, t2) + t1) + " world";
"" + typeof (Math.pow(t1, Math.pow(t2, t1))) + typeof (Math.pow(t1, Math.pow(t2, t1))) + " world";
Math.pow(t1, t2) + " hello world " + Math.pow(t1, t2) + " !!";
Math.pow(t1, Math.pow(t2, t1)) + " hello world " + Math.pow(t1, Math.pow(t2, t1)) + " !!";
t1 + Math.pow(t2, t1) + " hello world " + (t1 + Math.pow(t2, t1)) + " !!";
Math.pow(t1, t2) + t1 + " hello world " + (Math.pow(t1, t2) + t1) + " !!";
t1 + Math.pow(t2, t2) + t1 + " hello world " + (t1 + Math.pow(t2, t2) + t1) + " !!";
typeof (Math.pow(t1, Math.pow(t2, t1))) + " hello world " + typeof (Math.pow(t1, Math.pow(t2, t1))) + " !!";
"".concat(Math.pow(t1, t2), " world");
"".concat(Math.pow(t1, Math.pow(t2, t1)), " world");
"".concat(t1 + Math.pow(t2, t1), " world");
"".concat(Math.pow(t1, t2) + t1, " world");
"".concat(t1 + Math.pow(t2, t2) + t1, " world");
"".concat(typeof (Math.pow(t1, Math.pow(t2, t1))), " world");
"".concat(1 + typeof (Math.pow(t1, Math.pow(t2, t1))), " world");
"".concat(Math.pow(t1, t2)).concat(Math.pow(t1, t2), " world");
"".concat(Math.pow(t1, Math.pow(t2, t1))).concat(Math.pow(t1, Math.pow(t2, t1)), " world");
"".concat(t1 + Math.pow(t2, t1)).concat(t1 + Math.pow(t2, t1), " world");
"".concat(Math.pow(t1, t2) + t1).concat(Math.pow(t1, t2) + t1, " world");
"".concat(t1 + Math.pow(t2, t2) + t1).concat(t1 + Math.pow(t2, t2) + t1, " world");
"".concat(typeof (Math.pow(t1, Math.pow(t2, t1)))).concat(typeof (Math.pow(t1, Math.pow(t2, t1))), " world");
"".concat(Math.pow(t1, t2), " hello world ").concat(Math.pow(t1, t2), " !!");
"".concat(Math.pow(t1, Math.pow(t2, t1)), " hello world ").concat(Math.pow(t1, Math.pow(t2, t1)), " !!");
"".concat(t1 + Math.pow(t2, t1), " hello world ").concat(t1 + Math.pow(t2, t1), " !!");
"".concat(Math.pow(t1, t2) + t1, " hello world ").concat(Math.pow(t1, t2) + t1, " !!");
"".concat(t1 + Math.pow(t2, t2) + t1, " hello world ").concat(t1 + Math.pow(t2, t2) + t1, " !!");
"".concat(typeof (Math.pow(t1, Math.pow(t2, t1))), " hello world ").concat(typeof (Math.pow(t1, Math.pow(t2, t1))), " !!");
@@ -0,0 +1,37 @@
// === /node_modules/react-hook-form/dist/index.d.ts ===
// /// <reference types="[|react|]/*FIND ALL REFS*/" />
// export type Foo = React.Whatever;
// export function useForm(): any;
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/node_modules/react-hook-form/dist/index.d.ts",
"kind": "string",
"name": "react",
"textSpan": {
"start": 22,
"length": 5
},
"displayParts": [
{
"text": "\"react\"",
"kind": "stringLiteral"
}
]
},
"references": [
{
"textSpan": {
"start": 22,
"length": 5
},
"fileName": "/node_modules/react-hook-form/dist/index.d.ts",
"isWriteAccess": false,
"isDefinition": false
}
]
}
]
@@ -32,21 +32,21 @@ var t2 = 10;
var s;
// Error: early syntax error using ES7 SimpleUnaryExpression on left-hand side without ()
// TempateHead & TemplateTail are empty
"" + (1 + Math.pow(typeof t1, Math.pow(t2, t1)));
"" + (Math.pow(-t1, t2) - t1);
"" + (Math.pow(-++t1, t2) - t1);
"" + (Math.pow(-t1++, t2) - t1);
"" + Math.pow(!t1, Math.pow(t2, --t1));
"" + Math.pow(typeof t1, Math.pow(t2, t1));
"" + (Math.pow(-t1, t2) - t1) + (Math.pow(-t1, t2) - t1);
"" + (Math.pow(-++t1, t2) - t1) + (Math.pow(-++t1, t2) - t1);
"" + (Math.pow(-t1++, t2) - t1) + (Math.pow(-t1++, t2) - t1);
"" + Math.pow(!t1, Math.pow(t2, --t1)) + Math.pow(!t1, Math.pow(t2, --t1));
"" + Math.pow(typeof t1, Math.pow(t2, t1)) + Math.pow(typeof t1, Math.pow(t2, t1));
"" + (1 + Math.pow(typeof t1, Math.pow(t2, t1))) + (1 + Math.pow(typeof t1, Math.pow(t2, t1)));
Math.pow(-t1, t2) - t1 + " hello world " + (Math.pow(-t1, t2) - t1);
Math.pow(-++t1, t2) - t1 + " hello world " + (Math.pow(-++t1, t2) - t1);
Math.pow(-t1++, t2) - t1 + " hello world " + (Math.pow(-t1++, t2) - t1);
Math.pow(!t1, Math.pow(t2, --t1)) + " hello world " + Math.pow(!t1, Math.pow(t2, --t1));
Math.pow(typeof t1, Math.pow(t2, t1)) + " hello world " + Math.pow(typeof t1, Math.pow(t2, t1));
1 + Math.pow(typeof t1, Math.pow(t2, t1)) + " hello world " + (1 + Math.pow(typeof t1, Math.pow(t2, t1)));
"".concat(1 + Math.pow(typeof t1, Math.pow(t2, t1)));
"".concat(Math.pow(-t1, t2) - t1);
"".concat(Math.pow(-++t1, t2) - t1);
"".concat(Math.pow(-t1++, t2) - t1);
"".concat(Math.pow(!t1, Math.pow(t2, --t1)));
"".concat(Math.pow(typeof t1, Math.pow(t2, t1)));
"".concat(Math.pow(-t1, t2) - t1).concat(Math.pow(-t1, t2) - t1);
"".concat(Math.pow(-++t1, t2) - t1).concat(Math.pow(-++t1, t2) - t1);
"".concat(Math.pow(-t1++, t2) - t1).concat(Math.pow(-t1++, t2) - t1);
"".concat(Math.pow(!t1, Math.pow(t2, --t1))).concat(Math.pow(!t1, Math.pow(t2, --t1)));
"".concat(Math.pow(typeof t1, Math.pow(t2, t1))).concat(Math.pow(typeof t1, Math.pow(t2, t1)));
"".concat(1 + Math.pow(typeof t1, Math.pow(t2, t1))).concat(1 + Math.pow(typeof t1, Math.pow(t2, t1)));
"".concat(Math.pow(-t1, t2) - t1, " hello world ").concat(Math.pow(-t1, t2) - t1);
"".concat(Math.pow(-++t1, t2) - t1, " hello world ").concat(Math.pow(-++t1, t2) - t1);
"".concat(Math.pow(-t1++, t2) - t1, " hello world ").concat(Math.pow(-t1++, t2) - t1);
"".concat(Math.pow(!t1, Math.pow(t2, --t1)), " hello world ").concat(Math.pow(!t1, Math.pow(t2, --t1)));
"".concat(Math.pow(typeof t1, Math.pow(t2, t1)), " hello world ").concat(Math.pow(typeof t1, Math.pow(t2, t1)));
"".concat(1 + Math.pow(typeof t1, Math.pow(t2, t1)), " hello world ").concat(1 + Math.pow(typeof t1, Math.pow(t2, t1)));

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