Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[api-extractor] Update API Extractor to support TypeScript 5.3.3 #4408

Merged
merged 9 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/api-extractor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"resolve": "~1.22.1",
"semver": "~7.5.4",
"source-map": "~0.6.1",
"typescript": "~5.0.4"
"typescript": "5.3.3"
},
"devDependencies": {
"local-eslint-config": "workspace:*",
Expand Down
2 changes: 2 additions & 0 deletions apps/api-extractor/src/analyzer/ExportAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ export class ExportAnalyzer {
: undefined;

const resolvedModule: ts.ResolvedModuleFull | undefined = TypeScriptInternals.getResolvedModule(
this._program,
importOrExportDeclaration.getSourceFile(),
moduleSpecifier,
mode
Expand Down Expand Up @@ -882,6 +883,7 @@ export class ExportAnalyzer {
)
: undefined;
const resolvedModule: ts.ResolvedModuleFull | undefined = TypeScriptInternals.getResolvedModule(
this._program,
importOrExportDeclaration.getSourceFile(),
moduleSpecifier,
mode
Expand Down
11 changes: 8 additions & 3 deletions apps/api-extractor/src/analyzer/TypeScriptInternals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,19 @@ export class TypeScriptInternals {
* The compiler populates this cache as part of analyzing the source file.
*/
public static getResolvedModule(
program: ts.Program,
sourceFile: ts.SourceFile,
moduleNameText: string,
mode: ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined
): ts.ResolvedModuleFull | undefined {
// Compiler internal:
// https://github.com/microsoft/TypeScript/blob/v4.7.2/src/compiler/utilities.ts#L161

return (ts as any).getResolvedModule(sourceFile, moduleNameText, mode);
// https://github.com/microsoft/TypeScript/blob/v5.3.3/src/compiler/types.ts#L4698
const result: ts.ResolvedModuleWithFailedLookupLocations | undefined = (program as any).getResolvedModule(
sourceFile,
moduleNameText,
mode
);
return result?.resolvedModule;
}

/**
Expand Down
208 changes: 104 additions & 104 deletions build-tests/install-test-workspace/workspace/common/pnpm-lock.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/api-extractor",
"comment": "Update API Extractor to support TypeScript 5.3.3",
"type": "minor"
}
],
"packageName": "@microsoft/api-extractor"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/eslint-patch",
"comment": "",
"type": "none"
}
],
"packageName": "@rushstack/eslint-patch"
}
4 changes: 3 additions & 1 deletion common/config/rush/common-versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@
// For testing Heft with TS V3
"~3.9.10",
// For testing Heft with TS V4
"~4.9.5"
"~4.9.5",

"5.3.3"
],
"source-map": [
"~0.6.1" // API Extractor is using an older version of source-map because newer versions are async
Expand Down
16 changes: 11 additions & 5 deletions common/config/rush/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/rush/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": "148b38e4e98c98edfcfa2d368a33cff4b835df8f",
"pnpmShrinkwrapHash": "e42e10f7ac97560c9546f9077901b92b19a54310",
"preferredVersionsHash": "1926a5b12ac8f4ab41e76503a0d1d0dccc9c0e06"
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ export function getGitRootPath(): string {
export const GitRootPath = getGitRootPath();

function findEslintrcDirectory(fileAbsolutePath: string): string {
for (let currentDir = fileAbsolutePath; currentDir.startsWith(GitRootPath); currentDir = path.dirname(currentDir))
for (
let currentDir = fileAbsolutePath;
currentDir.startsWith(GitRootPath);
currentDir = path.dirname(currentDir)
)
if (['.eslintrc.js', '.eslintrc.cjs'].some((eslintrc) => fs.existsSync(path.join(currentDir, eslintrc))))
return currentDir;
throw new Error('Cannot locate eslintrc');
Expand Down