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

Fix Signature handling for unions and generics #391

Merged
merged 2 commits into from Apr 1, 2022

Conversation

chriskrycho
Copy link
Contributor

Cherry-picks this fix to master from #390 (which targets v1.x).

Ultimately, we should be able to drop these shenanigans entirely before cutting v2.0, but we’ll want to give folks currently using the v2 betas a heads-up about it.

@chriskrycho chriskrycho added the bug label Apr 1, 2022
@chriskrycho chriskrycho force-pushed the bugfix-signature-master branch 2 times, most recently from 6fa1ace to 89cc232 Compare April 1, 2022 17:13
Comment on lines 2 to 6

// Intentionally checking the shape of the exports *and* the export itself.
import * as gc from '@glimmer/component';
// eslint-disable-next-line no-duplicate-imports
import Component from '@glimmer/component';
Copy link
Member

Choose a reason for hiding this comment

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

Linting doesn't seem to like this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahhh, the problem is that it's tslint instead of eslint. Ugh.

When using a `keyof` type to check whether the type parameter for
Glimmer Component is a `Signature` or the classic `Args`-only type, if
we do not force TS to distribute over union types, it resolves the
`keyof` check for union types with no shared members as `never`, and
`never extends <anything>` is always true. This in turn meant that for
all such unions, as well as for cases where users were providing
generic types which could then be further extended in their own
subclasses.

Accordingly, introduce the standard technique TypeScript provides for
opting into distributivity: conditional types are documented to support
exactly this.

(cherry picked from commit ad429d5)
@chadhietala chadhietala merged commit 8edbbb8 into master Apr 1, 2022
@chadhietala chadhietala deleted the bugfix-signature-master branch April 1, 2022 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants