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

TypeScript Type Aliases #13

Merged
merged 12 commits into from
Sep 19, 2022
Merged

TypeScript Type Aliases #13

merged 12 commits into from
Sep 19, 2022

Conversation

alexisthedev
Copy link
Owner

This is still a WIP. Opened PR for status reports and discussion on the progress of this feature since GitHub does not allow to reference already existing branches in Issues (#8).

@alexisthedev
Copy link
Owner Author

alexisthedev commented Aug 24, 2022

(WIP)

Things that need to be completed

  • Extend AST for TypeScript type alias nodes
  • Add type aliases as a type in typescript_types
  • Extend generator by extending the list in top_level_decl through calling a builtin factory method with type alias gen func
  • Add decl to context (look into already existing add_type function)

@alexisthedev alexisthedev marked this pull request as draft August 24, 2022 17:53
@alexisthedev alexisthedev self-assigned this Aug 24, 2022
@alexisthedev alexisthedev linked an issue Aug 24, 2022 that may be closed by this pull request
@alexisthedev alexisthedev added the enhancement New feature or request label Aug 24, 2022
@alexisthedev alexisthedev changed the title (Global Feature) Type Aliases TypeScript Type Aliases Aug 25, 2022
@alexisthedev
Copy link
Owner Author

What's left in this PR is solving a new bug that has appeared after adding type aliases, where hephaestus can not correctly recognize subtyping relations (ie. trying to assign a boolean to a number).

@alexisthedev alexisthedev mentioned this pull request Sep 1, 2022
4 tasks
@alexisthedev
Copy link
Owner Author

alexisthedev commented Sep 15, 2022

Type Aliases are ready to go! For more information on the issue described on my previous message, please read this. A similar issue was encountered and fixed while developing the Union Types feature.

After adding complete support for TypeScript's Structural Typing system and Union Types, we will proceed with adding both Union Types as candidates for Type Aliases (should be trivial after adding support for these features). Keep an eye out for the progress on that update in the Union Types pull request.

@alexisthedev alexisthedev marked this pull request as ready for review September 15, 2022 11:01
Copy link
Collaborator

@theosotr theosotr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

Please also add unit tests for checking that the subtyping relations of the TypeAlias, StringLiteralType, and NumberLiteralType types work as expected.

src/generators/generator.py Outdated Show resolved Hide resolved
src/generators/generator.py Outdated Show resolved Hide resolved
src/ir/builtins.py Show resolved Hide resolved
src/ir/typescript_ast.py Show resolved Hide resolved
src/ir/typescript_types.py Outdated Show resolved Hide resolved
src/ir/typescript_types.py Outdated Show resolved Hide resolved
src/ir/typescript_types.py Outdated Show resolved Hide resolved
src/ir/typescript_types.py Outdated Show resolved Hide resolved
src/ir/typescript_types.py Outdated Show resolved Hide resolved
src/translators/typescript.py Outdated Show resolved Hide resolved
@alexisthedev
Copy link
Owner Author

This should be ready to merge after pushing the required unit tests.

src/generators/generator.py Outdated Show resolved Hide resolved
src/generators/generator.py Outdated Show resolved Hide resolved
src/generators/generator.py Outdated Show resolved Hide resolved
src/generators/generator.py Outdated Show resolved Hide resolved
src/generators/generator.py Outdated Show resolved Hide resolved
@theosotr theosotr merged commit 50007dd into main Sep 19, 2022
@alexisthedev alexisthedev deleted the ts-type-alias branch September 19, 2022 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type Aliases
2 participants