Skip to content

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

@kasperpeulen

Description

@kasperpeulen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-downstream-blockerBlocking the downstream ecosystem to work properly (priority)regressionThe issue only appears after a new release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions