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

New tsconfig of create-vite gives type errors if .d.ts files can not be generated #17638

Closed
7 tasks done
kasperpeulen opened this issue Jul 9, 2024 · 1 comment · Fixed by #17774
Closed
7 tasks done
Labels
p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) regression The issue only appears after a new release

Comments

@kasperpeulen
Copy link

Describe the bug

This PR introduced new default values for the tsconfig.json created with create-vite:
#15913

This PR uses TS references and sets composite: true in tsconfig.json:

{
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

The references feature uses .d.ts files when references reference each other. So declaration is forced to be set to true:
https://www.typescriptlang.org/tsconfig/#declaration

This gives quite some extra TS errors.
In storybook, *.stories.ts files are usually not written in a way that allows .d.ts files to be generated from them.

In a fresh storybook vite react project, users now get the following TS error:

Exported variable 'meta' has or is using name 'ButtonProps' from external module "src/stories/Button" 
but cannot be named.
ts(4023)

Reproduction

https://stackblitz.com/edit/github-nup1wj?file=src%2Fvite-env.d.ts

Steps to reproduce

Clone the stackblitz repro locally. As stackblitz is also broken by this PR.

The error will popup in your editor in Button.stories.tsx, but not when running tsc on the command line.

System Info

System:
    OS: macOS 13.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 55.66 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node
    Yarn: 1.19.1 - ~/.nvm/versions/node/v18.18.0/bin/yarn
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.0/bin/npm
    pnpm: 9.1.4 - ~/.nvm/versions/node/v18.18.0/bin/pnpm
    bun: 1.1.12 - ~/.bun/bin/bun
  Browsers:
    Chrome: 126.0.6478.127
    Chrome Canary: 128.0.6583.0
    Safari: 16.4
  npmPackages:
    @vitejs/plugin-react: ^4.3.1 => 4.3.1
    vite: ^5.3.1 => 5.3.3

Used Package Manager

npm

Logs

No response

Validations

Copy link

stackblitz bot commented Jul 9, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) regression The issue only appears after a new release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants