diff --git a/.changeset/poor-bears-hear.md b/.changeset/poor-bears-hear.md new file mode 100644 index 000000000000..9bd43937027c --- /dev/null +++ b/.changeset/poor-bears-hear.md @@ -0,0 +1,5 @@ +--- +"@typescript/vfs": patch +--- + +Update for compatibility with TypeScript 6.0. diff --git a/package.json b/package.json index 21b31ec901ee..c5c793a47ccf 100644 --- a/package.json +++ b/package.json @@ -37,8 +37,8 @@ "@types/estree": "0.0.46", "@types/eslint": "7.29.0", "assert": "2.0.0", - "rollup-plugin-typescript2": "0.34.1", - "typescript": "5.9.2", + "rollup-plugin-typescript2": "0.36.0", + "typescript": "6.0.0-dev.20260213", "tslib": "^2.6.2", "prettier": "^2.0.2", "sharp": "0.28.1" diff --git a/packages/ata/tsconfig.json b/packages/ata/tsconfig.json index e228c47e9e33..8ca940e926de 100644 --- a/packages/ata/tsconfig.json +++ b/packages/ata/tsconfig.json @@ -1,11 +1,11 @@ { "compilerOptions": { "module": "ESNext", - "moduleResolution": "node", + "moduleResolution": "bundler", "strict": true, "noUncheckedIndexedAccess": true, "target": "ES2015", "declaration": false, "noEmit": true } -} \ No newline at end of file +} diff --git a/packages/glossary/scripts/generateMarkdown.ts b/packages/glossary/scripts/generateMarkdown.ts index 78c012079d48..05e3d62119ac 100644 --- a/packages/glossary/scripts/generateMarkdown.ts +++ b/packages/glossary/scripts/generateMarkdown.ts @@ -32,7 +32,7 @@ languages.forEach((lang) => { const locale = join(__dirname, "..", "copy", lang); const fallbackLocale = join(__dirname, "..", "copy", "en"); - const languageMeta = { terms: [] }; + const languageMeta: { terms: { display: string; id: string }[] } = { terms: [] }; const markdownChunks: string[] = []; const glossaryTerms = readdirSync(join(__dirname, "..", "copy", "en")).filter( diff --git a/packages/glossary/tsconfig.json b/packages/glossary/tsconfig.json index 2d3829643225..e2cd60109261 100644 --- a/packages/glossary/tsconfig.json +++ b/packages/glossary/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { "resolveJsonModule": true, - "allowJs": true + "allowJs": true, + "types": ["*"] } } diff --git a/packages/playground-worker/tsconfig.json b/packages/playground-worker/tsconfig.json index ff340edec22b..bfe69714fdfb 100644 --- a/packages/playground-worker/tsconfig.json +++ b/packages/playground-worker/tsconfig.json @@ -5,6 +5,6 @@ "target": "ES2020", "allowJs": false, "module": "esnext", - "moduleResolution": "node" + "moduleResolution": "bundler" } -} \ No newline at end of file +} diff --git a/packages/playground/src/createConfigDropdown.ts b/packages/playground/src/createConfigDropdown.ts index 030edff787e2..11be14f640cc 100644 --- a/packages/playground/src/createConfigDropdown.ts +++ b/packages/playground/src/createConfigDropdown.ts @@ -230,6 +230,7 @@ const createSelect = (title: string, id: string, blurb: string, sandbox: Sandbox .forEach(key => { // hide Latest if (key === "Latest") return + if (key === "LatestStandard") return const option = document.createElement("option") option.value = key diff --git a/packages/playground/tsconfig.json b/packages/playground/tsconfig.json index 885a5495a406..c97482469733 100644 --- a/packages/playground/tsconfig.json +++ b/packages/playground/tsconfig.json @@ -1,6 +1,7 @@ { "include": ["src"], "compilerOptions": { + "ignoreDeprecations": "6.0", "outDir": "../typescriptlang-org/static/js/playground", "jsx": "react", "target": "ES2016", diff --git a/packages/sandbox/tsconfig.json b/packages/sandbox/tsconfig.json index 2612cde3e8a0..96ba4df1278e 100644 --- a/packages/sandbox/tsconfig.json +++ b/packages/sandbox/tsconfig.json @@ -2,6 +2,7 @@ "include": ["src", "src/vendor/lzstring.min.js"], "compilerOptions": { + "ignoreDeprecations": "6.0", "outDir": "../typescriptlang-org/static/js/sandbox", "target": "ES2016", "module": "AMD", @@ -14,6 +15,7 @@ "allowJs": true, "moduleResolution": "node", "esModuleInterop": true, - "skipLibCheck": true + "skipLibCheck": true, + "types": ["*"] } } diff --git a/packages/ts-twoslasher/package.json b/packages/ts-twoslasher/package.json index 925379139949..b221e2d4b7b6 100755 --- a/packages/ts-twoslasher/package.json +++ b/packages/ts-twoslasher/package.json @@ -29,7 +29,7 @@ }, "devDependencies": { "@types/jest": "^29.5.12", - "@types/prettier": "^1.19.0", + "@types/prettier": "^2.7.3", "dts-cli": "^2.0.5", "jest": "^29.5.0", "jest-file-snapshot": "^0.3.8", diff --git a/packages/ts-twoslasher/test/results/unknown_compiler_value.json b/packages/ts-twoslasher/test/results/unknown_compiler_value.json index 09f2c8311a7a..73f8279fd3e3 100644 --- a/packages/ts-twoslasher/test/results/unknown_compiler_value.json +++ b/packages/ts-twoslasher/test/results/unknown_compiler_value.json @@ -3,4 +3,4 @@ Got TS2015 for target but it is not a supported value by the TS compiler. -Allowed values: es3,es5,es6,es2015,es2016,es2017,es2018,es2019,es2020,es2021,es2022,es2023,es2024,esnext \ No newline at end of file +Allowed values: es3,es5,es6,es2015,es2016,es2017,es2018,es2019,es2020,es2021,es2022,es2023,es2024,es2025,esnext \ No newline at end of file diff --git a/packages/ts-twoslasher/tsconfig.json b/packages/ts-twoslasher/tsconfig.json index bd2865763b5b..c7655e729aab 100644 --- a/packages/ts-twoslasher/tsconfig.json +++ b/packages/ts-twoslasher/tsconfig.json @@ -20,12 +20,12 @@ "noUnusedParameters": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, - "moduleResolution": "node", - "baseUrl": "./src", + "moduleResolution": "bundler", "paths": { - "*": ["src/*", "node_modules/*"] + "*": ["./src/*"] }, "jsx": "react", - "esModuleInterop": true + "esModuleInterop": true, + "types": ["*"] } } diff --git a/packages/tsconfig-reference/package.json b/packages/tsconfig-reference/package.json index 717f31803fd9..e16ae25ff370 100644 --- a/packages/tsconfig-reference/package.json +++ b/packages/tsconfig-reference/package.json @@ -27,6 +27,7 @@ "@types/json-schema": "^7.0.15", "ts-node": "*", "typescript": "*", + "typescript-for-docs": "npm:typescript@5.9.3", "xml-js": "^1.6.11" }, "type": "module" diff --git a/packages/tsconfig-reference/scripts/cli/generateJSON.ts b/packages/tsconfig-reference/scripts/cli/generateJSON.ts index 1af3baa73109..6a8870128d99 100644 --- a/packages/tsconfig-reference/scripts/cli/generateJSON.ts +++ b/packages/tsconfig-reference/scripts/cli/generateJSON.ts @@ -7,7 +7,7 @@ */ console.log("TSConfig Ref: JSON for CLI Opts"); -import ts from "typescript"; +import ts from "typescript-for-docs"; import { CommandLineOptionBase } from "../types"; import { writeFileSync, readFileSync } from "fs"; @@ -22,11 +22,11 @@ import { } from "../tsconfigRules.js"; import { CompilerOptionName } from "../../data/_types"; -const toJSONString = (obj) => +const toJSONString = (obj: any) => prettier.format(JSON.stringify(obj, null, " "), { filepath: "thing.json" }); -const writeJSON = (name, obj) => +const writeJSON = (name: string, obj: any) => writeFileSync(new URL(`../../data/${name}`, import.meta.url), toJSONString(obj)); -const writeString = (name, text) => +const writeString = (name: string, text: string) => writeFileSync( new URL(`../../data/${name}`, import.meta.url), prettier.format(text, { filepath: name }) @@ -44,7 +44,7 @@ export interface CompilerOptionJSON extends CommandLineOptionBase { hostObj: string; } -const tsconfigOpts = JSON.parse(readFileSync(join("data", "tsconfigOpts.json"), "utf8")); +const tsconfigOpts: CompilerOptionJSON[] = JSON.parse(readFileSync(join("data", "tsconfigOpts.json"), "utf8")); const notCompilerFlags = [ // @ts-ignore @@ -73,7 +73,7 @@ filteredOptions.forEach((option) => { // Convert JS Map types to a JSONable obj if ("type" in option && typeof option.type === "object" && "get" in option.type) { // Option definitely has a map obj, need to resolve it - const newOptions = {}; + const newOptions: Record = {}; option.type.forEach((v, k) => (newOptions[k] = v)); // @ts-ignore option.type = newOptions; @@ -88,15 +88,15 @@ filteredOptions.forEach((option) => { } if (name in allowedValues) { - option.allowedValues = allowedValues[name]; + option.allowedValues = (allowedValues as any)[name]; } if (name in configToRelease) { - option.releaseVersion = configToRelease[name]; + option.releaseVersion = (configToRelease as any)[name]; } if (name in defaultsForOptions) { - const defaultValue = defaultsForOptions[name]; + const defaultValue = (defaultsForOptions as any)[name]; option.defaultValue = Array.isArray(defaultValue) ? defaultValue.join(" ") : defaultValue; } diff --git a/packages/tsconfig-reference/scripts/cli/generateMarkdown.ts b/packages/tsconfig-reference/scripts/cli/generateMarkdown.ts index 82ef44d058fa..47b845509a9a 100644 --- a/packages/tsconfig-reference/scripts/cli/generateMarkdown.ts +++ b/packages/tsconfig-reference/scripts/cli/generateMarkdown.ts @@ -15,7 +15,7 @@ import prettier from "prettier"; import { CompilerOptionJSON } from "./generateJSON.js"; import { parseMarkdown } from "../tsconfigRules.js"; -const cliOpts = JSON.parse(readFileSync(join("data", "cliOpts.json"), "utf8")); +const cliOpts: Record = JSON.parse(readFileSync(join("data", "cliOpts.json"), "utf8")); const knownTypes: Record = {}; @@ -107,14 +107,14 @@ languages.forEach((lang) => { markdownChunks.push(` ${parseMarkdown(optType)}`); if (!opts?.noDefaults) { - markdownChunks.push(` ${parseMarkdown(option.defaultValue)}`); + markdownChunks.push(` ${parseMarkdown(option.defaultValue ?? "")}`); } markdownChunks.push(``); // Add a new row under the current one for the description, this uses the 'odd' / 'even' classes // to fake looking like a single row markdownChunks.push(``); - markdownChunks.push(`${parseMarkdown(description)}`.trim()); + markdownChunks.push(`${parseMarkdown(description ?? "")}`.trim()); markdownChunks.push(`\n`); }); markdownChunks.push(`\n`); diff --git a/packages/tsconfig-reference/scripts/msbuild/generateJSON.ts b/packages/tsconfig-reference/scripts/msbuild/generateJSON.ts index 7654f09cb896..bb4e42159b4c 100644 --- a/packages/tsconfig-reference/scripts/msbuild/generateJSON.ts +++ b/packages/tsconfig-reference/scripts/msbuild/generateJSON.ts @@ -7,9 +7,9 @@ import { readFileSync, writeFileSync } from "fs"; import { join } from "path"; import prettier from "prettier"; -const toJSONString = (obj) => +const toJSONString = (obj: any) => prettier.format(JSON.stringify(obj, null, " "), { filepath: "thing.json" }); -const writeJSON = (name, obj) => +const writeJSON = (name: string, obj: any) => writeFileSync( new URL(`../../data/${name}`, import.meta.url), toJSONString(obj) @@ -34,10 +34,10 @@ if (!config) { const skip = ["TypeScriptCodePage", "TypeScriptExperimentalAsyncFunctions", "TypeScriptOutFile"]; -const json = config.TypeScriptBuildConfigurations.map((config) => { +const json = config.TypeScriptBuildConfigurations!.map((config) => { const tscCLIName = config._text.includes("--") && config._text.trim().slice(2).split("--")[1].split(" ")[0]; - const configName = config._attributes.Condition.split("(")[1].split(")")[0]; + const configName = config._attributes!.Condition.split("(")[1].split(")")[0]; return { tscCLIName, diff --git a/packages/tsconfig-reference/scripts/msbuild/generateMarkdown.ts b/packages/tsconfig-reference/scripts/msbuild/generateMarkdown.ts index 00f93c6cff61..74c4f9bdc75a 100644 --- a/packages/tsconfig-reference/scripts/msbuild/generateMarkdown.ts +++ b/packages/tsconfig-reference/scripts/msbuild/generateMarkdown.ts @@ -15,6 +15,7 @@ import matter from "gray-matter"; import prettier from "prettier"; import remark from "remark"; +// @ts-ignore - no types available import remarkHTML from "remark-html"; // @ts-ignore @@ -46,7 +47,7 @@ languages.forEach((lang) => { ); }; - function renderTable(title: string, options: { tscCLIName: string; configName }[]) { + function renderTable(title: string, options: { tscCLIName: string; configName: string }[]) { markdownChunks.push(`

${title}

`); markdownChunks.push(` diff --git a/packages/tsconfig-reference/scripts/schema/downloadSchemaBase.ts b/packages/tsconfig-reference/scripts/schema/downloadSchemaBase.ts index a195f512af10..a3daf6d08895 100644 --- a/packages/tsconfig-reference/scripts/schema/downloadSchemaBase.ts +++ b/packages/tsconfig-reference/scripts/schema/downloadSchemaBase.ts @@ -5,8 +5,8 @@ import { writeFileSync, existsSync, mkdirSync } from "fs"; import { join } from "path"; -const getFileAndStoreLocally = async (url, path, editFunc) => { - const editingFunc = editFunc ? editFunc : (text) => text; +const getFileAndStoreLocally = async (url: string, path: string, editFunc?: (text: string) => string) => { + const editingFunc = editFunc ? editFunc : (text: string) => text; const packageJSON = await fetch(url); const contents = await packageJSON.text(); writeFileSync(new URL(path, import.meta.url), editingFunc(contents), "utf8"); diff --git a/packages/tsconfig-reference/scripts/schema/generateJSON.ts b/packages/tsconfig-reference/scripts/schema/generateJSON.ts index 72319b637464..70aefb45413f 100644 --- a/packages/tsconfig-reference/scripts/schema/generateJSON.ts +++ b/packages/tsconfig-reference/scripts/schema/generateJSON.ts @@ -15,13 +15,13 @@ import { join } from "path"; import { fileURLToPath } from "url"; import prettier from "prettier"; import { CompilerOptionName } from "../../data/_types"; -import ts from "typescript"; +import ts from "typescript-for-docs"; import type { JSONSchema7 } from "json-schema"; import type { CommandLineOption } from "../tsconfigRules.js"; -const toJSONString = (obj) => +const toJSONString = (obj: any) => prettier.format(JSON.stringify(obj, null, " "), { filepath: "thing.json" }); -const writeJSON = (name, obj) => +const writeJSON = (name: string, obj: any) => writeFileSync(new URL(`result/${name}`, import.meta.url), toJSONString(obj)); export interface CompilerOptionJSON extends CommandLineOptionBase { @@ -40,7 +40,7 @@ const schemaBase = JSON.parse( readFileSync(join("scripts", "schema", "vendor", "base.json"), "utf8") ) as typeof import("./vendor/base.json"); -const tsconfigOpts = JSON.parse(readFileSync(join("data", "tsconfigOpts.json"), "utf8")) as any; +const tsconfigOpts: CompilerOptionJSON[] = JSON.parse(readFileSync(join("data", "tsconfigOpts.json"), "utf8")); // Cut down the list const filteredOptions = tsconfigOpts @@ -70,10 +70,10 @@ filteredOptions.forEach((option) => { if (okToSkip.includes(name)) return; const sectionsPath = new URL(`../../copy/en/options/${name}.md`, import.meta.url); - let section; - if (schemaCompilerOpts[name]) section = schemaCompilerOpts; - if (schemaWatchOpts[name]) section = schemaWatchOpts; - if (schemaBuildOpts[name]) section = schemaBuildOpts; + let section: Record | undefined; + if ((schemaCompilerOpts as Record)[name]) section = schemaCompilerOpts; + if ((schemaWatchOpts as Record)[name]) section = schemaWatchOpts; + if ((schemaBuildOpts as Record)[name]) section = schemaBuildOpts; if (!section) { const title = `Issue creating JSON Schema for tsconfig`; @@ -81,14 +81,14 @@ filteredOptions.forEach((option) => { const msg = `You need to add it to the file: packages/tsconfig-reference/scripts/schema/vendor/base.json - something like: "${name}": { - "description": "${option.description.message}", + "description": "${option.description?.message}", "type": "boolean", "default": false }, You're also probably going to need to make the new Markdown file for the compiler flag, run: -\n echo '---\\ndisplay: "${option.name}"\\noneline: "Does something"\\n---\\n${option.description.message}\\n ' > ${fileURLToPath(sectionsPath)}\n\nThen add some docs and run: \n> pnpm run --filter=tsconfig-reference build\n\n +\n echo '---\\ndisplay: "${option.name}"\\noneline: "Does something"\\n---\\n${option.description?.message}\\n ' > ${fileURLToPath(sectionsPath)}\n\nThen add some docs and run: \n> pnpm run --filter=tsconfig-reference build\n\n `; throw new Error([title, headline, msg, ""].join("\n\n")); @@ -100,7 +100,7 @@ You're also probably going to need to make the new Markdown file for the compile } catch (error) { // prettier-ignore throw new Error( - `\n echo '---\\ndisplay: "${option.name}"\\noneline: "Does something" \\n---\\n${option.description.message.replace(/'/g, "`")}\\n ' > ${fileURLToPath(sectionsPath)}\n\nThen add some docs and run: \n> pnpm run --filter=tsconfig-reference build\n\n` + `\n echo '---\\ndisplay: "${option.name}"\\noneline: "Does something" \\n---\\n${option.description?.message.replace(/'/g, "`")}\\n ' > ${fileURLToPath(sectionsPath)}\n\nThen add some docs and run: \n> pnpm run --filter=tsconfig-reference build\n\n` ); } @@ -140,7 +140,7 @@ for (const [properties, options] of [ (option) => option.name === name && option.category?.key !== "Command_line_Options_6171" ); if (!option) { - properties[name] = undefined; + (properties as Record)[name] = undefined; } else if (option.type === "list") { updateItemsSchema( ((optionSchema as Extract).items as never) || [], diff --git a/packages/tsconfig-reference/scripts/tsconfig/generateJSON.ts b/packages/tsconfig-reference/scripts/tsconfig/generateJSON.ts index 397fde24d3d2..a1a4f98aeafd 100644 --- a/packages/tsconfig-reference/scripts/tsconfig/generateJSON.ts +++ b/packages/tsconfig-reference/scripts/tsconfig/generateJSON.ts @@ -8,7 +8,7 @@ console.log("TSConfig Ref: JSON for TSConfig"); -import ts from "typescript"; +import ts from "typescript-for-docs"; import { CommandLineOptionBase } from "../types"; import { writeFileSync } from "fs"; @@ -27,14 +27,14 @@ import { } from "../tsconfigRules.js"; import { CompilerOptionName } from "../../data/_types"; -const toJSONString = (obj) => +const toJSONString = (obj: any) => prettier.format(JSON.stringify(obj, null, " "), { filepath: "thing.json" }); -const writeJSON = (name, obj) => +const writeJSON = (name: string, obj: any) => writeFileSync( new URL(`../../data/${name}`, import.meta.url), toJSONString(obj) ); -const writeString = (name, text) => +const writeString = (name: string, text: string) => writeFileSync( new URL(`../../data/${name}`, import.meta.url), prettier.format(text, { filepath: name }) @@ -147,7 +147,7 @@ allOptions.forEach((option) => { // Convert JS Map types to a JSONable obj if ("type" in option && typeof option.type === "object" && "get" in option.type) { // Option definitely has a map obj, need to resolve it - const newOptions = {}; + const newOptions: Record = {}; option.type.forEach((v, k) => (newOptions[k] = v)); // @ts-ignore option.type = newOptions; @@ -155,8 +155,8 @@ allOptions.forEach((option) => { // Convert categories to be something which can be looked up if ("category" in option) { - categories.add(option.category); - option.categoryCode = option.category.code; + categories.add(option.category!); + option.categoryCode = option.category!.code; option.category = undefined; } else if (option.name in additionalOptionDescriptors) { // Set category code manually because some options have no category @@ -182,15 +182,15 @@ allOptions.forEach((option) => { } if (name in allowedValues) { - option.allowedValues = allowedValues[name]; + option.allowedValues = (allowedValues as any)[name]; } if (name in configToRelease) { - option.releaseVersion = configToRelease[name]; + option.releaseVersion = (configToRelease as any)[name]; } if (name in defaultsForOptions) { - const defaultValue = defaultsForOptions[name]; + const defaultValue = (defaultsForOptions as any)[name]; option.defaultValue = Array.isArray(defaultValue) ? defaultValue.join(" ") : defaultValue; } @@ -213,7 +213,7 @@ writeString( .join("' | '")}'` ); -const categoryMap = {}; +const categoryMap: Record = {}; categories.forEach((c) => (categoryMap[c.code] = c)); // Add custom categories, for custom compiler flags diff --git a/packages/tsconfig-reference/scripts/tsconfig/generateMarkdown.ts b/packages/tsconfig-reference/scripts/tsconfig/generateMarkdown.ts index 6c338f6f8966..fd06599cfd77 100644 --- a/packages/tsconfig-reference/scripts/tsconfig/generateMarkdown.ts +++ b/packages/tsconfig-reference/scripts/tsconfig/generateMarkdown.ts @@ -25,7 +25,7 @@ import { fileURLToPath } from "url"; import * as assert from "assert"; import matter from "gray-matter"; import prettier from "prettier"; -import ts from "typescript"; +import ts from "typescript-for-docs"; import { CompilerOptionJSON } from "./generateJSON.js"; import { @@ -36,8 +36,8 @@ import { parseMarkdown, } from "../tsconfigRules.js"; -const options = JSON.parse(readFileSync(join("data", "tsconfigOpts.json"), "utf8")); -const categories = JSON.parse(readFileSync(join("data", "tsconfigCategories.json"), "utf8")); +const options: CompilerOptionJSON[] = JSON.parse(readFileSync(join("data", "tsconfigOpts.json"), "utf8")); +const categories: Record = JSON.parse(readFileSync(join("data", "tsconfigCategories.json"), "utf8")); const orderedCategories = [ "Project_Files_0", @@ -130,7 +130,7 @@ languages.forEach((lang) => { ); // Intro to the section - const sectionsPath = getPathInLocale(join("sections", section.name + ".md")); + const sectionsPath = getPathInLocale(join("sections", section.name + ".md"))!; const sectionsFile = matter.read(fileURLToPath(sectionsPath)); mdChunks.push("\n" + sectionsFile.content + "\n"); @@ -138,7 +138,7 @@ languages.forEach((lang) => { if (sectionCategories.length > 1) { mdChunks.push(`