kaleidawave / ezno

A JavaScript compiler and TypeScript checker written in Rust with a focus on static analysis and runtime performance
https://kaleidawave.github.io/posts/introducing-ezno/
MIT License
2.44k stars 45 forks source link

Add basic comments-as-types for variables and function parameters #57

Closed kaleidawave closed 1 year ago

kaleidawave commented 1 year ago

Treat postfix comments on variable identifiers and function parameters as a type annotation

error:
  ┌─ .\private\test-files\demo.ts:1:24
  │
1 │ const x /* string */ = 4;
  │            ------      ^ Type 4 is not assignable to type string
  │            │
  │            Variable declared with type string

this PR also adds a few changes to the parser to make this work