diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 8995900e3e..d2aacbd9ed 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -41,6 +41,7 @@ // Minh Son Nguyen // Junxiao Shi // Ilia Baryshnikov +// Surasak Chaisurin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // NOTE: These definitions support NodeJS and TypeScript 3.5. diff --git a/types/node/perf_hooks.d.ts b/types/node/perf_hooks.d.ts index bf44d446eb..dbedf2c5ea 100644 --- a/types/node/perf_hooks.d.ts +++ b/types/node/perf_hooks.d.ts @@ -1,5 +1,7 @@ -declare module "perf_hooks" { - import { AsyncResource } from "async_hooks"; +declare module 'perf_hooks' { + import { AsyncResource } from 'async_hooks'; + + type EntryType = 'node' | 'mark' | 'measure' | 'gc' | 'function' | 'http2' | 'http'; interface PerformanceEntry { /** @@ -22,7 +24,7 @@ declare module "perf_hooks" { * The type of the performance entry. * Currently it may be one of: 'node', 'mark', 'measure', 'gc', or 'function'. */ - readonly entryType: string; + readonly entryType: EntryType; /** * When performanceEntry.entryType is equal to 'gc', the performance.kind property identifies @@ -133,7 +135,7 @@ declare module "perf_hooks" { * @param type * @return list of all PerformanceEntry objects */ - getEntriesByName(name: string, type?: string): PerformanceEntry[]; + getEntriesByName(name: string, type?: EntryType): PerformanceEntry[]; /** * Returns a list of all PerformanceEntry objects in chronological order with respect to performanceEntry.startTime @@ -141,7 +143,7 @@ declare module "perf_hooks" { * @param type * @return list of all PerformanceEntry objects */ - getEntriesByType(type: string): PerformanceEntry[]; + getEntriesByType(type: EntryType): PerformanceEntry[]; /** * Creates a new PerformanceMark entry in the Performance Timeline. @@ -202,13 +204,13 @@ declare module "perf_hooks" { * @return a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime * whose performanceEntry.name is equal to name, and optionally, whose performanceEntry.entryType is equal to type. */ - getEntriesByName(name: string, type?: string): PerformanceEntry[]; + getEntriesByName(name: string, type?: EntryType): PerformanceEntry[]; /** * @return Returns a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime * whose performanceEntry.entryType is equal to type. */ - getEntriesByType(type: string): PerformanceEntry[]; + getEntriesByType(type: EntryType): PerformanceEntry[]; } type PerformanceObserverCallback = (list: PerformanceObserverEntryList, observer: PerformanceObserver) => void; @@ -227,7 +229,7 @@ declare module "perf_hooks" { * Property buffered defaults to false. * @param options */ - observe(options: { entryTypes: string[], buffered?: boolean }): void; + observe(options: { entryTypes: EntryType[]; buffered?: boolean }): void; } namespace constants {