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

[vite:dts] Cannot read properties of undefined (reading 'length') #387

Open
3 tasks done
webkong opened this issue Oct 9, 2024 · 3 comments
Open
3 tasks done

[vite:dts] Cannot read properties of undefined (reading 'length') #387

webkong opened this issue Oct 9, 2024 · 3 comments

Comments

@webkong
Copy link

webkong commented Oct 9, 2024

Describe the bug

When I use dts according to documentation.

import dts from "vite-plugin-dts";

plugins: [dts()]

image

I'm try to fix the bug. Add a ? can resove.

image

Reproduction

no url

Steps to reproduce

No response

System Info

System:
    OS: macOS 15.0.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 71.48 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.0/bin/npm
  Browsers:
    Chrome: 129.0.6668.91
    Safari: 18.0.1
  npmPackages:
    vite: ^5.4.8 => 5.4.8 
    vite-plugin-dts: ^4.2.3 => 4.2.3

Validations

@qmhc
Copy link
Owner

qmhc commented Oct 10, 2024

Could you show how did you trigger this error?

@webkong
Copy link
Author

webkong commented Oct 12, 2024

just

import dts from "vite-plugin-dts";

plugins: [dts()]

tsconfig

{
  "compilerOptions": {
    "target": "ES2020",
    "useDefineForClassFields": true,
    "module": "ESNext",
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "skipLibCheck": true,

    /* declaration */
    "declaration": true,
    "declarationDir": "./types",

    /* Bundler mode */
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "isolatedModules": true,
    "moduleDetection": "force",
    "noEmit": true,

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true
  },
  "include": ["src"]
}

@iHeart-JeffSkee
Copy link

iHeart-JeffSkee commented Oct 31, 2024

I've encountered the same exact experience as described by @webkong.

After messing with it and debugging for WAY tooo long, I finally discovered that I was setting

export default defineConfig({
  build: {
    rollupOptions: { plugins: [dts({ rollupTypes: true })] },
    ...
  }
})

When I should have been setting

export default defineConfig({
  plugins: [dts({ rollupTypes: true })],
  build: {
    ...
  },
});

Seems like it's always the little things that trip you up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants