Skip to content

Instantly share code, notes, and snippets.

@DouglasdeMoura
Created December 27, 2023 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DouglasdeMoura/b801a47199cdd819cec8962be2cf11e6 to your computer and use it in GitHub Desktop.
Save DouglasdeMoura/b801a47199cdd819cec8962be2cf11e6 to your computer and use it in GitHub Desktop.
Jokenpo in TypeScript
type Moves = "rock" | "paper" | "scissors";
type RockPaperScissors<_Move extends Moves> = _Move extends "rock"
? "paper"
: _Move extends "paper"
? "scissors"
: "rock";
type Result = RockPaperScissors<"rock">; // expected to be 'paper'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment