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

export * statements in d.ts can not be use to prompt types of default export. #285

Closed
3 tasks done
emosheeep opened this issue Nov 21, 2023 · 4 comments
Closed
3 tasks done
Labels
bug Something isn't working

Comments

@emosheeep
Copy link

emosheeep commented Nov 21, 2023

Describe the bug

I'm facing a problem that I have these lines in my src/index.ts

export { sdk as default } from './sdk';

and I use insertTypesEntry functionality to generate dist/index.d.ts as follows:

export * from './src/index.d.ts';

But when I publish these code to npm and use it, type prompts were gone.

Reproduction

https://stackblitz.com/edit/vitejs-vite-xwwwbi?file=test.ts

Steps to reproduce

just run yarn build and see test.ts.

import sdk from '.';

sdk.execute(); // types' broken

System Info

System:
    OS: macOS 14.1.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 86.19 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm
    pnpm: 8.9.2 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 119.0.6045.159
    Edge: 119.0.2151.72
    Safari: 17.1
  npmPackages:
    vite: ^4.4.11 => 4.5.0

Validations

@qmhc
Copy link
Owner

qmhc commented Nov 21, 2023

Maybe a workaround:

import { sdk } from './sdk'
export default sdk

@emosheeep
Copy link
Author

emosheeep commented Nov 21, 2023

Although...maybe the plugin could do something? such as

import _default from './src/index.d.ts';
export * from './src/index.d.ts';
export default _default;

@qmhc
Copy link
Owner

qmhc commented Nov 21, 2023

This is a flaw of match logic, please wait for it to be fixed.

@qmhc qmhc added the bug Something isn't working label Nov 21, 2023
@emosheeep
Copy link
Author

That would be great! Thanks a lot.

@qmhc qmhc closed this as completed in 6e2d16d Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants