mirror of
https://github.com/ezolenko/rollup-plugin-typescript2.git
synced 2025-12-08 19:06:16 +00:00
refactor: move snapshot check into typecheckFile (#391)
- just slightly simplify / DRY up repeated code - this matches the style of some of the other functions in the codebase, such as `emitDeclaration`, `getAllReferences`, etc - also fix indentation in `typecheckFile` - apparently I double-intended this accidentally, so make it single indent
This commit is contained in:
parent
3dda648f0f
commit
ed0fbd9b85
24
src/index.ts
24
src/index.ts
@ -55,16 +55,19 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
|
||||
}));
|
||||
}
|
||||
|
||||
const typecheckFile = (id: string, snapshot: tsTypes.IScriptSnapshot, tcContext: IContext) =>
|
||||
const typecheckFile = (id: string, snapshot: tsTypes.IScriptSnapshot | undefined, tcContext: IContext) =>
|
||||
{
|
||||
id = normalize(id);
|
||||
checkedFiles.add(id); // must come before print, as that could bail
|
||||
if (!snapshot)
|
||||
return;
|
||||
|
||||
const diagnostics = getDiagnostics(id, snapshot);
|
||||
printDiagnostics(tcContext, diagnostics, parsedConfig.options.pretty !== false);
|
||||
id = normalize(id);
|
||||
checkedFiles.add(id); // must come before print, as that could bail
|
||||
|
||||
if (diagnostics.length > 0)
|
||||
noErrors = false;
|
||||
const diagnostics = getDiagnostics(id, snapshot);
|
||||
printDiagnostics(tcContext, diagnostics, parsedConfig.options.pretty !== false);
|
||||
|
||||
if (diagnostics.length > 0)
|
||||
noErrors = false;
|
||||
}
|
||||
|
||||
/** to be called at the end of Rollup's build phase, before output generation */
|
||||
@ -290,8 +293,7 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
|
||||
return;
|
||||
|
||||
const snapshot = servicesHost.getScriptSnapshot(id);
|
||||
if (snapshot)
|
||||
typecheckFile(id, snapshot, context);
|
||||
typecheckFile(id, snapshot, context);
|
||||
});
|
||||
}
|
||||
|
||||
@ -305,10 +307,8 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
|
||||
return;
|
||||
|
||||
context.debug(() => `type-checking missed '${key}'`);
|
||||
|
||||
const snapshot = servicesHost.getScriptSnapshot(key);
|
||||
if (snapshot)
|
||||
typecheckFile(key, snapshot, contextWrapper);
|
||||
typecheckFile(key, snapshot, contextWrapper);
|
||||
});
|
||||
|
||||
buildDone();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user