Skip to content
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

TypeScript type checker #571

Closed
kdy1 opened this issue Jan 6, 2020 · 103 comments
Closed

TypeScript type checker #571

kdy1 opened this issue Jan 6, 2020 · 103 comments

Comments

@kdy1
Copy link
Member

kdy1 commented Jan 6, 2020

Closing as the stc is now abandoned. TypeScript was not something that I could follow up on in an alternative language.

@kdy1 kdy1 added this to the TypeScript milestone Jan 6, 2020
@kdy1 kdy1 self-assigned this Jan 6, 2020
@dsherret
Copy link
Contributor

dsherret commented Jan 8, 2020

I'm just looking at this: https://github.com/kdy1/swc/tree/e88e5e4c824926e5f3a5240986c33bb30f7508b5/typescript/checker

Won't re-writing the TS type checker in rust be a lot of work? There's so many edge cases! Why not just do what babel does and tell people to run the typescript type checker over the code with emitting? Alternatively, you could build something into the swc JS package that uses the typescript compiler api to do this as well.

@dsherret
Copy link
Contributor

dsherret commented Jan 8, 2020

What might be neat is something that converts swc AST nodes to TypeScript compiler api nodes. So you could parse the nodes with swc, send them over to JS, convert them to typescript compiler api nodes, then it could do the type checking using those nodes.

@kdy1
Copy link
Member Author

kdy1 commented Jan 8, 2020

@dsherret I'm porting tsc because it is wall-clock grade slow.

@dsherret
Copy link
Contributor

dsherret commented Jan 9, 2020

True, it could be faster, but there's a whole team of developers working on TypeScript daily. It will be very hard to get all the edge cases, but perhaps you could repurpose the tests the typescript team uses in the typescript repo.

Anyway, you have a long and continually expanding road ahead of you :)

@kdy1
Copy link
Member Author

kdy1 commented Jan 9, 2020

I'm already using tests from typescript repository :)
I know that it's a very hard task, but it's fun for me.

@dsherret
Copy link
Contributor

dsherret commented Jan 9, 2020

That’s awesome. Well, you’ve done an excellent job with the library and you’re very fast at programming so good luck! 😀

@IronSean
Copy link

The other approach you can use with babel is do just do compilation, and run the type checker without emitting in a separate thread so even if it's slower, your build still finishes fast. That might currently work with swc? But the idea of a much faster type checker is also very exciting!

@kdy1 kdy1 added the E-hard label Mar 30, 2020
@kyegupov
Copy link

@kdy1 what's the current status? What's the most up-to-date branch in your fork? I have a feeling you won't be able to pull this alone. Maybe we can create a plan to "move Mount Fuji" and get more people involved?

@kdy1 kdy1 removed their assignment Apr 30, 2020
@nayeemrmn
Copy link
Contributor

https://deno.land/v1#tsc-bottleneck

@trivikr
Copy link
Contributor

trivikr commented May 16, 2020

FYI: TypeScript team doesn't have any plan to port TSC to Rust for reasons explained in tweet thread https://twitter.com/drosenwasser/status/1260722414012358657

@wongjiahau
Copy link

We need to recruit a few developers to achieve this.

@sciepsilon
Copy link

sciepsilon commented Jul 24, 2020

I'm interested! I don't know if I'm up to the task, but I'll at least spend the next couple days exploring the code and getting up to speed.

We need to recruit a few developers to achieve this.

@littledivy
Copy link
Contributor

@sciepsilon I've formed a little team together with @wongjiahau to help @kdy1 work on this.

Fell free to email!

@cakekindel
Copy link

Hi! 👋 I'm also very interested in helping with a rust port of TSC 😄, is this project public?

@wongjiahau
Copy link

wongjiahau commented Aug 4, 2020

@cakekindel Hi if you're interested you can join us at https://discord.gg/s8meYPV

@wongjiahau
Copy link

Sorry the link above was temporary, I just update it with a permanent one.

@kdy1 kdy1 changed the title TypeScript type checker .d.ts generator Sep 24, 2020
@kdy1 kdy1 self-assigned this Sep 24, 2020
@mdbetancourt
Copy link

mdbetancourt commented Oct 21, 2020

The other approach you can use with babel is do just do compilation, and run the type checker without emitting in a separate thread so even if it's slower, your build still finishes fast. That might currently work with swc? But the idea of a much faster type checker is also very exciting!

i think this idea isn't really useful for check type errors (we can do it with the IDE, may be to speed up vscode) but is very cool for lib which depend on typechecks (metadata desing:type), for example in loopback there is 3 different results depending on what you use
ts-node with typecheck: it's okay (Function)

ts-node with transpile-only: error (Object)
image
swc: error (undefined)
image

Sample repo: https://github.com/mdbetancourt/ts-node-loopback you can try changing .mocharc ts-node/register to @swc-node/register

@goloveychuk
Copy link

@kdy1 are you sure you will have better performance by porting to go?
The theory here - because 90% of type checking is conditions checks, nodejs (after warming, classes compilations and optimisations) could be as much fast as go.
Maybe it make sense to explore multithreading instead.

@kdy1
Copy link
Member Author

kdy1 commented May 13, 2022

Yep. The main problem is the number of cpu cores it uses.

Problem is not optimization

@goloveychuk
Copy link

So by porting you mean making it multithreaded too (using coroutines, channels, etc)?

@kdy1
Copy link
Member Author

kdy1 commented May 13, 2022

Of course. What's the point of porting to go at the first place if we are going to use only 1 core?
If go is single-threaded or javascript was multi-threaded, I wouldn't start it. If then, contributing to tsc is the correct way.

@chentsulin
Copy link

This discussion about multi-threaded compilation might be relevant: microsoft/TypeScript#30235

@kdy1 kdy1 unpinned this issue May 18, 2022
@swc-project swc-project locked as off-topic and limited conversation to collaborators Jun 15, 2022
@kdy1 kdy1 pinned this issue Jun 15, 2022
@kdy1 kdy1 unpinned this issue Jun 15, 2022
@swc-project swc-project unlocked this conversation Jun 15, 2022
@swc-project swc-project locked as spam and limited conversation to collaborators Jun 15, 2022
@swc-project swc-project unlocked this conversation Oct 16, 2022
@willstott101
Copy link

willstott101 commented Nov 13, 2022

Just to join the dots for anyone unaware, there's a public repo where work on stc kdy1's typescript type checker written in rust is taking place:

https://github.com/dudykr/stc

@kdy1
Copy link
Member Author

kdy1 commented Jan 30, 2024

Closing as the stc is now abandoned. TypeScript was not something that I could follow up on in an alternative language.

@Kingwl
Copy link

Kingwl commented Jan 30, 2024

Sorry to hear that, but respect you for your contributions and efforts here!

@swc-bot
Copy link
Collaborator

swc-bot commented Feb 29, 2024

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests