-
Notifications
You must be signed in to change notification settings - Fork 150
Added support for filtering unused named imports. #155
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
Conversation
6cccb21
to
49c121c
Compare
44680a4
to
c193100
Compare
src/processors/typescript.ts
Outdated
const transformed = await transformer({ | ||
content, | ||
filename, | ||
markup: markupCache[svelteFile.filename], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, as a suggestion, I'd move the additional parameter to the end of the param list to be consistent with your additions to other param lists earlier in the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
c193100
to
cf2177a
Compare
2d63489
to
bdd8bb0
Compare
Uses the AST to check if named imports are used in the transpiled code. If not, filters out the import. This way non-emitting types will never be imported so we don't get the following error: ```[!] Error: '<Interface>' is not exported by <TypeScriptFile>.ts, imported by <SvelteFile>.svelte```
cf2177a
to
ae7c462
Compare
This will make the pre-processor much more useful, I run into this ALL THE TIME :) |
I'm not 100% on all the problems this solves, but can recommending |
Uses the AST to check if named imports are used in the transpiled code. If not, filters out the named import. Another option could be to use the typechecker, but then it would break when transpileOnly was true.
Fixes #153.
This way non-emitting types will never be imported so we don't get the following error:
[!] Error: '<Interface>' is not exported by <TypeScriptFile>.ts, imported by <SvelteFile>.svelte
Before submitting the PR, please make sure you do the following
npm run lint
!)Tests
npm test
oryarn test