diff --git a/cli/build.rs b/cli/build.rs index 30e63f6791..2a7327a90f 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -465,7 +465,7 @@ fn main() { ); let ts_version = ts::version(); - debug_assert_eq!(ts_version, "5.0.2"); // bump this assertion when it changes + debug_assert_eq!(ts_version, "5.0.3"); // bump this assertion when it changes println!("cargo:rustc-env=TS_VERSION={}", ts_version); println!("cargo:rerun-if-env-changed=TS_VERSION"); diff --git a/cli/tests/unit/version_test.ts b/cli/tests/unit/version_test.ts index f3771056c8..f129de6b23 100644 --- a/cli/tests/unit/version_test.ts +++ b/cli/tests/unit/version_test.ts @@ -6,5 +6,5 @@ Deno.test(function version() { const pattern = /^\d+\.\d+\.\d+/; assert(pattern.test(Deno.version.deno)); assert(pattern.test(Deno.version.v8)); - assertEquals(Deno.version.typescript, "5.0.2"); + assertEquals(Deno.version.typescript, "5.0.3"); }); diff --git a/cli/tsc/00_typescript.js b/cli/tsc/00_typescript.js index bae91eee2d..63743a3724 100644 --- a/cli/tsc/00_typescript.js +++ b/cli/tsc/00_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"; @@ -39765,7 +39765,7 @@ ${lanes.join("\n")} } function nodeNextJsonConfigResolver(moduleName, containingFile, host) { return nodeModuleNameResolverWorker( - 8 /* Exports */, + 30 /* NodeNextDefault */, moduleName, getDirectoryPath(containingFile), { moduleResolution: 99 /* NodeNext */ }, @@ -55599,9 +55599,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 */; @@ -55638,7 +55639,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); } @@ -55744,6 +55745,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 */) { @@ -58248,6 +58253,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) { @@ -59287,8 +59298,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)); } } @@ -63787,7 +63797,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 */; } @@ -81461,14 +81471,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, @@ -94061,10 +94071,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*/ @@ -120433,7 +120447,7 @@ ${lanes.join("\n")} const { optionsNameMap } = getOptionsNameMap(); for (const name of getOwnKeys(options).sort(compareStringsCaseSensitive)) { const optionInfo = optionsNameMap.get(name.toLowerCase()); - if (optionInfo && (optionInfo.affectsBuildInfo || optionInfo.affectsSemanticDiagnostics)) { + if (optionInfo == null ? void 0 : optionInfo.affectsBuildInfo) { (result || (result = {}))[name] = convertToReusableCompilerOptionValue( optionInfo, options[name], @@ -123155,7 +123169,6 @@ ${lanes.join("\n")} ); } function updateExtendedConfigFilesWatches(forProjectPath, options, watchOptions2, watchType) { - Debug.assert(configFileName); updateSharedExtendedConfigFileWatcher( forProjectPath, options, @@ -123171,7 +123184,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); @@ -151397,7 +151410,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/cli/tsc/dts/lib.decorators.legacy.d.ts b/cli/tsc/dts/lib.decorators.legacy.d.ts index 39bf2413e2..26fbcb526a 100644 --- a/cli/tsc/dts/lib.decorators.legacy.d.ts +++ b/cli/tsc/dts/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;