Skip to content

Commit be34970

Browse files
committed
fix: type-check included files missed by transform (type-only files)
- type-only files never get processed by Rollup as their imports are elided/removed by TS in the resulting compiled JS file - so, as a workaround, make sure that all files in the `tsconfig` `include` (i.e. in `parsedConfig.fileNames`) are also type-checked - note that this will not catch _all_ type-only imports, in particular if one is using `tsconfig` `files` (or in general _not_ using glob patterns in `include`) -- this is just a workaround, that requires a separate fix - we do the same process for generating declarations for "missed" files right now in `_onwrite`, so basically do the same thing but for type-checking in `_ongenerate` (_technically_ speaking, there could be full TS files (i.e. _not_ type-only) that are in the `include` and weren't transformed - these would basically be independent TS files not part of the bundle that the user wanted type-checking and declarations for (as we _already_ generate declarations for those files))
1 parent 67f1d86 commit be34970

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,23 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
276276
});
277277
}
278278

279+
// type-check missed files as well
280+
parsedConfig.fileNames.forEach((name) =>
281+
{
282+
if (!pluginOptions.check)
283+
return;
284+
285+
const key = normalize(name);
286+
if (key in declarations || !filter(key)) // don't duplicate if it's already been transformed
287+
return;
288+
289+
context.debug(() => `type-checking missed '${key}'`);
290+
291+
const snapshot = servicesHost.getScriptSnapshot(key);
292+
if (snapshot)
293+
typecheckFile(key, snapshot, context);
294+
});
295+
279296
if (!watchMode && !noErrors)
280297
context.info(yellow("there were errors or warnings."));
281298

0 commit comments

Comments
 (0)