Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
);
let opts: CompilerOptions = {
...config,
// Always emit output
noEmit: false,
noEmitOnError: false,
declaration: true,
declarationMap: true,
isolatedModules: false,
emitDeclarationOnly: true,
outFile: 'index.d.ts',
moduleResolution: ts.ModuleResolutionKind.NodeJs,
};
let host = new CompilerHost(options.inputFS, ts);
// $FlowFixMe
let program = ts.createProgram([asset.filePath], opts, host);
let includedFiles = program
.getSourceFiles()
.filter(file => path.normalize(file.fileName) !== asset.filePath)
.map(file => ({filePath: file.fileName}));
let mainModuleName = path
.relative(program.getCommonSourceDirectory(), asset.filePath)
.slice(0, -path.extname(asset.filePath).length);
let moduleGraph = new TSModuleGraph(ts, mainModuleName);
program.emit(undefined, undefined, undefined, true, {
afterDeclarations: [
// 1. Build module graph
async validate({asset, config, options}) {
let ts = await options.packageManager.require('typescript', asset.filePath);
// This should never happen...
if (!config) return;
let {baseDir, configHash, tsconfig} = config;
if (tsconfig && !langServiceCache[configHash]) {
let parsedCommandLine = ts.parseJsonConfigFileContent(
tsconfig,
ts.sys,
baseDir,
);
langServiceCache[configHash] = ts.createLanguageService(
new LanguageServiceHost(options.inputFS, ts, parsedCommandLine),
ts.createDocumentRegistry(),
);
}
if (!langServiceCache[configHash]) return;
const diagnostics = langServiceCache[configHash].getSemanticDiagnostics(
asset.filePath,
);
let validatorResult = {
warnings: [],
errors: [],
};
if (diagnostics.length > 0) {
async loadConfig({config, options}) {
await loadTSConfig(config, options);
},
async loadConfig({config, options}) {
await loadTSConfig(config, options);
},