diff --git a/lib/_tsc.js b/lib/_tsc.js index 3bcdbf7ae59ec..e64047450c162 100644 --- a/lib/_tsc.js +++ b/lib/_tsc.js @@ -18,7 +18,7 @@ and limitations under the License. // src/compiler/corePublic.ts var versionMajorMinor = "5.7"; -var version = "5.7.2"; +var version = "5.7.3"; // src/compiler/core.ts var emptyArray = []; @@ -11143,6 +11143,7 @@ function sortAndDeduplicateDiagnostics(diagnostics) { } var targetToLibMap = /* @__PURE__ */ new Map([ [99 /* ESNext */, "lib.esnext.full.d.ts"], + [11 /* ES2024 */, "lib.es2024.full.d.ts"], [10 /* ES2023 */, "lib.es2023.full.d.ts"], [9 /* ES2022 */, "lib.es2022.full.d.ts"], [8 /* ES2021 */, "lib.es2021.full.d.ts"], @@ -11158,6 +11159,7 @@ function getDefaultLibFileName(options) { const target = getEmitScriptTarget(options); switch (target) { case 99 /* ESNext */: + case 11 /* ES2024 */: case 10 /* ES2023 */: case 9 /* ES2022 */: case 8 /* ES2021 */: @@ -70460,12 +70462,13 @@ function createTypeChecker(host) { const jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? Diagnostics.This_JSX_tag_requires_0_to_be_in_scope_but_it_could_not_be_found : void 0; const jsxFactoryNamespace = getJsxNamespace(node); const jsxFactoryLocation = isJsxOpeningLikeElement(node) ? node.tagName : node; + const shouldFactoryRefErr = compilerOptions.jsx !== 1 /* Preserve */ && compilerOptions.jsx !== 3 /* ReactNative */; let jsxFactorySym; if (!(isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) { jsxFactorySym = resolveName( jsxFactoryLocation, jsxFactoryNamespace, - compilerOptions.jsx === 1 /* Preserve */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */, + shouldFactoryRefErr ? 111551 /* Value */ : 111551 /* Value */ & ~384 /* Enum */, jsxFactoryRefErr, /*isUse*/ true @@ -70484,7 +70487,7 @@ function createTypeChecker(host) { resolveName( jsxFactoryLocation, localJsxNamespace, - compilerOptions.jsx === 1 /* Preserve */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */, + shouldFactoryRefErr ? 111551 /* Value */ : 111551 /* Value */ & ~384 /* Enum */, jsxFactoryRefErr, /*isUse*/ true @@ -74045,6 +74048,13 @@ function createTypeChecker(host) { return getIntersectionType(x); } function reportNonexistentProperty(propNode, containingType, isUncheckedJS) { + const links = getNodeLinks(propNode); + const cache = links.nonExistentPropCheckCache || (links.nonExistentPropCheckCache = /* @__PURE__ */ new Set()); + const key = `${getTypeId(containingType)}|${isUncheckedJS}`; + if (cache.has(key)) { + return; + } + cache.add(key); let errorInfo; let relatedInfo; if (!isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* Union */ && !(containingType.flags & 402784252 /* Primitive */)) { @@ -76003,12 +76013,14 @@ function createTypeChecker(host) { const sourceFileLinks = getNodeLinks(getSourceFileOfNode(node)); if (sourceFileLinks.jsxFragmentType !== void 0) return sourceFileLinks.jsxFragmentType; const jsxFragmentFactoryName = getJsxNamespace(node); - if (jsxFragmentFactoryName === "null") return sourceFileLinks.jsxFragmentType = anyType; + const shouldResolveFactoryReference = (compilerOptions.jsx === 2 /* React */ || compilerOptions.jsxFragmentFactory !== void 0) && jsxFragmentFactoryName !== "null"; + if (!shouldResolveFactoryReference) return sourceFileLinks.jsxFragmentType = anyType; + const shouldModuleRefErr = compilerOptions.jsx !== 1 /* Preserve */ && compilerOptions.jsx !== 3 /* ReactNative */; const jsxFactoryRefErr = diagnostics ? Diagnostics.Using_JSX_fragments_requires_fragment_factory_0_to_be_in_scope_but_it_could_not_be_found : void 0; const jsxFactorySymbol = getJsxNamespaceContainerForImplicitImport(node) ?? resolveName( node, jsxFragmentFactoryName, - compilerOptions.jsx === 1 /* Preserve */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */, + shouldModuleRefErr ? 111551 /* Value */ : 111551 /* Value */ & ~384 /* Enum */, /*nameNotFoundMessage*/ jsxFactoryRefErr, /*isUse*/ @@ -84702,7 +84714,7 @@ function createTypeChecker(host) { } } } - if (isOnlyImportableAsDefault(node.moduleSpecifier, resolvedModule) && !hasTypeJsonImportAttribute(node)) { + if (moduleKind === 199 /* NodeNext */ && isOnlyImportableAsDefault(node.moduleSpecifier, resolvedModule) && !hasTypeJsonImportAttribute(node)) { error(node.moduleSpecifier, Diagnostics.Importing_a_JSON_file_into_an_ECMAScript_module_requires_a_type_Colon_json_import_attribute_when_module_is_set_to_0, ModuleKind[moduleKind]); } } else if (noUncheckedSideEffectImports && !importClause) { @@ -131703,9 +131715,9 @@ function createSyntacticTypeNodeBuilder(options, resolver) { } if (!result && node.kind === 303 /* PropertyAssignment */) { const initializer = node.initializer; - const type = isJSDocTypeAssertion(initializer) ? getJSDocTypeAssertionType(initializer) : initializer.kind === 234 /* AsExpression */ || initializer.kind === 216 /* TypeAssertionExpression */ ? initializer.type : void 0; - if (type && !isConstTypeReference(type)) { - result = serializeExistingTypeNode(type, context); + const assertionNode = isJSDocTypeAssertion(initializer) ? getJSDocTypeAssertionType(initializer) : initializer.kind === 234 /* AsExpression */ || initializer.kind === 216 /* TypeAssertionExpression */ ? initializer.type : void 0; + if (assertionNode && !isConstTypeReference(assertionNode) && resolver.canReuseTypeNodeAnnotation(context, node, assertionNode, symbol)) { + result = serializeExistingTypeNode(assertionNode, context); } } return result ?? inferTypeOfDeclaration( diff --git a/lib/typescript.js b/lib/typescript.js index 33387eadeb847..b59020326c3c3 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -2278,7 +2278,7 @@ module.exports = __toCommonJS(typescript_exports); // src/compiler/corePublic.ts var versionMajorMinor = "5.7"; -var version = "5.7.2"; +var version = "5.7.3"; var Comparison = /* @__PURE__ */ ((Comparison3) => { Comparison3[Comparison3["LessThan"] = -1] = "LessThan"; Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo"; @@ -14547,6 +14547,7 @@ function sortAndDeduplicateDiagnostics(diagnostics) { } var targetToLibMap = /* @__PURE__ */ new Map([ [99 /* ESNext */, "lib.esnext.full.d.ts"], + [11 /* ES2024 */, "lib.es2024.full.d.ts"], [10 /* ES2023 */, "lib.es2023.full.d.ts"], [9 /* ES2022 */, "lib.es2022.full.d.ts"], [8 /* ES2021 */, "lib.es2021.full.d.ts"], @@ -14562,6 +14563,7 @@ function getDefaultLibFileName(options) { const target = getEmitScriptTarget(options); switch (target) { case 99 /* ESNext */: + case 11 /* ES2024 */: case 10 /* ES2023 */: case 9 /* ES2022 */: case 8 /* ES2021 */: @@ -75063,12 +75065,13 @@ function createTypeChecker(host) { const jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? Diagnostics.This_JSX_tag_requires_0_to_be_in_scope_but_it_could_not_be_found : void 0; const jsxFactoryNamespace = getJsxNamespace(node); const jsxFactoryLocation = isJsxOpeningLikeElement(node) ? node.tagName : node; + const shouldFactoryRefErr = compilerOptions.jsx !== 1 /* Preserve */ && compilerOptions.jsx !== 3 /* ReactNative */; let jsxFactorySym; if (!(isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) { jsxFactorySym = resolveName( jsxFactoryLocation, jsxFactoryNamespace, - compilerOptions.jsx === 1 /* Preserve */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */, + shouldFactoryRefErr ? 111551 /* Value */ : 111551 /* Value */ & ~384 /* Enum */, jsxFactoryRefErr, /*isUse*/ true @@ -75087,7 +75090,7 @@ function createTypeChecker(host) { resolveName( jsxFactoryLocation, localJsxNamespace, - compilerOptions.jsx === 1 /* Preserve */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */, + shouldFactoryRefErr ? 111551 /* Value */ : 111551 /* Value */ & ~384 /* Enum */, jsxFactoryRefErr, /*isUse*/ true @@ -78648,6 +78651,13 @@ function createTypeChecker(host) { return getIntersectionType(x); } function reportNonexistentProperty(propNode, containingType, isUncheckedJS) { + const links = getNodeLinks(propNode); + const cache = links.nonExistentPropCheckCache || (links.nonExistentPropCheckCache = /* @__PURE__ */ new Set()); + const key = `${getTypeId(containingType)}|${isUncheckedJS}`; + if (cache.has(key)) { + return; + } + cache.add(key); let errorInfo; let relatedInfo; if (!isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* Union */ && !(containingType.flags & 402784252 /* Primitive */)) { @@ -80606,12 +80616,14 @@ function createTypeChecker(host) { const sourceFileLinks = getNodeLinks(getSourceFileOfNode(node)); if (sourceFileLinks.jsxFragmentType !== void 0) return sourceFileLinks.jsxFragmentType; const jsxFragmentFactoryName = getJsxNamespace(node); - if (jsxFragmentFactoryName === "null") return sourceFileLinks.jsxFragmentType = anyType; + const shouldResolveFactoryReference = (compilerOptions.jsx === 2 /* React */ || compilerOptions.jsxFragmentFactory !== void 0) && jsxFragmentFactoryName !== "null"; + if (!shouldResolveFactoryReference) return sourceFileLinks.jsxFragmentType = anyType; + const shouldModuleRefErr = compilerOptions.jsx !== 1 /* Preserve */ && compilerOptions.jsx !== 3 /* ReactNative */; const jsxFactoryRefErr = diagnostics ? Diagnostics.Using_JSX_fragments_requires_fragment_factory_0_to_be_in_scope_but_it_could_not_be_found : void 0; const jsxFactorySymbol = getJsxNamespaceContainerForImplicitImport(node) ?? resolveName( node, jsxFragmentFactoryName, - compilerOptions.jsx === 1 /* Preserve */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */, + shouldModuleRefErr ? 111551 /* Value */ : 111551 /* Value */ & ~384 /* Enum */, /*nameNotFoundMessage*/ jsxFactoryRefErr, /*isUse*/ @@ -89305,7 +89317,7 @@ function createTypeChecker(host) { } } } - if (isOnlyImportableAsDefault(node.moduleSpecifier, resolvedModule) && !hasTypeJsonImportAttribute(node)) { + if (moduleKind === 199 /* NodeNext */ && isOnlyImportableAsDefault(node.moduleSpecifier, resolvedModule) && !hasTypeJsonImportAttribute(node)) { error2(node.moduleSpecifier, Diagnostics.Importing_a_JSON_file_into_an_ECMAScript_module_requires_a_type_Colon_json_import_attribute_when_module_is_set_to_0, ModuleKind[moduleKind]); } } else if (noUncheckedSideEffectImports && !importClause) { @@ -136663,9 +136675,9 @@ function createSyntacticTypeNodeBuilder(options, resolver) { } if (!result && node.kind === 303 /* PropertyAssignment */) { const initializer = node.initializer; - const type = isJSDocTypeAssertion(initializer) ? getJSDocTypeAssertionType(initializer) : initializer.kind === 234 /* AsExpression */ || initializer.kind === 216 /* TypeAssertionExpression */ ? initializer.type : void 0; - if (type && !isConstTypeReference(type)) { - result = serializeExistingTypeNode(type, context); + const assertionNode = isJSDocTypeAssertion(initializer) ? getJSDocTypeAssertionType(initializer) : initializer.kind === 234 /* AsExpression */ || initializer.kind === 216 /* TypeAssertionExpression */ ? initializer.type : void 0; + if (assertionNode && !isConstTypeReference(assertionNode) && resolver.canReuseTypeNodeAnnotation(context, node, assertionNode, symbol)) { + result = serializeExistingTypeNode(assertionNode, context); } } return result ?? inferTypeOfDeclaration( diff --git a/package-lock.json b/package-lock.json index 009efa478a176..abc281de52fde 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "typescript", - "version": "5.7.2", + "version": "5.7.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "typescript", - "version": "5.7.2", + "version": "5.7.3", "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", diff --git a/package.json b/package.json index fbf62429c6cf9..cd9f24a123ea3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "https://www.typescriptlang.org/", - "version": "5.7.2", + "version": "5.7.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 7b82bca47e571..d8f6c9c339fee 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -3,7 +3,7 @@ export const versionMajorMinor = "5.7"; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ -export const version = "5.7.2" as string; +export const version = "5.7.3" as string; /** * Type of objects whose values are all of the same type. diff --git a/src/testRunner/unittests/tsserver/completions.ts b/src/testRunner/unittests/tsserver/completions.ts index 88a9a4db17248..d25644c4ccae5 100644 --- a/src/testRunner/unittests/tsserver/completions.ts +++ b/src/testRunner/unittests/tsserver/completions.ts @@ -141,7 +141,7 @@ export class Component {} path: `${localAtTypes}/prop-types/package.json`, content: jsonToReadableText({ name: "@types/prop-types", - version: "15.7.3", + version: "14.7.3", }), }; const localPropTypes: File = { diff --git a/tests/baselines/reference/tsserver/completions/works-when-files-are-included-from-two-different-drives-of-windows.js b/tests/baselines/reference/tsserver/completions/works-when-files-are-included-from-two-different-drives-of-windows.js index 461f59ae7845b..c74a0de78bc4d 100644 --- a/tests/baselines/reference/tsserver/completions/works-when-files-are-included-from-two-different-drives-of-windows.js +++ b/tests/baselines/reference/tsserver/completions/works-when-files-are-included-from-two-different-drives-of-windows.js @@ -66,7 +66,7 @@ export function foo() {} //// [e:/solution/myproject/node_modules/@types/prop-types/package.json] { "name": "@types/prop-types", - "version": "15.7.3" + "version": "14.7.3" } //// [c:/typescript/node_modules/@types/react-router-dom/package.json] @@ -182,8 +182,8 @@ Info seq [hh:mm:ss:mss] Files (6) c:/home/src/tslibs/TS/Lib/lib.d.ts Default library for target 'es5' ../node_modules/@types/prop-types/index.d.ts - Imported via 'prop-types' from file '../node_modules/@types/react/index.d.ts' with packageId '@types/prop-types/index.d.ts@15.7.3' - Entry point for implicit type library 'prop-types' with packageId '@types/prop-types/index.d.ts@15.7.3' + Imported via 'prop-types' from file '../node_modules/@types/react/index.d.ts' with packageId '@types/prop-types/index.d.ts@14.7.3' + Entry point for implicit type library 'prop-types' with packageId '@types/prop-types/index.d.ts@14.7.3' ../node_modules/@types/react/index.d.ts Imported via 'react' from file 'app.js' with packageId '@types/react/index.d.ts@16.9.14' Entry point for implicit type library 'react' with packageId '@types/react/index.d.ts@16.9.14'