-
Notifications
You must be signed in to change notification settings - Fork 5.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
[Feature Request] Typescript compile API #2927
Comments
Hmm interesting... it certainly is feasible and I can seem the potential value in it. I do think we would need to think about it a bit more, as it is seldom a single chunk of code that needs to be transpiled. While the TypeScript compiler supports a single file transpile mode, currently the compiler APIs internally are more the project based transpilation. We would also have to deal with things like source maps and declarations, versus just JavaScript being emitted back, as well as diagnostics being returned. So fairly complex. So it might be better to align the runtime One of the other things Ry and I have chatted about is getting more direct access to the AST from TypeScript to potentially make manipulation easier (or faster if we did some in Rust), so that should be part of the consideration. I think also #1739 would be somewhat related (or we need to identify how these would interralte. |
Yes, we absolutely should expose Deno's compilation infrastructure to users. Maybe before tackling this, we should make sure Deno users can use TypeScript itself - see denoland/std#428 |
I think in the conversations that were partly related to #3321 that we should tackle this. Doing denoland/std#428 seems somewhat tangental to this. We can't expose the built in TypeScript and the types of workloads that people are talking about here, means that a clean, more accessible compiler API would be easier to consume. I would propose the following: Deno.transpileOnly(sources: string[], options?: Deno.CompilerOptions): Promise<string[]>;
Deno.compile(rootName: string, sources?: Record<string, string>, options?: Deno.CompilerOptions): Promise<[Deno.TSErrors | undefined, Record<string, string>]>;
Deno.bundle(rootName: string, sources?: Record<string, string>, options?: Deno.BundleOptions): Promise<[Deno.TSErrors | undefined, string]>;
Using Using With With |
Would this also include the Deno runtime? As in, assuming you’re outputting Deno-specific (uses Deno namespace/module) JS code, will you also get a JS version of Deno? If so, doesn’t that defeat the point of Deno using TypeScript? Also, should we be worried about bundle size? If not, what’s the point of exporting it as a JS file? (The browser won’t be able to use it anyway, if it has Deno-specific code). And if you’re not using Deno-specific code, why not use the TypeScript compiler directly? |
For some workloads, users want access to the TypeScript compiler that is built into Deno. Using Take using Deno as an HTTP server of some sort, and you want to serve to your clients JavaScript based on TypeScript you have hosted on locally. You could run the TypeScript language services under Deno, or we could provide access to the built in TypeScript compiler. It is a narrow use case, but it is still a very valid use case. |
Also restructures the compiler TypeScript files to make them easier to manage and eventually integrate deno_typescript fully. Fixes denoland#2927
Also restructures the compiler TypeScript files to make them easier to manage and eventually integrate deno_typescript fully. Fixes denoland#2927
Also restructures the compiler TypeScript files to make them easier to manage and eventually integrate deno_typescript fully. Fixes denoland#2927
Also restructures the compiler TypeScript files to make them easier to manage and eventually integrate deno_typescript fully. Fixes denoland#2927
One of the best features of Deno is allowing us to write JavaScript that both run at (modern) browsers and server side without building or other works. But if we write in TypeScript, that's useless for Browsers. (That's why I'd like to write codes in JS rather then TS.)
If Deno provide an API that accepts TS codes, compile them with inside compiler, and returns JS codes. We can build a web server to respond JS modules compiled from TS. Then the TS codes are cross-platform too.
Here is a suggestion:
The text was updated successfully, but these errors were encountered: