diff --git a/lib/lib.decorators.legacy.d.ts b/lib/lib.decorators.legacy.d.ts index 39bf2413e2baa..26fbcb526ab2e 100644 --- a/lib/lib.decorators.legacy.d.ts +++ b/lib/lib.decorators.legacy.d.ts @@ -19,4 +19,4 @@ and limitations under the License. declare type ClassDecorator = (target: TFunction) => TFunction | void; declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; -declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void; +declare type ParameterDecorator = (target: Object, propertyKey: string | symbol | undefined, parameterIndex: number) => void; diff --git a/lib/tsc.js b/lib/tsc.js index d3d0ee328b340..6addc1d5ee94d 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -23,7 +23,7 @@ var __export = (target, all) => { // src/compiler/corePublic.ts var versionMajorMinor = "5.0"; -var version = "5.0.2"; +var version = "5.0.3"; // src/compiler/core.ts var emptyArray = []; @@ -37424,7 +37424,7 @@ function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, hos } function nodeNextJsonConfigResolver(moduleName, containingFile, host) { return nodeModuleNameResolverWorker( - 8 /* Exports */, + 30 /* NodeNextDefault */, moduleName, getDirectoryPath(containingFile), { moduleResolution: 99 /* NodeNext */ }, @@ -53129,9 +53129,10 @@ function createTypeChecker(host) { setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, emptyArray); const typeParameter = getTypeParameterFromMappedType(type); const constraintType = getConstraintTypeFromMappedType(type); - const nameType = getNameTypeFromMappedType(type.target || type); - const isFilteringMappedType = nameType && isTypeAssignableTo(nameType, typeParameter); - const templateType = getTemplateTypeFromMappedType(type.target || type); + const mappedType = type.target || type; + const nameType = getNameTypeFromMappedType(mappedType); + const shouldLinkPropDeclarations = !nameType || isFilteringMappedType(mappedType); + const templateType = getTemplateTypeFromMappedType(mappedType); const modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); const templateModifiers = getMappedTypeModifiers(type); const include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; @@ -53168,7 +53169,7 @@ function createTypeChecker(host) { prop.links.keyType = keyType; if (modifiersProp) { prop.links.syntheticOrigin = modifiersProp; - prop.declarations = !nameType || isFilteringMappedType ? modifiersProp.declarations : void 0; + prop.declarations = shouldLinkPropDeclarations ? modifiersProp.declarations : void 0; } members.set(propName, prop); } @@ -53274,6 +53275,10 @@ function createTypeChecker(host) { } return false; } + function isFilteringMappedType(type) { + const nameType = getNameTypeFromMappedType(type); + return !!nameType && isTypeAssignableTo(nameType, getTypeParameterFromMappedType(type)); + } function resolveStructuredTypeMembers(type) { if (!type.members) { if (type.flags & 524288 /* Object */) { @@ -55778,6 +55783,12 @@ function createTypeChecker(host) { i--; const source = types[i]; if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) { + if (source.flags & 262144 /* TypeParameter */ && getBaseConstraintOrType(source).flags & 1048576 /* Union */) { + if (isTypeRelatedTo(source, getUnionType(map(types, (t) => t === source ? neverType : t)), strictSubtypeRelation)) { + orderedRemoveItemAt(types, i); + } + continue; + } const keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? find(getPropertiesOfType(source), (p) => isUnitType(getTypeOfSymbol(p))) : void 0; const keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); for (const target of types) { @@ -56815,8 +56826,7 @@ function createTypeChecker(host) { } } if (isGenericMappedType(objectType)) { - const nameType = getNameTypeFromMappedType(objectType); - if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) { + if (!getNameTypeFromMappedType(objectType) || isFilteringMappedType(objectType)) { return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), (t) => getSimplifiedType(t, writing)); } } @@ -61315,7 +61325,7 @@ function createTypeChecker(host) { const targetHasStringIndex = some(indexInfos, (info) => info.keyType === stringType); let result2 = -1 /* True */; for (const targetInfo of indexInfos) { - const related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : isGenericMappedType(source2) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source2), targetInfo.type, 3 /* Both */, reportErrors2) : typeRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState); + const related = relation !== strictSubtypeRelation && !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : isGenericMappedType(source2) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source2), targetInfo.type, 3 /* Both */, reportErrors2) : typeRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState); if (!related) { return 0 /* False */; } @@ -78983,14 +78993,14 @@ function createTypeChecker(host) { markAliasReferenced(sym, id); if (getAllSymbolFlags(sym) & 111551 /* Value */) { checkExpressionCached(id); - if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) { + if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) { error( id, node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration : Diagnostics.An_export_default_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration, idText(id) ); } - } else if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax) { + } else if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax) { error( id, node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type : Diagnostics.An_export_default_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type, @@ -91030,10 +91040,14 @@ function transformESDecorators(context) { visitor ); const superStatementIndex = findSuperStatementIndex(node.body.statements, nonPrologueStart); - const indexOfFirstStatementAfterSuper = superStatementIndex >= 0 ? superStatementIndex + 1 : void 0; - addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, indexOfFirstStatementAfterSuper ? indexOfFirstStatementAfterSuper - nonPrologueStart : void 0)); - addRange(statements, initializerStatements); - addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, indexOfFirstStatementAfterSuper)); + if (superStatementIndex >= 0) { + addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, superStatementIndex + 1 - nonPrologueStart)); + addRange(statements, initializerStatements); + addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, superStatementIndex + 1)); + } else { + addRange(statements, initializerStatements); + addRange(statements, visitNodes2(node.body.statements, visitor, isStatement)); + } body = factory2.createBlock( statements, /*multiLine*/ @@ -119815,7 +119829,6 @@ function createWatchProgram(host) { ); } function updateExtendedConfigFilesWatches(forProjectPath, options, watchOptions2, watchType) { - Debug.assert(configFileName); updateSharedExtendedConfigFileWatcher( forProjectPath, options, @@ -119831,7 +119844,7 @@ function createWatchProgram(host) { if (!(projects == null ? void 0 : projects.size)) return; projects.forEach((projectPath) => { - if (toPath3(configFileName) === projectPath) { + if (configFileName && toPath3(configFileName) === projectPath) { reloadLevel = 2 /* Full */; } else { const config = parsedConfigs == null ? void 0 : parsedConfigs.get(projectPath); diff --git a/lib/tsserver.js b/lib/tsserver.js index e923d557263b3..6158bf4eb0a40 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -2286,7 +2286,7 @@ module.exports = __toCommonJS(server_exports); // src/compiler/corePublic.ts var versionMajorMinor = "5.0"; -var version = "5.0.2"; +var version = "5.0.3"; var Comparison = /* @__PURE__ */ ((Comparison3) => { Comparison3[Comparison3["LessThan"] = -1] = "LessThan"; Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo"; @@ -41868,7 +41868,7 @@ function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, hos } function nodeNextJsonConfigResolver(moduleName, containingFile, host) { return nodeModuleNameResolverWorker( - 8 /* Exports */, + 30 /* NodeNextDefault */, moduleName, getDirectoryPath(containingFile), { moduleResolution: 99 /* NodeNext */ }, @@ -57728,9 +57728,10 @@ function createTypeChecker(host) { setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, emptyArray); const typeParameter = getTypeParameterFromMappedType(type); const constraintType = getConstraintTypeFromMappedType(type); - const nameType = getNameTypeFromMappedType(type.target || type); - const isFilteringMappedType = nameType && isTypeAssignableTo(nameType, typeParameter); - const templateType = getTemplateTypeFromMappedType(type.target || type); + const mappedType = type.target || type; + const nameType = getNameTypeFromMappedType(mappedType); + const shouldLinkPropDeclarations = !nameType || isFilteringMappedType(mappedType); + const templateType = getTemplateTypeFromMappedType(mappedType); const modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); const templateModifiers = getMappedTypeModifiers(type); const include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; @@ -57767,7 +57768,7 @@ function createTypeChecker(host) { prop.links.keyType = keyType; if (modifiersProp) { prop.links.syntheticOrigin = modifiersProp; - prop.declarations = !nameType || isFilteringMappedType ? modifiersProp.declarations : void 0; + prop.declarations = shouldLinkPropDeclarations ? modifiersProp.declarations : void 0; } members.set(propName, prop); } @@ -57873,6 +57874,10 @@ function createTypeChecker(host) { } return false; } + function isFilteringMappedType(type) { + const nameType = getNameTypeFromMappedType(type); + return !!nameType && isTypeAssignableTo(nameType, getTypeParameterFromMappedType(type)); + } function resolveStructuredTypeMembers(type) { if (!type.members) { if (type.flags & 524288 /* Object */) { @@ -60377,6 +60382,12 @@ function createTypeChecker(host) { i--; const source = types[i]; if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) { + if (source.flags & 262144 /* TypeParameter */ && getBaseConstraintOrType(source).flags & 1048576 /* Union */) { + if (isTypeRelatedTo(source, getUnionType(map(types, (t) => t === source ? neverType : t)), strictSubtypeRelation)) { + orderedRemoveItemAt(types, i); + } + continue; + } const keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? find(getPropertiesOfType(source), (p) => isUnitType(getTypeOfSymbol(p))) : void 0; const keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); for (const target of types) { @@ -61414,8 +61425,7 @@ function createTypeChecker(host) { } } if (isGenericMappedType(objectType)) { - const nameType = getNameTypeFromMappedType(objectType); - if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) { + if (!getNameTypeFromMappedType(objectType) || isFilteringMappedType(objectType)) { return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), (t) => getSimplifiedType(t, writing)); } } @@ -65914,7 +65924,7 @@ function createTypeChecker(host) { const targetHasStringIndex = some(indexInfos, (info) => info.keyType === stringType); let result2 = -1 /* True */; for (const targetInfo of indexInfos) { - const related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : isGenericMappedType(source2) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source2), targetInfo.type, 3 /* Both */, reportErrors2) : typeRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState); + const related = relation !== strictSubtypeRelation && !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : isGenericMappedType(source2) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source2), targetInfo.type, 3 /* Both */, reportErrors2) : typeRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState); if (!related) { return 0 /* False */; } @@ -83582,14 +83592,14 @@ function createTypeChecker(host) { markAliasReferenced(sym, id); if (getAllSymbolFlags(sym) & 111551 /* Value */) { checkExpressionCached(id); - if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) { + if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) { error( id, node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration : Diagnostics.An_export_default_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration, idText(id) ); } - } else if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax) { + } else if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax) { error( id, node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type : Diagnostics.An_export_default_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type, @@ -95800,10 +95810,14 @@ function transformESDecorators(context) { visitor ); const superStatementIndex = findSuperStatementIndex(node.body.statements, nonPrologueStart); - const indexOfFirstStatementAfterSuper = superStatementIndex >= 0 ? superStatementIndex + 1 : void 0; - addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, indexOfFirstStatementAfterSuper ? indexOfFirstStatementAfterSuper - nonPrologueStart : void 0)); - addRange(statements, initializerStatements); - addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, indexOfFirstStatementAfterSuper)); + if (superStatementIndex >= 0) { + addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, superStatementIndex + 1 - nonPrologueStart)); + addRange(statements, initializerStatements); + addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, superStatementIndex + 1)); + } else { + addRange(statements, initializerStatements); + addRange(statements, visitNodes2(node.body.statements, visitor, isStatement)); + } body = factory2.createBlock( statements, /*multiLine*/ @@ -124707,7 +124721,6 @@ function createWatchProgram(host) { ); } function updateExtendedConfigFilesWatches(forProjectPath, options, watchOptions2, watchType) { - Debug.assert(configFileName); updateSharedExtendedConfigFileWatcher( forProjectPath, options, @@ -124723,7 +124736,7 @@ function createWatchProgram(host) { if (!(projects == null ? void 0 : projects.size)) return; projects.forEach((projectPath) => { - if (toPath3(configFileName) === projectPath) { + if (configFileName && toPath3(configFileName) === projectPath) { reloadLevel = 2 /* Full */; } else { const config = parsedConfigs == null ? void 0 : parsedConfigs.get(projectPath); @@ -152027,7 +152040,7 @@ function getStringLiteralCompletionEntries(sourceFile, node, position, typeCheck const literals = contextualTypes.types.filter((literal) => !tracker.hasValue(literal.value)); return { kind: 2 /* Types */, types: literals, isNewIdentifier: false }; default: - return fromContextualType(); + return fromContextualType() || fromContextualType(0 /* None */); } function fromContextualType(contextFlags = 4 /* Completions */) { const types = getStringLiteralTypes(getContextualTypeFromParent(node, typeChecker, contextFlags)); diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 66bf62109d21b..d18ae2db12b4b 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -35,7 +35,7 @@ var ts = (() => { "src/compiler/corePublic.ts"() { "use strict"; versionMajorMinor = "5.0"; - version = "5.0.2"; + version = "5.0.3"; Comparison = /* @__PURE__ */ ((Comparison3) => { Comparison3[Comparison3["LessThan"] = -1] = "LessThan"; Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo"; @@ -39756,7 +39756,7 @@ ${lanes.join("\n")} } function nodeNextJsonConfigResolver(moduleName, containingFile, host) { return nodeModuleNameResolverWorker( - 8 /* Exports */, + 30 /* NodeNextDefault */, moduleName, getDirectoryPath(containingFile), { moduleResolution: 99 /* NodeNext */ }, @@ -55538,9 +55538,10 @@ ${lanes.join("\n")} setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, emptyArray); const typeParameter = getTypeParameterFromMappedType(type); const constraintType = getConstraintTypeFromMappedType(type); - const nameType = getNameTypeFromMappedType(type.target || type); - const isFilteringMappedType = nameType && isTypeAssignableTo(nameType, typeParameter); - const templateType = getTemplateTypeFromMappedType(type.target || type); + const mappedType = type.target || type; + const nameType = getNameTypeFromMappedType(mappedType); + const shouldLinkPropDeclarations = !nameType || isFilteringMappedType(mappedType); + const templateType = getTemplateTypeFromMappedType(mappedType); const modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); const templateModifiers = getMappedTypeModifiers(type); const include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; @@ -55577,7 +55578,7 @@ ${lanes.join("\n")} prop.links.keyType = keyType; if (modifiersProp) { prop.links.syntheticOrigin = modifiersProp; - prop.declarations = !nameType || isFilteringMappedType ? modifiersProp.declarations : void 0; + prop.declarations = shouldLinkPropDeclarations ? modifiersProp.declarations : void 0; } members.set(propName, prop); } @@ -55683,6 +55684,10 @@ ${lanes.join("\n")} } return false; } + function isFilteringMappedType(type) { + const nameType = getNameTypeFromMappedType(type); + return !!nameType && isTypeAssignableTo(nameType, getTypeParameterFromMappedType(type)); + } function resolveStructuredTypeMembers(type) { if (!type.members) { if (type.flags & 524288 /* Object */) { @@ -58187,6 +58192,12 @@ ${lanes.join("\n")} i--; const source = types[i]; if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) { + if (source.flags & 262144 /* TypeParameter */ && getBaseConstraintOrType(source).flags & 1048576 /* Union */) { + if (isTypeRelatedTo(source, getUnionType(map(types, (t) => t === source ? neverType : t)), strictSubtypeRelation)) { + orderedRemoveItemAt(types, i); + } + continue; + } const keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? find(getPropertiesOfType(source), (p) => isUnitType(getTypeOfSymbol(p))) : void 0; const keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); for (const target of types) { @@ -59224,8 +59235,7 @@ ${lanes.join("\n")} } } if (isGenericMappedType(objectType)) { - const nameType = getNameTypeFromMappedType(objectType); - if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) { + if (!getNameTypeFromMappedType(objectType) || isFilteringMappedType(objectType)) { return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), (t) => getSimplifiedType(t, writing)); } } @@ -63724,7 +63734,7 @@ ${lanes.join("\n")} const targetHasStringIndex = some(indexInfos, (info) => info.keyType === stringType); let result2 = -1 /* True */; for (const targetInfo of indexInfos) { - const related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : isGenericMappedType(source2) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source2), targetInfo.type, 3 /* Both */, reportErrors2) : typeRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState); + const related = relation !== strictSubtypeRelation && !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : isGenericMappedType(source2) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source2), targetInfo.type, 3 /* Both */, reportErrors2) : typeRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState); if (!related) { return 0 /* False */; } @@ -81392,14 +81402,14 @@ ${lanes.join("\n")} markAliasReferenced(sym, id); if (getAllSymbolFlags(sym) & 111551 /* Value */) { checkExpressionCached(id); - if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) { + if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) { error( id, node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration : Diagnostics.An_export_default_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration, idText(id) ); } - } else if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax) { + } else if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax) { error( id, node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type : Diagnostics.An_export_default_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type, @@ -93803,10 +93813,14 @@ ${lanes.join("\n")} visitor ); const superStatementIndex = findSuperStatementIndex(node.body.statements, nonPrologueStart); - const indexOfFirstStatementAfterSuper = superStatementIndex >= 0 ? superStatementIndex + 1 : void 0; - addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, indexOfFirstStatementAfterSuper ? indexOfFirstStatementAfterSuper - nonPrologueStart : void 0)); - addRange(statements, initializerStatements); - addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, indexOfFirstStatementAfterSuper)); + if (superStatementIndex >= 0) { + addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, superStatementIndex + 1 - nonPrologueStart)); + addRange(statements, initializerStatements); + addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, superStatementIndex + 1)); + } else { + addRange(statements, initializerStatements); + addRange(statements, visitNodes2(node.body.statements, visitor, isStatement)); + } body = factory2.createBlock( statements, /*multiLine*/ @@ -122897,7 +122911,6 @@ ${lanes.join("\n")} ); } function updateExtendedConfigFilesWatches(forProjectPath, options, watchOptions2, watchType) { - Debug.assert(configFileName); updateSharedExtendedConfigFileWatcher( forProjectPath, options, @@ -122913,7 +122926,7 @@ ${lanes.join("\n")} if (!(projects == null ? void 0 : projects.size)) return; projects.forEach((projectPath) => { - if (toPath3(configFileName) === projectPath) { + if (configFileName && toPath3(configFileName) === projectPath) { reloadLevel = 2 /* Full */; } else { const config = parsedConfigs == null ? void 0 : parsedConfigs.get(projectPath); @@ -151124,7 +151137,7 @@ ${lanes.join("\n")} const literals = contextualTypes.types.filter((literal) => !tracker.hasValue(literal.value)); return { kind: 2 /* Types */, types: literals, isNewIdentifier: false }; default: - return fromContextualType(); + return fromContextualType() || fromContextualType(0 /* None */); } function fromContextualType(contextFlags = 4 /* Completions */) { const types = getStringLiteralTypes(getContextualTypeFromParent(node, typeChecker, contextFlags)); diff --git a/lib/typescript.js b/lib/typescript.js index c812bf9575857..4c5d21f4b46c0 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -35,7 +35,7 @@ var ts = (() => { "src/compiler/corePublic.ts"() { "use strict"; versionMajorMinor = "5.0"; - version = "5.0.2"; + version = "5.0.3"; Comparison = /* @__PURE__ */ ((Comparison3) => { Comparison3[Comparison3["LessThan"] = -1] = "LessThan"; Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo"; @@ -39756,7 +39756,7 @@ ${lanes.join("\n")} } function nodeNextJsonConfigResolver(moduleName, containingFile, host) { return nodeModuleNameResolverWorker( - 8 /* Exports */, + 30 /* NodeNextDefault */, moduleName, getDirectoryPath(containingFile), { moduleResolution: 99 /* NodeNext */ }, @@ -55538,9 +55538,10 @@ ${lanes.join("\n")} setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, emptyArray); const typeParameter = getTypeParameterFromMappedType(type); const constraintType = getConstraintTypeFromMappedType(type); - const nameType = getNameTypeFromMappedType(type.target || type); - const isFilteringMappedType = nameType && isTypeAssignableTo(nameType, typeParameter); - const templateType = getTemplateTypeFromMappedType(type.target || type); + const mappedType = type.target || type; + const nameType = getNameTypeFromMappedType(mappedType); + const shouldLinkPropDeclarations = !nameType || isFilteringMappedType(mappedType); + const templateType = getTemplateTypeFromMappedType(mappedType); const modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); const templateModifiers = getMappedTypeModifiers(type); const include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; @@ -55577,7 +55578,7 @@ ${lanes.join("\n")} prop.links.keyType = keyType; if (modifiersProp) { prop.links.syntheticOrigin = modifiersProp; - prop.declarations = !nameType || isFilteringMappedType ? modifiersProp.declarations : void 0; + prop.declarations = shouldLinkPropDeclarations ? modifiersProp.declarations : void 0; } members.set(propName, prop); } @@ -55683,6 +55684,10 @@ ${lanes.join("\n")} } return false; } + function isFilteringMappedType(type) { + const nameType = getNameTypeFromMappedType(type); + return !!nameType && isTypeAssignableTo(nameType, getTypeParameterFromMappedType(type)); + } function resolveStructuredTypeMembers(type) { if (!type.members) { if (type.flags & 524288 /* Object */) { @@ -58187,6 +58192,12 @@ ${lanes.join("\n")} i--; const source = types[i]; if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) { + if (source.flags & 262144 /* TypeParameter */ && getBaseConstraintOrType(source).flags & 1048576 /* Union */) { + if (isTypeRelatedTo(source, getUnionType(map(types, (t) => t === source ? neverType : t)), strictSubtypeRelation)) { + orderedRemoveItemAt(types, i); + } + continue; + } const keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? find(getPropertiesOfType(source), (p) => isUnitType(getTypeOfSymbol(p))) : void 0; const keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); for (const target of types) { @@ -59224,8 +59235,7 @@ ${lanes.join("\n")} } } if (isGenericMappedType(objectType)) { - const nameType = getNameTypeFromMappedType(objectType); - if (!nameType || isTypeAssignableTo(nameType, getTypeParameterFromMappedType(objectType))) { + if (!getNameTypeFromMappedType(objectType) || isFilteringMappedType(objectType)) { return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), (t) => getSimplifiedType(t, writing)); } } @@ -63724,7 +63734,7 @@ ${lanes.join("\n")} const targetHasStringIndex = some(indexInfos, (info) => info.keyType === stringType); let result2 = -1 /* True */; for (const targetInfo of indexInfos) { - const related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : isGenericMappedType(source2) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source2), targetInfo.type, 3 /* Both */, reportErrors2) : typeRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState); + const related = relation !== strictSubtypeRelation && !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : isGenericMappedType(source2) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source2), targetInfo.type, 3 /* Both */, reportErrors2) : typeRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState); if (!related) { return 0 /* False */; } @@ -81392,14 +81402,14 @@ ${lanes.join("\n")} markAliasReferenced(sym, id); if (getAllSymbolFlags(sym) & 111551 /* Value */) { checkExpressionCached(id); - if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) { + if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, 111551 /* Value */)) { error( id, node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration : Diagnostics.An_export_default_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration, idText(id) ); } - } else if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax) { + } else if (!isIllegalExportDefaultInCJS && !(node.flags & 16777216 /* Ambient */) && compilerOptions.verbatimModuleSyntax) { error( id, node.isExportEquals ? Diagnostics.An_export_declaration_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type : Diagnostics.An_export_default_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type, @@ -93803,10 +93813,14 @@ ${lanes.join("\n")} visitor ); const superStatementIndex = findSuperStatementIndex(node.body.statements, nonPrologueStart); - const indexOfFirstStatementAfterSuper = superStatementIndex >= 0 ? superStatementIndex + 1 : void 0; - addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, indexOfFirstStatementAfterSuper ? indexOfFirstStatementAfterSuper - nonPrologueStart : void 0)); - addRange(statements, initializerStatements); - addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, indexOfFirstStatementAfterSuper)); + if (superStatementIndex >= 0) { + addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, nonPrologueStart, superStatementIndex + 1 - nonPrologueStart)); + addRange(statements, initializerStatements); + addRange(statements, visitNodes2(node.body.statements, visitor, isStatement, superStatementIndex + 1)); + } else { + addRange(statements, initializerStatements); + addRange(statements, visitNodes2(node.body.statements, visitor, isStatement)); + } body = factory2.createBlock( statements, /*multiLine*/ @@ -122897,7 +122911,6 @@ ${lanes.join("\n")} ); } function updateExtendedConfigFilesWatches(forProjectPath, options, watchOptions2, watchType) { - Debug.assert(configFileName); updateSharedExtendedConfigFileWatcher( forProjectPath, options, @@ -122913,7 +122926,7 @@ ${lanes.join("\n")} if (!(projects == null ? void 0 : projects.size)) return; projects.forEach((projectPath) => { - if (toPath3(configFileName) === projectPath) { + if (configFileName && toPath3(configFileName) === projectPath) { reloadLevel = 2 /* Full */; } else { const config = parsedConfigs == null ? void 0 : parsedConfigs.get(projectPath); @@ -151138,7 +151151,7 @@ ${lanes.join("\n")} const literals = contextualTypes.types.filter((literal) => !tracker.hasValue(literal.value)); return { kind: 2 /* Types */, types: literals, isNewIdentifier: false }; default: - return fromContextualType(); + return fromContextualType() || fromContextualType(0 /* None */); } function fromContextualType(contextFlags = 4 /* Completions */) { const types = getStringLiteralTypes(getContextualTypeFromParent(node, typeChecker, contextFlags)); diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 1f8713008fa60..9829c4b9ef38c 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -54,7 +54,7 @@ var path = __toESM(require("path")); // src/compiler/corePublic.ts var versionMajorMinor = "5.0"; -var version = "5.0.2"; +var version = "5.0.3"; // src/compiler/core.ts var emptyArray = []; diff --git a/package.json b/package.json index 69ab01a5a616e..9bf31add9adc8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "https://www.typescriptlang.org/", - "version": "5.0.2", + "version": "5.0.3", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/src/compiler/corePublic.ts b/src/compiler/corePublic.ts index 139cfa95efb9e..00780e262d647 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -4,7 +4,7 @@ export const versionMajorMinor = "5.0"; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types -export const version = "5.0.2" as string; +export const version = "5.0.3" as string; /** * Type of objects whose values are all of the same type.