-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Generates corresponding .d.ts file #657
Comments
I've been agonized if it is possible without fully blown typescript parser. I thinks it's not possible yet. (I'm working on a fully-blown typescript compiler, but It would take some time.) |
Okay, I get it. Unfortunately the advantage of swc is kind of lost when you need the declaration files, since you have to run |
Reopening as I checked an output from tsc and I noticed that it's possible without a full type checker. Currentlly it cannot infer the type of parameter, but it's okay as d.ts contains it as-is |
If this were to work, that would be wonderful |
Hi there, has any progress? |
Hi, I've commented on Esbuild a similar issue, but same question for SWC: could you at least point users to a possible pattern/documentation/resource to generate the .d.ts files? I don't think .d.ts should be regenerated all the time, it's often ok to generate them only when publishing the app for instance. So we could keep using tsc or whatever for this step. However I completely fail to find some decent documentation about how to just generate those files after the build, with either |
@behnammodi #571 is used instead of this issue, as generating @eric-burel TypeSciprt is a huge beast and porting it is not easy. It's simply not support neither by esbuild nor swc at the moment. |
Yeah I get that the port is hard, no problem with that, but is there a palliative that could use It seems to me that if I use For instance, I'd like |
No. It's simply impossible. You need full type system to generate |
@kdy1 Man, I wish Microsoft would realize how valuable this is and just hire you to replace their current TS type system with the Rust-based one you're working on 😅 |
Why? You'd of course need a full type system to validate types, but to generate the [edit] Assuming all types are explicit. I feel like generating |
Bexause you can't know type |
You need to be able to parse types, but you don't need to understand them (e.g. need a full type system):
can be used to create a
|
No you can't know the type id it's not specified. (All validations are not required for generating .d.ts, but I don't think you meant this) |
What am I missing, lol? I don't see why you need type ids to generate a Let's say you matched |
No. function foo<T>(arr: T[]) {
for (const a of arr) {
if (typeof a === 'string') return a
}
} Do you think you can generate the |
😁 All of ours are anyway, because we've enabled |
I don't think the user of a feature like that is many enough to justify the effort required for this. |
I really need this feature. My project is monorepo. So, I want to transpile shared package by using swc. |
When referencing other packages' types that are in the same workspace, you don't have to build |
In the context of monorepo I believen packages live in different workspaces. After all yarn v2 uses the word |
@onichandame According to the documentation, a workspace itself is a package. However, it also hosts several sub-projects which are also packages. Therefore a single workspace package hosts many sub-packages, and the sub-packages can cross-reference each other. |
How exciting, Vercel would be supporting the effort ! https://kdy1.dev/posts/2022/1/tsc-go 🥳 |
Any updates on this? If we want to publish our packages on npm this wont be ideal solution |
@ShivamJoker check the linked article https://kdy1.dev/posts/2022/1/tsc-go And example {
"extends": "./tsconfig.json",
"include": [
"./shared/index.ts",
"./client/index.ts",
"./server/index.ts"
],
"compilerOptions": {
"emitDeclarationOnly": true,
"isolatedModules": false,
"declaration": true,
// helps local development, could be dropped out of the NPM package though
"declarationMap": true
},
} |
okay so there is gonna be a new lib which will have all these features? |
It will be added to swc |
Is there a timeline for this? |
are there any news for this feature? |
@kdy1 any progress on this? |
Update: See https://github.com/dudykr/stc |
It would be great if we could specify (like source maps) an option to also generate declaration files.
The text was updated successfully, but these errors were encountered: