-
Notifications
You must be signed in to change notification settings - Fork 8
Simplified API for custom types #73
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
Open
JohannesMeierSE
wants to merge
18
commits into
main
Choose a base branch
from
jm/simple-custom-types
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+1,662
−70
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…Selectors, calculate identifiers only from custom properties
…, more comments, renamings
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 contributes a simplified API to enable users of Typir to define and use their project-specific custom types. Features of custom types as designed in this PR:
custom-cycles.test.ts
andcustom-selectors.test.ts
)For some more fixes/features of this PR beyond custom types, see the
CHANGELOG.md
.Open questions to discuss during the review:
LanguageService.isLanguageNode(node: unknown): node is LanguageType
, which is used once and only for a detail (which has some relevance nevertheless): Is there a better solution? Should we make it optional (or is the default implementation OK)? For me, this feels not like a perfect solution.Type
), since they cannot be distinguished from string values for primitive properties. In my eyes, that is a reasonable limitation, since you will get a TypeScript error, if you try to do that.getTypeFinal(): Type|undefined
on the initializer always, even in cases, where it is not required, since your custom type has no types as properties or you know, that all depending types are already available. Even in these cases you need the "work-around" withconst myCustomType = ...finish().getTypeFinal()!;
. An idea would be to provideSimpleCustomType
s (without support for circular types) andComplexCustomType
s (with support for circular types) and the user of Typir has to select the appropriate solution for the current use case.undefined
is not supported as result to be returned by an inference rule. You need to returnInferenceRuleNotApplicable
, if the rule is for another case, or anInferenceProblem
. Should we supportundefined
as well? That might simplify some things.Hints for the review:
custom-example-matrix.test.ts
andcustom-example-restricted.test.ts
first to get an idea, how the API works.custom-type.ts
andcustom-definitions.ts
🙂