Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type-only/Emit-less TS files aren't being checked #725

Open
aomader opened this issue May 20, 2020 · 5 comments
Open

Type-only/Emit-less TS files aren't being checked #725

aomader opened this issue May 20, 2020 · 5 comments
Labels
kind: bug Something isn't working scope: upstream Issue in upstream dependency topic: rollup-plugin-typescript2 Issues and PRs relating to rpts2

Comments

@aomader
Copy link

aomader commented May 20, 2020

Current Behavior

After creating a simple react-with-storybook tsdx project (using create), add the following files:

src/interfaces/test.ts:

export interface Foo {
  bar: asd; // should not compile!
}

src/interfaces/index.ts:

export * from './test';

src/index.tsx:

// ...
export * from './interfaces';

Using this setup, running npm run start "successfully" builds the package, although it should error out due to the above error.

In contrast, when I run tsc --noEmit, the error is successfully recognized.

Expected behavior

When running npm run start, I expect it to catch the error.

Your environment

Software Version(s)
TSDX 0.13.2
TypeScript 3.9.3
npm 6.14.4
Node 14.1.10
Operating System Win10

Find the minimal example from above here:
lib2.zip

@agilgur5
Copy link
Collaborator

agilgur5 commented May 23, 2020

Sounds like this might be similar to #527 which never provided a repro. test.ts is a type-only/emit-less import and its type isn't used anywhere, so it might just be pruned out by rollup-plugin-typescript2 or rollup itself

@agilgur5 agilgur5 added the kind: bug Something isn't working label May 23, 2020
@agilgur5 agilgur5 changed the title Not all TS files are being checked or generated Type-only TS files aren't being checked Jun 12, 2020
@agilgur5 agilgur5 added the scope: upstream Issue in upstream dependency label Jun 12, 2020
@agilgur5 agilgur5 changed the title Type-only TS files aren't being checked Type-only/Emit-less TS files aren't being checked Sep 19, 2020
@ezolenko
Copy link

Yeah, rollup prunes unused sources, so rtp2 plugin might never see something not imported by entry file.

@agilgur5
Copy link
Collaborator

agilgur5 commented Sep 30, 2020

I did some research on this in the past few weeks/months and found a reference to the original issue in rollup-plugin-typescript (rollup/rollup-plugin-typescript#28) from @wessberg/rollup-plugin-ts's docs. That was then moved to rollup/plugins#71 which was supposedly fixed in @rollup/plugin-typescript v3.0.0

We don't use @rollup/plugin-typescript, but that issue has references from other plugins, e.g. this one wessberg/rollup-plugin-ts#29 which has a comment that refers to rollup-plugin-typescript2's issue: ezolenko/rollup-plugin-typescript2#24 (which also referenced from the original issue). ezolenko/rollup-plugin-typescript2#7 is perhaps a duplicate of that

@ezolenko thanks for responding here. Per that issue, I thought this was fixed by ezolenko/rollup-plugin-typescript2@448913d with the current code here? Does that only handle entry files? Can we workaround that? It seems like @wessberg/rollup-plugin-ts has fixed the emit-less/type-only issue in somehow.
Not sure if ezolenko/rollup-plugin-typescript2#211 is related given mention of "entry file"

@agilgur5 agilgur5 added the topic: rollup-plugin-typescript2 Issues and PRs relating to rpts2 label Nov 1, 2020
@agilgur5
Copy link
Collaborator

agilgur5 commented Nov 1, 2020

@ezolenko following up about the above

@agilgur5
Copy link
Collaborator

agilgur5 commented Sep 17, 2022

Noting here that this type-only issue was reproduced upstream in ezolenko/rollup-plugin-typescript2#298.
I became a maintainer of rpt2 a couple of months ago and fixed that in ezolenko/rollup-plugin-typescript2#345 , which was released in rpt2 0.33.0

Not sure if ezolenko/rollup-plugin-typescript2#211 is related given mention of "entry file"

This was actually the root cause and all of my references were related -- type-only issues were the longest lasting and most common issues in rpt2.
ezolenko/rollup-plugin-typescript2#345 allowed a specific workaround to function for many use-cases, but I later fixed the root cause issue in ezolenko/rollup-plugin-typescript2#406, which was released in rpt2 0.34.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working scope: upstream Issue in upstream dependency topic: rollup-plugin-typescript2 Issues and PRs relating to rpts2
Projects
None yet
Development

No branches or pull requests

3 participants