diff --git a/apps/api-extractor/src/analyzer/TypeScriptInternals.ts b/apps/api-extractor/src/analyzer/TypeScriptInternals.ts index 63d4642446..4c35cc1ded 100644 --- a/apps/api-extractor/src/analyzer/TypeScriptInternals.ts +++ b/apps/api-extractor/src/analyzer/TypeScriptInternals.ts @@ -108,10 +108,13 @@ export class TypeScriptInternals { public static getGlobalVariableAnalyzer(program: ts.Program): IGlobalVariableAnalyzer { const anyProgram: any = program; - if (!anyProgram.getDiagnosticsProducingTypeChecker) { - throw new InternalError('Missing Program.getDiagnosticsProducingTypeChecker'); + const typeCheckerInstance: any = + anyProgram.getDiagnosticsProducingTypeChecker ?? anyProgram.getTypeChecker; + + if (!typeCheckerInstance) { + throw new InternalError('Missing Program.getDiagnosticsProducingTypeChecker or Program.getTypeChecker'); } - const typeChecker: any = anyProgram.getDiagnosticsProducingTypeChecker(); + const typeChecker: any = typeCheckerInstance(); if (!typeChecker.getEmitResolver) { throw new InternalError('Missing TypeChecker.getEmitResolver'); } diff --git a/common/changes/@microsoft/api-extractor/users-chhol-update-api-for-getDiagnosticsProducingTypeChecker_2022-05-04-21-31.json b/common/changes/@microsoft/api-extractor/users-chhol-update-api-for-getDiagnosticsProducingTypeChecker_2022-05-04-21-31.json new file mode 100644 index 0000000000..701f4b2b93 --- /dev/null +++ b/common/changes/@microsoft/api-extractor/users-chhol-update-api-for-getDiagnosticsProducingTypeChecker_2022-05-04-21-31.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/api-extractor", + "comment": "update getGlobalVariableAnalyzer to support changes to typescript internals in v4.7", + "type": "patch" + } + ], + "packageName": "@microsoft/api-extractor" +} \ No newline at end of file