diff --git a/lib/tsc.js b/lib/tsc.js index 564e3233b2a67..4a425cf3d9cbf 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -3635,6 +3635,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => { TypeFlags2[TypeFlags2["NonPrimitive"] = 67108864] = "NonPrimitive"; TypeFlags2[TypeFlags2["TemplateLiteral"] = 134217728] = "TemplateLiteral"; TypeFlags2[TypeFlags2["StringMapping"] = 268435456] = "StringMapping"; + TypeFlags2[TypeFlags2["Reserved1"] = 536870912] = "Reserved1"; TypeFlags2[TypeFlags2["AnyOrUnknown"] = 3] = "AnyOrUnknown"; TypeFlags2[TypeFlags2["Nullable"] = 98304] = "Nullable"; TypeFlags2[TypeFlags2["Literal"] = 2944] = "Literal"; @@ -3672,7 +3673,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => { TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard"; TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject"; TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable"; - TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 268435456 /* StringMapping */] = "IncludesConstrainedTypeVariable"; + TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 536870912 /* Reserved1 */] = "IncludesConstrainedTypeVariable"; TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion"; return TypeFlags2; })(TypeFlags || {}); @@ -57482,7 +57483,7 @@ function createTypeChecker(host) { if (flags & 465829888 /* Instantiable */) includes |= 33554432 /* IncludesInstantiable */; if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) - includes |= 268435456 /* IncludesConstrainedTypeVariable */; + includes |= 536870912 /* IncludesConstrainedTypeVariable */; if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */; if (!strictNullChecks && flags & 98304 /* Nullable */) { @@ -57575,18 +57576,21 @@ function createTypeChecker(host) { } } function removeStringLiteralsMatchedByTemplateLiterals(types) { - const templates = filter(types, (t) => !!(t.flags & 134217728 /* TemplateLiteral */) && isPatternLiteralType(t)); + const templates = filter(types, isPatternLiteralType); if (templates.length) { let i = types.length; while (i > 0) { i--; const t = types[i]; - if (t.flags & 128 /* StringLiteral */ && some(templates, (template) => isTypeMatchedByTemplateLiteralType(t, template))) { + if (t.flags & 128 /* StringLiteral */ && some(templates, (template) => isTypeMatchedByTemplateLiteralOrStringMapping(t, template))) { orderedRemoveItemAt(types, i); } } } } + function isTypeMatchedByTemplateLiteralOrStringMapping(type, template) { + return template.flags & 134217728 /* TemplateLiteral */ ? isTypeMatchedByTemplateLiteralType(type, template) : isMemberOfStringMapping(type, template); + } function removeConstrainedTypeVariables(types) { const typeVariables = []; for (const type of types) { @@ -57684,10 +57688,10 @@ function createTypeChecker(host) { if (includes & (32 /* Enum */ | 2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + if (includes & 128 /* StringLiteral */ && includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); } - if (includes & 268435456 /* IncludesConstrainedTypeVariable */) { + if (includes & 536870912 /* IncludesConstrainedTypeVariable */) { removeConstrainedTypeVariables(typeSet); } if (unionReduction === 2 /* Subtype */) { @@ -57851,7 +57855,7 @@ function createTypeChecker(host) { while (i > 0) { i--; const t = types[i]; - if (!(t.flags & 134217728 /* TemplateLiteral */)) + if (!(t.flags & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */))) continue; for (const t2 of literals) { if (isTypeSubtypeOf(t2, t)) { @@ -57925,7 +57929,7 @@ function createTypeChecker(host) { if (strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) || includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) || includes & 2112 /* BigIntLike */ && includes & (469892092 /* DisjointDomains */ & ~2112 /* BigIntLike */) || includes & 12288 /* ESSymbolLike */ && includes & (469892092 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || includes & 49152 /* VoidLike */ && includes & (469892092 /* DisjointDomains */ & ~49152 /* VoidLike */)) { return neverType; } - if (includes & 134217728 /* TemplateLiteral */ && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { + if (includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { return neverType; } if (includes & 1 /* Any */) { diff --git a/lib/tsserver.js b/lib/tsserver.js index de1991f53fce4..7254b1aff33d8 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -6659,6 +6659,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => { TypeFlags2[TypeFlags2["NonPrimitive"] = 67108864] = "NonPrimitive"; TypeFlags2[TypeFlags2["TemplateLiteral"] = 134217728] = "TemplateLiteral"; TypeFlags2[TypeFlags2["StringMapping"] = 268435456] = "StringMapping"; + TypeFlags2[TypeFlags2["Reserved1"] = 536870912] = "Reserved1"; TypeFlags2[TypeFlags2["AnyOrUnknown"] = 3] = "AnyOrUnknown"; TypeFlags2[TypeFlags2["Nullable"] = 98304] = "Nullable"; TypeFlags2[TypeFlags2["Literal"] = 2944] = "Literal"; @@ -6696,7 +6697,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => { TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard"; TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject"; TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable"; - TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 268435456 /* StringMapping */] = "IncludesConstrainedTypeVariable"; + TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 536870912 /* Reserved1 */] = "IncludesConstrainedTypeVariable"; TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion"; return TypeFlags2; })(TypeFlags || {}); @@ -62217,7 +62218,7 @@ function createTypeChecker(host) { if (flags & 465829888 /* Instantiable */) includes |= 33554432 /* IncludesInstantiable */; if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) - includes |= 268435456 /* IncludesConstrainedTypeVariable */; + includes |= 536870912 /* IncludesConstrainedTypeVariable */; if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */; if (!strictNullChecks && flags & 98304 /* Nullable */) { @@ -62310,18 +62311,21 @@ function createTypeChecker(host) { } } function removeStringLiteralsMatchedByTemplateLiterals(types) { - const templates = filter(types, (t) => !!(t.flags & 134217728 /* TemplateLiteral */) && isPatternLiteralType(t)); + const templates = filter(types, isPatternLiteralType); if (templates.length) { let i = types.length; while (i > 0) { i--; const t = types[i]; - if (t.flags & 128 /* StringLiteral */ && some(templates, (template) => isTypeMatchedByTemplateLiteralType(t, template))) { + if (t.flags & 128 /* StringLiteral */ && some(templates, (template) => isTypeMatchedByTemplateLiteralOrStringMapping(t, template))) { orderedRemoveItemAt(types, i); } } } } + function isTypeMatchedByTemplateLiteralOrStringMapping(type, template) { + return template.flags & 134217728 /* TemplateLiteral */ ? isTypeMatchedByTemplateLiteralType(type, template) : isMemberOfStringMapping(type, template); + } function removeConstrainedTypeVariables(types) { const typeVariables = []; for (const type of types) { @@ -62419,10 +62423,10 @@ function createTypeChecker(host) { if (includes & (32 /* Enum */ | 2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + if (includes & 128 /* StringLiteral */ && includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); } - if (includes & 268435456 /* IncludesConstrainedTypeVariable */) { + if (includes & 536870912 /* IncludesConstrainedTypeVariable */) { removeConstrainedTypeVariables(typeSet); } if (unionReduction === 2 /* Subtype */) { @@ -62586,7 +62590,7 @@ function createTypeChecker(host) { while (i > 0) { i--; const t = types[i]; - if (!(t.flags & 134217728 /* TemplateLiteral */)) + if (!(t.flags & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */))) continue; for (const t2 of literals) { if (isTypeSubtypeOf(t2, t)) { @@ -62660,7 +62664,7 @@ function createTypeChecker(host) { if (strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) || includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) || includes & 2112 /* BigIntLike */ && includes & (469892092 /* DisjointDomains */ & ~2112 /* BigIntLike */) || includes & 12288 /* ESSymbolLike */ && includes & (469892092 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || includes & 49152 /* VoidLike */ && includes & (469892092 /* DisjointDomains */ & ~49152 /* VoidLike */)) { return neverType; } - if (includes & 134217728 /* TemplateLiteral */ && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { + if (includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { return neverType; } if (includes & 1 /* Any */) { diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 4df46013e2e33..100081fb8cccf 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -205,7 +205,7 @@ declare namespace ts { /** * Request to reload the project structure for all the opened files */ - interface ReloadProjectsRequest extends Message { + interface ReloadProjectsRequest extends Request { command: CommandTypes.ReloadProjects; } /** diff --git a/lib/typescript.js b/lib/typescript.js index acd1a29f67af5..6cd6c983a31b7 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -4412,6 +4412,7 @@ ${lanes.join("\n")} TypeFlags2[TypeFlags2["NonPrimitive"] = 67108864] = "NonPrimitive"; TypeFlags2[TypeFlags2["TemplateLiteral"] = 134217728] = "TemplateLiteral"; TypeFlags2[TypeFlags2["StringMapping"] = 268435456] = "StringMapping"; + TypeFlags2[TypeFlags2["Reserved1"] = 536870912] = "Reserved1"; TypeFlags2[TypeFlags2["AnyOrUnknown"] = 3] = "AnyOrUnknown"; TypeFlags2[TypeFlags2["Nullable"] = 98304] = "Nullable"; TypeFlags2[TypeFlags2["Literal"] = 2944] = "Literal"; @@ -4449,7 +4450,7 @@ ${lanes.join("\n")} TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard"; TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject"; TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable"; - TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 268435456 /* StringMapping */] = "IncludesConstrainedTypeVariable"; + TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 536870912 /* Reserved1 */] = "IncludesConstrainedTypeVariable"; TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion"; return TypeFlags2; })(TypeFlags || {}); @@ -59971,7 +59972,7 @@ ${lanes.join("\n")} if (flags & 465829888 /* Instantiable */) includes |= 33554432 /* IncludesInstantiable */; if (flags & 2097152 /* Intersection */ && getObjectFlags(type) & 67108864 /* IsConstrainedTypeVariable */) - includes |= 268435456 /* IncludesConstrainedTypeVariable */; + includes |= 536870912 /* IncludesConstrainedTypeVariable */; if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */; if (!strictNullChecks && flags & 98304 /* Nullable */) { @@ -60064,18 +60065,21 @@ ${lanes.join("\n")} } } function removeStringLiteralsMatchedByTemplateLiterals(types) { - const templates = filter(types, (t) => !!(t.flags & 134217728 /* TemplateLiteral */) && isPatternLiteralType(t)); + const templates = filter(types, isPatternLiteralType); if (templates.length) { let i = types.length; while (i > 0) { i--; const t = types[i]; - if (t.flags & 128 /* StringLiteral */ && some(templates, (template) => isTypeMatchedByTemplateLiteralType(t, template))) { + if (t.flags & 128 /* StringLiteral */ && some(templates, (template) => isTypeMatchedByTemplateLiteralOrStringMapping(t, template))) { orderedRemoveItemAt(types, i); } } } } + function isTypeMatchedByTemplateLiteralOrStringMapping(type, template) { + return template.flags & 134217728 /* TemplateLiteral */ ? isTypeMatchedByTemplateLiteralType(type, template) : isMemberOfStringMapping(type, template); + } function removeConstrainedTypeVariables(types) { const typeVariables = []; for (const type of types) { @@ -60173,10 +60177,10 @@ ${lanes.join("\n")} if (includes & (32 /* Enum */ | 2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + if (includes & 128 /* StringLiteral */ && includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); } - if (includes & 268435456 /* IncludesConstrainedTypeVariable */) { + if (includes & 536870912 /* IncludesConstrainedTypeVariable */) { removeConstrainedTypeVariables(typeSet); } if (unionReduction === 2 /* Subtype */) { @@ -60340,7 +60344,7 @@ ${lanes.join("\n")} while (i > 0) { i--; const t = types[i]; - if (!(t.flags & 134217728 /* TemplateLiteral */)) + if (!(t.flags & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */))) continue; for (const t2 of literals) { if (isTypeSubtypeOf(t2, t)) { @@ -60414,7 +60418,7 @@ ${lanes.join("\n")} if (strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) || includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) || includes & 2112 /* BigIntLike */ && includes & (469892092 /* DisjointDomains */ & ~2112 /* BigIntLike */) || includes & 12288 /* ESSymbolLike */ && includes & (469892092 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || includes & 49152 /* VoidLike */ && includes & (469892092 /* DisjointDomains */ & ~49152 /* VoidLike */)) { return neverType; } - if (includes & 134217728 /* TemplateLiteral */ && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { + if (includes & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { return neverType; } if (includes & 1 /* Any */) { diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 5f5bf0fd0f92f..691d2a967221f 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -3069,6 +3069,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => { TypeFlags2[TypeFlags2["NonPrimitive"] = 67108864] = "NonPrimitive"; TypeFlags2[TypeFlags2["TemplateLiteral"] = 134217728] = "TemplateLiteral"; TypeFlags2[TypeFlags2["StringMapping"] = 268435456] = "StringMapping"; + TypeFlags2[TypeFlags2["Reserved1"] = 536870912] = "Reserved1"; TypeFlags2[TypeFlags2["AnyOrUnknown"] = 3] = "AnyOrUnknown"; TypeFlags2[TypeFlags2["Nullable"] = 98304] = "Nullable"; TypeFlags2[TypeFlags2["Literal"] = 2944] = "Literal"; @@ -3106,7 +3107,7 @@ var TypeFlags = /* @__PURE__ */ ((TypeFlags2) => { TypeFlags2[TypeFlags2["IncludesWildcard"] = 8388608 /* IndexedAccess */] = "IncludesWildcard"; TypeFlags2[TypeFlags2["IncludesEmptyObject"] = 16777216 /* Conditional */] = "IncludesEmptyObject"; TypeFlags2[TypeFlags2["IncludesInstantiable"] = 33554432 /* Substitution */] = "IncludesInstantiable"; - TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 268435456 /* StringMapping */] = "IncludesConstrainedTypeVariable"; + TypeFlags2[TypeFlags2["IncludesConstrainedTypeVariable"] = 536870912 /* Reserved1 */] = "IncludesConstrainedTypeVariable"; TypeFlags2[TypeFlags2["NotPrimitiveUnion"] = 36323331] = "NotPrimitiveUnion"; return TypeFlags2; })(TypeFlags || {});