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

Occasional type erasure #215

Open
hydroper opened this issue Mar 15, 2024 · 0 comments
Open

Occasional type erasure #215

hydroper opened this issue Mar 15, 2024 · 0 comments

Comments

@hydroper
Copy link

hydroper commented Mar 15, 2024

I read that some people find the type erasure proposal not trustworthy as tools such as TypeScript and Flow have different type checking behavior and may also vary due to version upgrades.

If the proposal was taking the runtime types approach, possibly there could be a special treatment of complex types such as union and complement types, similiar to polymorphism:

  • Complex types are checked at compile time for correctness
  • Complex types are converted to any at runtime.

For example, consider the following program:

type U = "n1" | "n2";

const v: U = "nN";

The above program generates a compile time verify error. If it were valid, it'd translate to:

const v: any = "nN";

Complex types include:

  • Union types
  • Complement types
  • Type parameters
  • Structural function types
  • Tuple types
  • Structural object types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant