Skip to content

Commit

Permalink
fix: make performance API compatible with TypeScript 5
Browse files Browse the repository at this point in the history
Fixes #797 by removing ts performance logging (#803)
  • Loading branch information
eamodio authored Mar 5, 2023
1 parent b4f7201 commit 4b0c77a
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions src/typescript-reporter/profile/TypeScriptPerformance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import type * as ts from 'typescript';
import { Performance } from '../../profile/Performance';

interface TypeScriptPerformance {
enable(): void;
disable(): void;
mark(name: string): void;
measure(name: string, startMark?: string, endMark?: string): void;
enable?(): void;
disable?(): void;
forEachMeasure?(callback: (measureName: string, duration: number) => void): void;
}

function getTypeScriptPerformance(typescript: typeof ts): TypeScriptPerformance | undefined {
Expand All @@ -20,27 +19,17 @@ function connectTypeScriptPerformance(
const typeScriptPerformance = getTypeScriptPerformance(typescript);

if (typeScriptPerformance) {
const { mark, measure } = typeScriptPerformance;
const { enable, disable } = performance;

typeScriptPerformance.mark = (name) => {
mark(name);
performance.mark(name);
};
typeScriptPerformance.measure = (name, startMark, endMark) => {
measure(name, startMark, endMark);
performance.measure(name, startMark, endMark);
};

return {
...performance,
enable() {
enable();
typeScriptPerformance.enable();
typeScriptPerformance.enable?.();
},
disable() {
disable();
typeScriptPerformance.disable();
typeScriptPerformance.disable?.();
},
};
} else {
Expand Down

0 comments on commit 4b0c77a

Please sign in to comment.