Skip to content

Commit fb8179c

Browse files
committed
Work around api-extractor import bug
The import expression for the ETW trace types breaks API extractor; it outputs a named import for a non-existent name in the module rather than emitting a default import. For now, redeclare the type locally and then use a conditional type to verify that what we have is compatible with the upstream type when type checking locally.
1 parent 6db765e commit fb8179c

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

Diff for: src/compiler/perfLogger.ts

+33-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
11
import { noop } from "./_namespaces/ts";
22

3-
type PerfLogger = typeof import("@microsoft/typescript-etw");
3+
/** @internal */
4+
interface PerfLogger {
5+
logEvent(msg: string): void;
6+
logErrEvent(msg: string): void;
7+
logPerfEvent(msg: string): void;
8+
logInfoEvent(msg: string): void;
9+
logStartCommand(command: string, msg: string): void;
10+
logStopCommand(command: string, msg: string): void;
11+
logStartUpdateProgram(msg: string): void;
12+
logStopUpdateProgram(msg: string): void;
13+
logStartUpdateGraph(): void;
14+
logStopUpdateGraph(): void;
15+
logStartResolveModule(name: string): void;
16+
logStopResolveModule(success: string): void;
17+
logStartParseSourceFile(filename: string): void;
18+
logStopParseSourceFile(): void;
19+
logStartReadFile(filename: string): void;
20+
logStopReadFile(): void;
21+
logStartBindFile(filename: string): void;
22+
logStopBindFile(): void;
23+
logStartScheduledOperation(operationId: string): void;
24+
logStopScheduledOperation(): void;
25+
}
26+
27+
type ImportedPerfLogger = typeof import("@microsoft/typescript-etw");
28+
29+
// Assert that our PerfLogger type is compatible with the library.
30+
// TODO(jakebailey): remove this workaround for an api-extractor bug.
31+
const _perfLoggerCorrectType: PerfLogger extends ImportedPerfLogger ? true : false = true;
32+
33+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
34+
_perfLoggerCorrectType;
35+
436
const nullLogger: PerfLogger = {
537
logEvent: noop,
638
logErrEvent: noop,

0 commit comments

Comments
 (0)