@adonisjs/require-ts
Version:
In memory typescript compiler
73 lines (72 loc) • 1.98 kB
TypeScript
import tsStatic from 'typescript';
import { Transformers } from '../Contracts';
/**
* Exposes the API to parse tsconfig file and cache it until the
* contents of the file are changed.
*/
export declare class Config {
private appRoot;
private cacheRoot;
private ts?;
private usesCache;
static version: string;
/**
* Hard assumption has been made that config file name
* is "tsconfig.json"
*/
private configFilePath;
/**
* Reference to the cache
*/
private cache;
/**
* Dignostic reporter to print program errors
*/
private diagnosticsReporter;
constructor(appRoot: string, cacheRoot: string, ts?: typeof tsStatic | undefined, usesCache?: boolean);
/**
* Returns the raw contents of the config file. We need to read this
* always to generate the hash and then look for the cached config
* file.
*/
private getConfigRawContents;
/**
* Parses the ts config using the typescript compiler
*/
private parseTsConfig;
/**
* Parses the cached config string as JSON. Errors
* are ignored and hence cache is ignored too
*/
private parseConfigAsJson;
/**
* Extracts transformers the tsconfig file contents
*/
private extractTransformers;
/**
* Returns the config file from the cache or returns null when there is
* no cache
*/
getCached(): {
raw: string;
cachePath: string;
cached: null | {
version: string;
options: {
compilerOptions: tsStatic.CompilerOptions;
transformers?: Transformers;
};
};
};
/**
* Parses config and returns the compiler options
*/
parse(): {
version: string;
options: null | {
compilerOptions: tsStatic.CompilerOptions;
transformers?: Transformers;
};
error: null | tsStatic.Diagnostic[];
};
}