tc39 / proposal-type-annotations

ECMAScript proposal for type syntax that is erased - Stage 1
https://tc39.es/proposal-type-annotations/
4.13k stars 44 forks source link

Just a thought: add a way to register transpiler or compiler. #201

Open niyarlatotep opened 8 months ago

niyarlatotep commented 8 months ago

Maybe we can simply add a way to register any type checker or transpiler like it implemented in node js (or similar) i mean --loader (transpiler loader). And just write js code with types, then in the beginning of "main" module import (run) this checker or transpiler and it will typecheck and/or transpile code on the fly. It doesn't resolve typing "forks" problem but does the type annotation? I'm not a big expert but in my view it may solve most of noted in proposal problems.

Pros:

Cons:

We can somehow use compilers (transpilers) compiled to wasm if we need speed it up, or we want to have compiler written in other languages like rust etc

tocque commented 8 months ago

Translated from Chinese by GPT

I don't want to discuss the feasibility of this idea. But I think it should be noted that this idea can be used to negate the majority of proposals that have already been passed. For example, most methods added to built-in objects can be polyfilled, and async/await is just syntactic sugar. So I think this idea is not in line with the consistent thinking of TC-39.

niyarlatotep commented 8 months ago

Yes I understand the idea but it slightly different. When we discuss about async/await syntactic sugar (for instance) we have two ways to implement it:

  1. Polyfilling (many different design implementations)
  2. Standardization and add to language (single design implementation)

But if we discuss about the language it has its own standards in their ecosystems for example features instead of async/away etc. So yes if we want to standardized type annotation way in JS my idea is not suitable it's rather another proposal. The question is more about another way for solving sounded problems and about does it really solve the problem does we realy have such problems? Don't we already have checkers that doing the same things and mature enough?

azder commented 6 months ago

@niyarlatotep FYI https://github.com/tc39/proposal-type-annotations/issues/176#issuecomment-1732690996 it is the same or similar idea and a little above in another comment https://github.com/tc39/proposal-type-annotations/issues/176#issuecomment-1732520344