-
-
Notifications
You must be signed in to change notification settings - Fork 223
fix(emitDts): set rootDir for consistent output structure #1886
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
fix(emitDts): set rootDir for consistent output structure #1886
Conversation
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.
Thanks for figuring that out! This makes sense to me. As for the question: I think emitDts should start returning an object which for now has { warnings: { file: string; message: string; }[] }.
|
I made it return an object containing the diagnostics from ts itself, The test timeout for the plugin seems unrelated (hopefully 😬). |
packages/svelte2tsx/src/emitDts.ts
Outdated
| program.emit(); | ||
|
|
||
| // EmitResult below doesn't contain them for some reason, so get them separately | ||
| const diagnostics = ts.getPreEmitDiagnostics(program); |
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.
I'm wondering how much slower the emit is becoming through this, AFAICT TS will do some thorough code analyses there, and if there are errors inside Svelte files the diagnostics would need to be mapped etc. It might also close #1835. Should we have this behind an option? Should we leave it out completely for now?
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.
The problem with rolling our custom warnings is that it doesn't contain information on where the bad import happened. The WriteFileCallback gets a SourceFile I'll see if there's a way to extract this information from there.
Alternatively, I suppose we could set a flag if such files are found inside the callback and only run the diagnostics if it's true?
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.
As for #1835, I don't think emitDts's diagnostics can be fully relied upon. It already gets a few false positives because the tsconfig passed to it doesn't line up with the generated by SvelteKit.
|
My idea for generating d.ts files is now that we don't pass the |
Do you mean you want to change it to be that way at some point? Right now it's still there. I wrote my thoughts on not wanting to do that in that other thread, would there be any benefit to it?
Do we trust people to do that or should svelte-package include the check in its scripts? |
The benefit is that we don't mess around with the tsconfig include/files settings. Input/output settings are no problem because New proposal: Don't return any diagnostics. Just emit a one-time warning when we detect that some file would be written out that is outside the root dir.
We trust people to do that if they want to. It's finicky to build it into |
|
Okay, makes sense. Although if we consider the project root to be the rootDir, we can't really tell the files apart to emit an warning. To clarify, should I keep it scoped to the input for now and just remove the diagnostics or change the PR to the other method? |
|
I'm switching my mind constantly 😅 I now think we should just set |
95d21af to
ef90c01
Compare
|
Yeah that's what I meant, should this stay in place for now? https://github.com/sveltejs/language-tools/pull/1886/files#diff-783d276c3f0448d53760c169c6843c026704cd3329bcabbbd46c6234cdcef69bR47 |
dummdidumm
left a comment
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.
Yeah that makes sense!
Ref sveltejs/kit#9118 (comment) and microsoft/TypeScript#52889
Marking as draft cause, should it be a hard error or a warning and who is responsible for logging it: emitDts or the caller?