Last active
September 14, 2020 09:35
-
-
Save mrousavy/999dd6b038b8e9193e4f7f1f5848dbbe to your computer and use it in GitHub Desktop.
TypeScript: Omit parameter using generics (e.g. useful for navigation commands with optional parameters)
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
| interface StoryView { | |
| onStoryPressed: <TStory extends UserStory | CategoryStory>( | |
| ...args: TStory extends UserStory ? [stories: Story[], selectedStory: UserStory, user: User] : [stories: Story[], selectedStory: CategoryStory] | |
| ) => void; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment