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

feat: Add const typing for Language Names #2554

Open
wants to merge 79 commits into
base: master
Choose a base branch
from

Conversation

inferrinizzard
Copy link
Contributor

@inferrinizzard inferrinizzard commented Apr 6, 2024

Description

Moves displayName, names, extension to external consts in each TargetLanguage file, and then passed as a generic arg to the base TargetLanguage class. This allows them to be statically analysed by the TypeScript compiler - leading to stricter typings for languages.

  • TypeScriptFlowBaseTargetLanguage has been removed
  • TypeScriptTargetLanguage and FlowTargetLanguage no longer extend from JavaScriptTargetLanguage
  • all TargetLanguage classes now inherit directly from TargetLanguage instead*

*this is a minor breaking change for anyone who was inheriting from an existing TargetLanguage class, guide on how to properly extend custom classes to come

Motivation and Context

Previously, the lang option would allow for string | TargetLanguage - which would allow for any arbitrary string to be passed and would cause errors at runtime instead of at write time. This change shifts that error left and prevents any incorrect strings from being passed in the first place.

Previous Behaviour / Output

options.lang used to be:
image

New Behaviour / Output

now looks like:
image

How Has This Been Tested?

Screenshots (if appropriate):

@inferrinizzard inferrinizzard changed the title Feat/core/language types feat: Add static typing for Language Names Apr 6, 2024
@inferrinizzard inferrinizzard changed the title feat: Add static typing for Language Names wip: feat: Add static typing for Language Names Apr 6, 2024
@inferrinizzard inferrinizzard changed the title wip: feat: Add static typing for Language Names feat: Add const typing for Language Names Apr 16, 2024
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

Successfully merging this pull request may close these issues.

None yet

1 participant