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

Star-imports don't get included in the bundle #304

Closed
amsyarasyiq opened this issue Feb 23, 2024 · 4 comments · Fixed by #309
Closed

Star-imports don't get included in the bundle #304

amsyarasyiq opened this issue Feb 23, 2024 · 4 comments · Fixed by #309
Assignees
Labels
Milestone

Comments

@amsyarasyiq
Copy link

amsyarasyiq commented Feb 23, 2024

Bug report
When star-importing another module import *, the value gets ignored and won't bundle. The following will error out without --no-check:

Input code

// otherLib.ts
export function foo_func() {}
export function bar_func() {}

// index.ts
import * as lib from "./otherLib";
export const Lib = lib;

Expected output(?)

export declare const Lib: {
	foo_func(): void;
	bar_func(): void;
};

export {};

Actual output

// without --no-check: dist/index.d.ts(1,34): error TS2552: Cannot find name 'lib'. Did you mean 'Lib'?
export declare const Lib: typeof lib;

export {};

Additional context
This can be work around by "cloning" the imported module with spread operator { ...lib }. Doing this will result the "expected output" shown above.

@timocov
Copy link
Owner

timocov commented Feb 23, 2024

What version of the tool you're using?

@timocov timocov added the Bug label Feb 23, 2024
@timocov timocov self-assigned this Feb 23, 2024
@timocov
Copy link
Owner

timocov commented Feb 23, 2024

As a workaround for now you can use something like export { lib as Lib }, technically should be around the same. I'll take a look in details later

@amsyarasyiq
Copy link
Author

amsyarasyiq commented Feb 23, 2024

What version of the tool you're using?

From package.json, "dts-bundle-generator": "^9.3.1",

My usage was something along with:

export const getSomething = () => ({
	somethingKey: starImportedModule
})

so that doesn't really work as a workaround in this case

@timocov
Copy link
Owner

timocov commented Apr 15, 2024

The fix has been published in 9.4.0 version.

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