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!: expose language metadata as const #1111

Merged
merged 2 commits into from
Jul 12, 2023
Merged

Conversation

coolya
Copy link
Contributor

@coolya coolya commented Jul 6, 2023

Exposing the LanguageMetadata as const with satisfies allows the values of its members like languageId or fileExtensions to be exposed statically. This allows for patterns like

type MyFileExtensions = typeof MyFancyDSLLanguageMetaData.fileExtensions

Where MyFileExtensions is not typed to a generic string[] but to ['.myDsl'] which makes it easier to avoid mistakes.

Unfortunately this is a breaking change because it requires the fileExtensions on the LanguageMetaData to be readonly to work.

Exposing the LanguageMetadata as const with satisfies allows the values of
its members like `languageId` or `fileExtensions` to be exposed statically.
This allows for patterns like
```
type MyFileExtensions = typeof MyFancyDSLLanguageMetaData.fileExtensions
```
Where then MyFileExtensions is not typed to a generic `string[]`
but to `['.myDsl']` which makes it easier to avoid mistakes.

Unfortunately this is a breaking change because it requires the fileExtensions
on the LanguageMetaData to be readonly to work.
@msujew msujew added the cli CLI related issue label Jul 11, 2023
Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution! Looks good to me 👍

@msujew msujew merged commit 1749111 into eclipse-langium:main Jul 12, 2023
3 checks passed
@spoenemann spoenemann added this to the v2.0.0 milestone Jul 19, 2023
spoenemann pushed a commit that referenced this pull request Aug 15, 2023
Exposing the LanguageMetadata as const with satisfies allows the values of
its members like `languageId` or `fileExtensions` to be exposed statically.
This allows for patterns like
```
type MyFileExtensions = typeof MyFancyDSLLanguageMetaData.fileExtensions
```
Where then MyFileExtensions is not typed to a generic `string[]`
but to `['.myDsl']` which makes it easier to avoid mistakes.

Unfortunately this is a breaking change because it requires the fileExtensions
on the LanguageMetaData to be readonly to work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli CLI related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants