Skip to content

Occasional type erasure #215

Open
Open

Description

@hydroper

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions