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

TypeChecking (CI): issue with 3rd party libraries #972

Closed
florian-sanders-cc opened this issue Mar 4, 2024 · 0 comments
Closed

TypeChecking (CI): issue with 3rd party libraries #972

florian-sanders-cc opened this issue Mar 4, 2024 · 0 comments
Assignees
Labels
bug Something isn't working maintenance Code refactoring, project structure, dev tooling (storybook, dev server, npm tasks...)

Comments

@florian-sanders-cc
Copy link
Contributor

florian-sanders-cc commented Mar 4, 2024

Context

With the latest Storybook upgrade (7.0, see #952), it looks like CI TypeChecking is broken.

What's going on?

  1. The TypeChecker scans d.ts files from the node_modules/@types folder (see https://www.typescriptlang.org/tsconfig#types),
  2. It detects errors related to express, react, trusted_types & babel (see Screenshot below).

image

We cannot solve these errors sicne they are related to 3rd party libraries imported by Storybook.

The typical solution

Usually, people set skipLibCheck to true.
This improves performances and prevents 3rd party libraries from making your compilation / typechecking fail.

Unfortunately, this also means our own d.ts files are no longer typechecked.
Since we actually hand-author these d.ts files, we think it's critical they are typechecked like the rest of our code.

What we'd like

We would like to be able to exclude the offending types from our typechecking.
Unfortunately, this does not seem to be possible at the moment (microsoft/TypeScript#30511) because we're in a case that is not officially supported by TypeScript:

Currently, we have a fairly coherent posture that .d.ts files are either outputs or they describe the shape of colocated JS (as in libraries), but they’re not inputs to be hand-authored.

What can we do?

Instead of excluding the types, we can declare types we want to be included thanks to the types option (see https://www.typescriptlang.org/tsconfig#types).
This is cumbersome because we need to manually add types.

At the moment, we only typecheck the src/lib/utils.js file and it looks like the only type we need to import is node so we'll go with that.

We will gradually add types to the list as we need them and if it starts to become painful to maintain, we might need to consider another option, perhaps even the skiLibCheck: true solution.

EDIT: we had to go with skipLibCheck because the solution with the types option failed when upgrading some of our dependencies. One of our dependencies is bringing ts4.8 types in node types and this node lib cannot be checked with our current TypeScript version (~4.3.2).

@florian-sanders-cc florian-sanders-cc added bug Something isn't working maintenance Code refactoring, project structure, dev tooling (storybook, dev server, npm tasks...) labels Mar 4, 2024
@florian-sanders-cc florian-sanders-cc self-assigned this Mar 4, 2024
florian-sanders-cc added a commit that referenced this issue Mar 4, 2024
Fixes #972

chore(tsconfig-ci): tmp dark magic to solve TypeChecking issue

TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies yay).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours (which is SO stupid
in my noob opinion).
I went for another solution that apparently tells TypeScript to only
check our `d.ts` and `node` types ("node" here could be any other
3rd party as long as it does not contain errors).
I have no idea about the drawbacks of this solution and I do not fully
understand it.

fix(tsconfig): fixup
florian-sanders-cc added a commit that referenced this issue Mar 4, 2024
Fixes #972

chore(tsconfig-ci): tmp dark magic to solve TypeChecking issue

TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies yay).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours (which is SO stupid
in my noob opinion).
I went for another solution that apparently tells TypeScript to only
check our `d.ts` and `node` types ("node" here could be any other
3rd party as long as it does not contain errors).
I have no idea about the drawbacks of this solution and I do not fully
understand it.

fix(tsconfig): fixup
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
florian-sanders-cc added a commit that referenced this issue Mar 5, 2024
TypeScript always checks all types found in the `node_modules/@types`
folder.
It looks like with the new storybook version, some types in there are in
conflict and contain mistakes (storybook & react dependencies).
The common solution is to use `skipLibCheck: true` but this disables
typechecking for all `d.ts` files, including ours.

Fixes #972
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working maintenance Code refactoring, project structure, dev tooling (storybook, dev server, npm tasks...)
Projects
None yet
Development

No branches or pull requests

1 participant