Update definitions for @types/istanbul-lib-source-maps (#43339)

* Updated type definitions for istanbul source maps version 4.x, as transform method now returns only coverage map

* fix: Prettier configuration to run to approve linting
This commit is contained in:
Sridhar Mallela 2020-03-31 17:10:33 -05:00 committed by GitHub
parent 3e97df05b2
commit 83fd63a9bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 38 deletions

View File

@ -1,43 +1,43 @@
// Type definitions for istanbul-lib-source-maps 1.2
// Type definitions for istanbul-lib-source-maps 4.0
// Project: https://istanbul.js.org, https://github.com/istanbuljs/istanbuljs
// Definitions by: Jason Cheatham <https://github.com/jason0x43>
// Sridhar Mallela <https://github.com/sridharmallela>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
import { CoverageMap } from 'istanbul-lib-coverage';
import { RawSourceMap } from 'source-map';
export function createSourceMapStore(
options?: Partial<MapStoreOptions>
): MapStore;
export function createSourceMapStore(options?: Partial<MapStoreOptions>): MapStore;
export interface MapStoreOptions {
verbose: boolean;
baseDir: string;
sourceStore: 'memory' | 'file';
tmpdir: string;
verbose: boolean;
baseDir: string;
sourceStore: 'memory' | 'file';
tmpdir: string;
}
export interface MapStore {
baseDir: string | null;
verbose: boolean;
sourceStore: SourceStore;
data: {
[filepath: string]: {
type: string;
data: any;
};
};
baseDir: string | null;
verbose: boolean;
sourceStore: SourceStore;
data: {
[filepath: string]: {
type: string;
data: any;
};
};
registerURL(transformedFilePath: string, sourceMapUrl: string): void;
registerMap(filename: string, sourceMap: RawSourceMap): void;
transformCoverage(
coverageMap: CoverageMap
): { map: CoverageMap; sourceFinder(path: string): string };
dispose(): void;
registerURL(transformedFilePath: string, sourceMapUrl: string): void;
registerMap(filename: string, sourceMap: RawSourceMap): void;
getSourceMapSync(filePath: string): any;
addInputSourceMapsSync(coverageData: any): void;
sourceFinder(filePath: string): string;
transformCoverage(coverageMap: CoverageMap): CoverageMap;
dispose(): void;
}
export class SourceStore {
getSource(filepath: string): string | null;
registerSource(filepath: string, sourceText: string): void;
getSource(filepath: string): string | null;
registerSource(filepath: string, sourceText: string): void;
}

View File

@ -1,24 +1,24 @@
import { createSourceMapStore } from 'istanbul-lib-source-maps';
import { CoverageMap } from 'istanbul-lib-coverage';
import { RawSourceMap } from 'source-map';
import { createSourceMapStore } from 'istanbul-lib-source-maps';
createSourceMapStore();
createSourceMapStore({});
const store = createSourceMapStore({
verbose: false,
baseDir: 'foo',
sourceStore: 'memory',
tmpdir: 'foo'
verbose: false,
baseDir: 'foo',
sourceStore: 'memory',
tmpdir: 'foo',
});
store.data['foo'].type.trim();
const sourceMap: RawSourceMap = {
version: 1 as any as string, // Fixed by https://github.com/mozilla/source-map/pull/293 but the fix is not yet published
sources: ['foo', 'bar'],
names: ['foo', 'bar'],
mappings: 'foo',
file: 'foo'
version: (1 as any) as string, // Fixed by https://github.com/mozilla/source-map/pull/293 but the fix is not yet published
sources: ['foo', 'bar'],
names: ['foo', 'bar'],
mappings: 'foo',
file: 'foo',
};
store.registerMap('foo', sourceMap);
@ -26,13 +26,12 @@ store.registerURL('foo', 'foo');
const map = new CoverageMap({});
const transformed = store.transformCoverage(map);
transformed.map.data;
transformed.sourceFinder('foo').trim();
transformed.data;
store.dispose();
store.sourceStore.registerSource('foo', 'bar');
const source = store.sourceStore.getSource('foo');
if (source != null) {
source.trim();
source.trim();
}