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

Make macro configs static #1815

Merged
merged 2 commits into from
Feb 27, 2024
Merged

Make macro configs static #1815

merged 2 commits into from
Feb 27, 2024

Conversation

simonihmig
Copy link
Collaborator

@simonihmig simonihmig commented Feb 23, 2024

Fixes #1804

@simonihmig simonihmig force-pushed the static-macros-config branch 2 times, most recently from 21ab0eb to c46b5b0 Compare February 26, 2024 17:31
? maybeFastbootMemberExpression.get('property')
: maybeFastbootMemberExpression.isOptionalMemberExpression()
? maybeFastbootMemberExpression.get('property')
: assertNever(maybeFastbootMemberExpression);
Copy link
Collaborator Author

@simonihmig simonihmig Feb 26, 2024

Choose a reason for hiding this comment

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

This looks weird, but I found no better way to make TS happy. I had it first as simple as this:

image

You see the return type of .get('property') is not correct, it cannot be an array of NodePath, that makes no sense...

Those tertiary expressions narrow down the type before hitting .get() to make it return the correct type.

The type definition of .get() would not deal well with a union type (NodePath<MemberExpression> | NodePath<OptionalMemeberExpression> it seems, falling back to the second loosely typed one:

image

That tertiary expression would narrow down the type before hitting .get(), returning the expected correct type.

@simonihmig
Copy link
Collaborator Author

Failing tests are the same as those on master, fixed in #1817...

@simonihmig simonihmig marked this pull request as ready for review February 26, 2024 17:58
@simonihmig simonihmig requested a review from ef4 February 26, 2024 17:59
@simonihmig simonihmig merged commit f60adbb into stable Feb 27, 2024
201 checks passed
@simonihmig simonihmig deleted the static-macros-config branch February 27, 2024 19:06
@simonihmig simonihmig added the enhancement New feature or request label Feb 27, 2024
@github-actions github-actions bot mentioned this pull request Feb 28, 2024
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.

2 participants