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

[Feature] Add full interface support for defining interfaces and checking against given types #527

Open
2 of 5 tasks
Luna-Klatzer opened this issue Jun 26, 2024 · 0 comments
Assignees
Labels
feature New feature or enhancement
Milestone

Comments

@Luna-Klatzer
Copy link
Member

Is there an existing proposal for this?

  • I have searched the existing issues

This feature does not exist in the latest version

  • I am using the latest version

Proposal

Add full interface support which allows the user to define interfaces and match objects against them.

For example:

interface X {
  x: num;
  y: num;
}

var x: X = {
  x: 1,
  y: 2,
};

This issue does NOT implement casts or conversions of objects but focuses solely on the support of defining an object with an interface type and letting the user provide constraints on variables or arguments that must have the specific object type.

Exact behaviour / changes you want

  • Add semantic analysis and type checking for the interface AST node.
  • Add internal translation of the interface definition to an internal type representation, which can then be used to match against objects.
  • Implement support for "custom types" in the form of interfaces (such as var x: X where X is the custom type), which can be used as a value in variable and function declarations and can be checked against.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or enhancement
Projects
Development

No branches or pull requests

2 participants