UNPKG

3.31 kBTypeScriptView Raw
1import type * as _ts from 'typescript';
2/**
3 * Common TypeScript interfaces between versions. We endeavour to write ts-node's own code against these types instead
4 * of against `import "typescript"`, though we are not yet doing this consistently.
5 *
6 * Sometimes typescript@next adds an API we need to use. But we build ts-node against typescript@latest.
7 * In these cases, we must declare that API explicitly here. Our declarations include the newer typescript@next APIs.
8 * Importantly, these re-declarations are *not* TypeScript internals. They are public APIs that only exist in
9 * pre-release versions of typescript.
10 */
11export interface TSCommon {
12 version: typeof _ts.version;
13 sys: typeof _ts.sys;
14 ScriptSnapshot: typeof _ts.ScriptSnapshot;
15 displayPartsToString: typeof _ts.displayPartsToString;
16 createLanguageService: typeof _ts.createLanguageService;
17 getDefaultLibFilePath: typeof _ts.getDefaultLibFilePath;
18 getPreEmitDiagnostics: typeof _ts.getPreEmitDiagnostics;
19 flattenDiagnosticMessageText: typeof _ts.flattenDiagnosticMessageText;
20 transpileModule: typeof _ts.transpileModule;
21 ModuleKind: TSCommon.ModuleKindEnum;
22 ScriptTarget: typeof _ts.ScriptTarget;
23 findConfigFile: typeof _ts.findConfigFile;
24 readConfigFile: typeof _ts.readConfigFile;
25 parseJsonConfigFileContent: typeof _ts.parseJsonConfigFileContent;
26 formatDiagnostics: typeof _ts.formatDiagnostics;
27 formatDiagnosticsWithColorAndContext: typeof _ts.formatDiagnosticsWithColorAndContext;
28 createDocumentRegistry: typeof _ts.createDocumentRegistry;
29 JsxEmit: typeof _ts.JsxEmit;
30 createModuleResolutionCache: typeof _ts.createModuleResolutionCache;
31 resolveModuleName: typeof _ts.resolveModuleName;
32 resolveModuleNameFromCache: typeof _ts.resolveModuleNameFromCache;
33 resolveTypeReferenceDirective: typeof _ts.resolveTypeReferenceDirective;
34 createIncrementalCompilerHost: typeof _ts.createIncrementalCompilerHost;
35 createSourceFile: typeof _ts.createSourceFile;
36 getDefaultLibFileName: typeof _ts.getDefaultLibFileName;
37 createIncrementalProgram: typeof _ts.createIncrementalProgram;
38 createEmitAndSemanticDiagnosticsBuilderProgram: typeof _ts.createEmitAndSemanticDiagnosticsBuilderProgram;
39 Extension: typeof _ts.Extension;
40 ModuleResolutionKind: typeof _ts.ModuleResolutionKind;
41}
42export declare namespace TSCommon {
43 interface LanguageServiceHost extends _ts.LanguageServiceHost {
44 }
45 type ModuleResolutionHost = _ts.ModuleResolutionHost;
46 type ParsedCommandLine = _ts.ParsedCommandLine;
47 type ResolvedModule = _ts.ResolvedModule;
48 type ResolvedTypeReferenceDirective = _ts.ResolvedTypeReferenceDirective;
49 type CompilerOptions = _ts.CompilerOptions;
50 type ResolvedProjectReference = _ts.ResolvedProjectReference;
51 type ResolvedModuleWithFailedLookupLocations = _ts.ResolvedModuleWithFailedLookupLocations;
52 type FileReference = _ts.FileReference;
53 type SourceFile = _ts.SourceFile;
54 type ModuleKindEnum = typeof _ts.ModuleKind & {
55 Node16: typeof _ts.ModuleKind extends {
56 Node16: any;
57 } ? typeof _ts.ModuleKind['Node16'] : 100;
58 };
59 namespace ModuleKind {
60 type CommonJS = _ts.ModuleKind.CommonJS;
61 type ESNext = _ts.ModuleKind.ESNext;
62 }
63}