More type safety for language keys #93
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR increases the TypeScript type-safety and can be seen as a follow-up of #90
TypirSpecifics
now contain the propertyLanguageKeys: Record<string, unknown>;
to make language keys explicit. This is the precondition for the following improvements:Specifics['LanguageKeys']
to simplify inference rules for functions and operators: Now it is possible to skip the TypeScript type when using onlylanguageKey
and nofilter
. @Lotes You sketched this idea some time ago and now we have everything to make your idea happen 🙂Contributions of this PR which are not related to language keys:
languageProperty
supports only valid property names of the givenlanguageNode
Open issues:
Specifics['LanguageKeys']
now even in Typir (core), we could support the featuresaddValidationRulesForAstNodes
andaddInferenceRulesForAstNodes
(which are Typir-Langium only so far) also in Typir (core): I would prefer that (but did not implement that yet), what do you think?typir.ts
, there are two open issues/improvements marked with// possible extension
, for which I found no solution so farI recommend to review this PR commit by commit.