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

Types which differ according to "type" or "kind" #21

Open
lazarljubenovic opened this issue Oct 13, 2019 · 1 comment
Open

Types which differ according to "type" or "kind" #21

lazarljubenovic opened this issue Oct 13, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@lazarljubenovic
Copy link
Owner

lazarljubenovic commented Oct 13, 2019

const isMorphRuleOfType = <TMorphType extends MorphType> (type: TMorphType) => {
  return (rule: MorphRuleBase<MorphType>): rule is MorphRuleBase<TMorphType> => {
    return rule.type === type
  }
}

Think of a way to quickly create this. Something like hasType('type', type).

@lazarljubenovic lazarljubenovic added the enhancement New feature or request label Oct 13, 2019
@lazarljubenovic
Copy link
Owner Author

The term seems to be "discriminated unions", see here for example: https://basarat.gitbooks.io/typescript/docs/types/discriminated-unions.html

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

No branches or pull requests

1 participant