-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Allow <script lang='typescript'>
without an explicit pre-processor
#4797
Comments
I don't like this for a few reasons. One is that the core From a more technical perspective: Do Babel and TypeScript have synchronous modes of operation? The Svelte compiler is currently synchronous, and one of the reasons that preprocessing was split out into its own thing was that async-only operations abound in the various transpilers people would want to use on components. |
For the first point, that's totally reasonable, you all know the internals better than I do. There could definitely be other avenues I don't know to explore. Second: Yeah, in the Danger code above they are both synchronous |
@Conduitry maybe we could think about a auto detect feature inside the preprocess for common use cases? |
What does "minimal support" mean? Are there things that would be explicitly unsupported? I'd love better TypeScript support, but I tend to think that building in support for pre-processing TypeScript and not other things like One thing I wonder about building into sveltejs though is compilation of templates to TypeScript (e.g. like tsx does). That would make a lot more sense to do in core than trying to build it into an external library |
For me, minimal is that if svelte see's typescript lang tags it runs It really could just be the "typescript" module, which would simplify the code to: export const typescriptify = (content: string): string => {
try {
const ts = require("typescript")
const compilerOptions = { ... }
const result = ts.transpileModule(content, sanitizeTSConfig(compilerOptions))
return result.outputText
} catch () {
console.error("You need TypeScript installed to use TypeScript script templates in svelte")
process.exitCode = 1
process.exit() // etc
}
} For me, doing something like:
Is pretty heavy work (as seen in svelte2tsx) which puts a lot of support and tooling inside the svelte compiler |
Adding my 2 cents:
|
This is issue about moving enough into the compiler so that you wouldn't need the preprocessor config for just TS - yep. Re: config stuff, that's a good call for another issue. The proposal doesn't touch the editor integration (which is what the LSP handles) they're not connected other than the LSP uses the svelte compiler under the hood. The LSP wouldn't have any code changes if/when this change happens. |
I brought up my opinion in a recent maintainers meeting - I've been shifting to the side of this is not necessary. I'm going to close the issue. When you have |
Describe the bug
We can reduce the number of tools people need to set up by adding very minimal support for TypeScript parsing of the JS. This can be done in the same way that Danger does it:
To Reproduce
Expected behavior
This would pass, assuming TypeScript was in my dependencies
Stacktraces
n/a
Severity
Nice to have - a part of #4518
The text was updated successfully, but these errors were encountered: