ezolenko / rollup-plugin-typescript2

Rollup plugin for typescript with compiler errors.
MIT License
822 stars 71 forks source link

dx: be more explicit with `emitSkipped` error #395

Closed agilgur5 closed 2 years ago

agilgur5 commented 2 years ago

Summary

Provide a bit more details when erroring on emitSkipped and link to my TS issue since this is unfortunately undocumented

Details

agilgur5 commented 2 years ago

Hmm... so with latest rpt2 0.33.0 on #254 I was still getting emitSkipped despite all the fixes. I added some logging and saw something interesting:

❯ npx rollup -c

src/runtime/navigation/index.ts, src/runtime/stores/index.ts β†’ assets/runtime...
{
  outputFiles: [],
  emitSkipped: true,
  diagnostics: [
    {
      file: [SourceFileObject],
      start: 617,
      length: 5,
      messageText: "Property 'route' of exported interface has or is using private name 'Route'.",
      category: 1,
      code: 4033,
      reportsUnnecessary: undefined,
      reportsDeprecated: undefined
    }
  ],
  exportedModulesFromDeclarationEmit: undefined
}
/rpt2-issue-254/packages/kit/src/runtime/navigation/index.ts
[]
[!] (plugin rpt2) Error: Emit skipped for '/rpt2-issue-254/packages/kit/src/runtime/navigation/index.ts'. See https://github.com/microsoft/TypeScript/issues/49790 for potential reasons why this may occur
src/runtime/navigation/index.ts

    at error (/rpt2-issue-254/node_modules/.pnpm/rollup@2.32.0/node_modules/rollup/dist/shared/rollup.js:5251:30)
    at throwPluginError (/rpt2-issue-254/node_modules/.pnpm/rollup@2.32.0/node_modules/rollup/dist/shared/rollup.js:17912:12)
    at Object.error (/rpt2-issue-254/node_modules/.pnpm/rollup@2.32.0/node_modules/rollup/dist/shared/rollup.js:18519:24)
    at Object.error (/rpt2-issue-254/node_modules/.pnpm/rollup@2.32.0/node_modules/rollup/dist/shared/rollup.js:18081:38)
    at /rpt2-issue-254/node_modules/.pnpm/rollup-plugin-typescript2@0.33.0_g55licvlyixydf5tadtvtnn3hq/node_modules/rollup-plugin-typescript2/src/index.ts:232:12
    at TsCache.getCached (/rpt2-issue-254/node_modules/.pnpm/rollup-plugin-typescript2@0.33.0_g55licvlyixydf5tadtvtnn3hq/node_modules/rollup-plugin-typescript2/src/tscache.ts:274:25)
    at TsCache.getCompiled (/rpt2-issue-254/node_modules/.pnpm/rollup-plugin-typescript2@0.33.0_g55licvlyixydf5tadtvtnn3hq/node_modules/rollup-plugin-typescript2/src/tscache.ts:213:15)
    at Object.transform (/rpt2-issue-254/node_modules/.pnpm/rollup-plugin-typescript2@0.33.0_g55licvlyixydf5tadtvtnn3hq/node_modules/rollup-plugin-typescript2/src/index.ts:222:16)
    at /rpt2-issue-254/node_modules/.pnpm/rollup@2.32.0/node_modules/rollup/dist/shared/rollup.js:18718:25

In this case, there are diagnostics with the output. But typecheckFile doesn't output anything.

That's because the type error is in types.ts instead of index.ts (per the issue). But index.ts gets a different diagnostic error because of that type error apparently, and it appears to be neither a syntactic nor a semantic error, oddly enough... πŸ€” It also doesn't show up in tsc's output.

This might be a TS bug upstream? I'm really not sure... πŸ˜•