vite-plugin-dts icon indicating copy to clipboard operation
vite-plugin-dts copied to clipboard

[vite:dts] Internal Error: Unable to determine semantic information for declaration

Open norvalbv opened this issue 1 year ago • 5 comments

Describe the bug

`[vite:dts] Internal Error: Unable to determine semantic information for declaration: /Users/beam/Desktop/Person/react-blogs/src/components/Title/index.tsx:16:9

You have encountered a software defect. Please consider reporting the issue to the maintainers of this application. ✓ built in 3.78s error during build: Error: Internal Error: Unable to determine semantic information for declaration:`

When using dts({ rollupTypes: true }) the plugin does not work when destructuring.

For example,

This throws a bug:

  const hi = { hello: 'hi' };
  const { hello } = hi;

this throws a bug:

  const [test, setTest] = useState();

Etc.

full error:

image

From some basic research it seems to be an error with Api-Extractor and you may need to downgrade?

Reproduction

https://github.com/norvalbv/react-blogs

Steps to reproduce

Go to any components folder in /src and put one of those examples above in the code, then simply running yarn build or yarn build --watch will throw an error.

System Info

System:
    OS: macOS 12.4
    CPU: (8) arm64 Apple M1 Pro
    Memory: 110.31 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.16.0 - /usr/local/bin/node
    Yarn: 3.6.1 - /usr/local/bin/yarn
    npm: 9.5.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 118.0.5993.117
    Firefox: 119.0
    Safari: 15.5
  npmPackages:
    @vitejs/plugin-react: ^4.1.0 => 4.1.0 
    vite: ^4.5.0 => 4.5.0 
    vite-plugin-dts: ^3.6.3 => 3.6.3

Validations

norvalbv avatar Oct 31 '23 18:10 norvalbv

I can't reproduce this issue, refer to https://stackblitz.com/~/github.com/qmhc/react-blogs/tree/qmhc/patch-58131.

Maybe you can use a template in stackblitz and create a minimum reproduction.

qmhc avatar Nov 01 '23 00:11 qmhc

Hey, i've made a new branch and you can see the error caused in src/components

https://github.com/norvalbv/react-blogs/tree/test

The error is still the same, below: :)

image

norvalbv avatar Nov 01 '23 18:11 norvalbv

Refer to https://github.com/microsoft/rushstack/issues/3875, this maybe a limitation of @microsoft/api-extractor (or TypeScript resolver).

Currently you need to use relative paths:

export * from './components';

or use alias with paths option like the following:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "src/*": ["./src/*"]
    }
  }
}
export * from 'src/components';

qmhc avatar Nov 30 '23 03:11 qmhc