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

Type-only imports should be imported using import type #166

Closed
backfromexile opened this issue Feb 1, 2024 · 3 comments · Fixed by #167
Closed

Type-only imports should be imported using import type #166

backfromexile opened this issue Feb 1, 2024 · 3 comments · Fixed by #167

Comments

@backfromexile
Copy link
Contributor

Hi there,

when the TypeScript configuration option isolatedModules is active, then the compilation of the generated .ts files fails as they only import types but the imports are not properly marked as such.
Type-only imports should use import type { Type } instead of import { Type }.
This change should not be an issue for any TypeScript project that uses TypeScript >=3.8.

Because of the issue mentioned above, running my Vue3 project with vite fails with a runtime error like this
Uncaught SyntaxError: The requested module '/src/_generated/Namespace.Hubs.ts' does not provide an export named 'MyType' (at Namespace.Hubs.ts:6:23).

@backfromexile
Copy link
Contributor Author

This is an issue in Tapper as well if I'm not mistaken

@nenoNaninu
Copy link
Owner

Thanks for the issue report.

I have several projects using TypedSignalR.Client.TypeScript with isolatedModules is true, and they wrok fine. Perhaps the problem is not caused by the isolatedModules setting.

@backfromexile
Copy link
Contributor Author

Thanks for the issue report.

I have several projects using TypedSignalR.Client.TypeScript with isolatedModules is true, and they wrok fine. Perhaps the problem is not caused by the isolatedModules setting.

Yeah you are right, I confused this with preserveValueImports in combination with importsNotUsedAsValues. Vite uses esbuild to compile TypeScript code and esbuild requires import type because of the mentioned options.

Either way, thanks for merging the PR!

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

Successfully merging a pull request may close this issue.

2 participants