Skip to content

Commit

Permalink
[api-extractor] Upgrade bundled TypeScript to 5.7 (#4815)
Browse files Browse the repository at this point in the history
* WIP: [api-extractor] Upgrade bundled TypeScript to 5.5

1. Upgrade TypeScript to `5.5.2`
2. Upgrade @typescript-eslint/parser to `7.14.1`
3. Adopt breaking changes of typescript-eslint

* rush change

* Upgrade API Extractor's bundled TypeScript version to 5.7.2

* Update TypeScriptInternals.ts to reflect changes in TypeScript 5.7.2
NOTE: This is a type signature change that didn't affect the runtime contract; it should be fully backwards compatible

* rush update

* Fix a warning caused by TypeScript 5.7.2 strict checks complaining about resolve() signatures being inconsistent between @types/node/module.d.ts and lib.dom.d.ts:

Warning: C:/Git/rushstack/common/temp/default/node_modules/.pnpm/@types[email protected]/node_modules/@types/node/module.d.ts:210:13 - (TS2386) Overload signatures must all be optional or required.

* Temporarily suppress warning caused by TypeScript 5.7.2 being incompatible with @types/[email protected]:

Warning: C:\Git\rushstack\common\temp\default\node_modules\.pnpm\@types[email protected]\node_modules\@types\node\ts3.2\globals.d.ts:10:11 - (TS2320) Interface 'Buffer' cannot simultaneously extend types 'Uint8Array<ArrayBuffer>' and 'Uint8Array<ArrayBufferLike>'.
Named property 'buffer' of types 'Uint8Array<ArrayBuffer>' and 'Uint8Array<ArrayBufferLike>' are not identical.

* rush change

---------

Co-authored-by: Qingyu Wang <[email protected]>
Co-authored-by: Pete Gonzalez <[email protected]>
  • Loading branch information
3 people authored Jan 7, 2025
1 parent d716cce commit 62825ff
Show file tree
Hide file tree
Showing 24 changed files with 61 additions and 42 deletions.
2 changes: 1 addition & 1 deletion apps/api-extractor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"resolve": "~1.22.1",
"semver": "~7.5.4",
"source-map": "~0.6.1",
"typescript": "5.4.2"
"typescript": "5.7.2"
},
"devDependencies": {
"@rushstack/heft-node-rig": "2.6.44",
Expand Down
4 changes: 2 additions & 2 deletions apps/api-extractor/src/analyzer/TypeScriptInternals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ export class TypeScriptInternals {
* Gets the mode required for module resolution required with the addition of Node16/nodenext
*/
public static getModeForUsageLocation(
file: { impliedNodeFormat?: ts.SourceFile['impliedNodeFormat'] },
file: ts.SourceFile,
usage: ts.StringLiteralLike,
compilerOptions: ts.CompilerOptions
): ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined {
// Compiler internal:
// https://github.com/microsoft/TypeScript/blob/v4.7.2/src/compiler/program.ts#L568
// https://github.com/microsoft/TypeScript/blob/v5.7.2/src/compiler/program.ts#L940

return ts.getModeForUsageLocation?.(file, usage, compilerOptions);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/api-extractor/src/generators/ApiModelGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export class ApiModelGenerator {
}

private _tryFindFunctionDeclaration(astDeclaration: AstDeclaration): ts.FunctionDeclaration | undefined {
const children: ts.Node[] = astDeclaration.declaration.getChildren(
const children: readonly ts.Node[] = astDeclaration.declaration.getChildren(
astDeclaration.declaration.getSourceFile()
);
return children.find(ts.isFunctionTypeNode) as ts.FunctionDeclaration | undefined;
Expand Down
2 changes: 1 addition & 1 deletion build-tests/api-documenter-scenarios/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"experimentalDecorators": true,
"strictNullChecks": true,
"types": ["node", "jest"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable"],
"outDir": "lib"
},
"include": ["src/**/*.ts"]
Expand Down
2 changes: 1 addition & 1 deletion build-tests/api-extractor-d-cts-test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"experimentalDecorators": true,
"strictNullChecks": true,
"types": ["node", "jest"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable"],
"outDir": "lib"
},
"include": ["src/**/*.cts", "typings/tsd.d.ts"]
Expand Down
2 changes: 1 addition & 1 deletion build-tests/api-extractor-d-mts-test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"experimentalDecorators": true,
"strictNullChecks": true,
"types": ["node", "jest"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable"],
"outDir": "lib"
},
"include": ["src/**/*.mts", "typings/tsd.d.ts"]
Expand Down
2 changes: 1 addition & 1 deletion build-tests/api-extractor-lib1-test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"sourceMap": true,
"experimentalDecorators": true,
"strictNullChecks": true,
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable"],
"outDir": "lib"
},
"include": ["src/**/*.ts"]
Expand Down
2 changes: 1 addition & 1 deletion build-tests/api-extractor-lib2-test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"experimentalDecorators": true,
"strictNullChecks": true,
"types": ["node", "jest"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable"],
"outDir": "lib"
},
"include": ["src/**/*.ts", "typings/tsd.d.ts"]
Expand Down
2 changes: 1 addition & 1 deletion build-tests/api-extractor-lib3-test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"experimentalDecorators": true,
"strictNullChecks": true,
"types": ["node", "jest"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable"],
"outDir": "lib"
},
"include": ["src/**/*.ts", "typings/tsd.d.ts"]
Expand Down
2 changes: 1 addition & 1 deletion build-tests/api-extractor-lib4-test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"experimentalDecorators": true,
"strictNullChecks": true,
"types": ["node", "jest"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable"],
"outDir": "lib"
},
"include": ["src/**/*.ts", "typings/tsd.d.ts"]
Expand Down
2 changes: 1 addition & 1 deletion build-tests/api-extractor-lib5-test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"experimentalDecorators": true,
"strictNullChecks": true,
"types": ["node", "jest"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable"],
"outDir": "lib"
},
"include": ["src/**/*.ts", "typings/tsd.d.ts"]
Expand Down
2 changes: 1 addition & 1 deletion build-tests/api-extractor-test-01/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"strictNullChecks": true,
"esModuleInterop": true,
"types": ["node", "jest"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable"],
"outDir": "lib"
},
"include": ["src/**/*.ts", "typings/tsd.d.ts"]
Expand Down
2 changes: 1 addition & 1 deletion build-tests/api-extractor-test-02/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"strictNullChecks": true,
"esModuleInterop": true,
"types": ["node"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable"],
"outDir": "lib"
},
"include": ["src/**/*.ts", "typings/tsd.d.ts"]
Expand Down
2 changes: 1 addition & 1 deletion build-tests/api-extractor-test-03/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"strictNullChecks": true,
"esModuleInterop": true,
"types": ["node", "jest"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable"],
"outDir": "lib"
},
"include": ["src/**/*.ts", "typings/tsd.d.ts"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"declarationMap": true,
"experimentalDecorators": true,
"strictNullChecks": true,
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable"],
"outDir": "lib"
},
"include": ["src/**/*.ts", "typings/tsd.d.ts"]
Expand Down
2 changes: 1 addition & 1 deletion build-tests/api-extractor-test-04/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"strictNullChecks": true,
"esModuleInterop": true,
"types": [],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable", "dom"],
"lib": ["es5", "scripthost", "es2015.collection", "es2015.promise", "es2015.iterable"],
"outDir": "lib"
},
"include": ["src/**/*.ts", "typings/tsd.d.ts"]
Expand Down
5 changes: 4 additions & 1 deletion build-tests/heft-typescript-v2-test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

"module": "commonjs",
"target": "es2017",
"lib": ["es2017"]
"lib": ["es2017"],

// TODO: REVERT THIS AFTER WE UPGRADE heft-typescript-v2-test TO A NEWER VERSION
"skipLibCheck": true
},
"include": ["src/**/*.ts", "src/**/*.tsx"],
"exclude": ["node_modules", "lib"]
Expand Down
10 changes: 10 additions & 0 deletions common/changes/@microsoft/api-extractor/main_2024-06-27-03-27.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/api-extractor",
"comment": "Upgrade the bundled compiler engine to TypeScript 5.7.2",
"type": "minor"
}
],
"packageName": "@microsoft/api-extractor"
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"~4.9.5",

// API Extractor bundles a specific TypeScript version because it calls internal APIs
"5.4.2"
"5.7.2"
],
"source-map": [
"~0.6.1" // API Extractor is using an older version of source-map because newer versions are async
Expand Down
34 changes: 17 additions & 17 deletions common/config/subspaces/build-tests-subspace/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions common/config/subspaces/build-tests-subspace/repo-state.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
{
"pnpmShrinkwrapHash": "bd75fc59a5df40deec1cf3db51e99ab1a7eb35f6",
"pnpmShrinkwrapHash": "cc2a213121844e88f739b521181daa5d860d33b2",
"preferredVersionsHash": "ce857ea0536b894ec8f346aaea08cfd85a5af648",
"packageJsonInjectedDependenciesHash": "3f1f7f2e64fc15d64eef6c0311adc38dff344509"
"packageJsonInjectedDependenciesHash": "7b4bb13bdb42ab5aada7a6f5ab8ec6694ea61721"
}
2 changes: 1 addition & 1 deletion common/config/subspaces/default/common-versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"~4.9.5",

// API Extractor bundles a specific TypeScript version because it calls internal APIs
"5.4.2"
"5.7.2"
],
"source-map": [
"~0.6.1" // API Extractor is using an older version of source-map because newer versions are async
Expand Down
10 changes: 8 additions & 2 deletions common/config/subspaces/default/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion common/config/subspaces/default/repo-state.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
{
"pnpmShrinkwrapHash": "7b913e5ca364b30654436bba1a36ea570496f25c",
"pnpmShrinkwrapHash": "77d6789469edc916cd005c6b493ab4d37d68ed64",
"preferredVersionsHash": "ce857ea0536b894ec8f346aaea08cfd85a5af648"
}

0 comments on commit 62825ff

Please sign in to comment.