Skip to content

Instantly share code, notes, and snippets.

@jamesseanwright
Created April 24, 2020 16:22
Show Gist options
  • Select an option

  • Save jamesseanwright/705a8f7fa803fa5a04d79569891a4ae9 to your computer and use it in GitHub Desktop.

Select an option

Save jamesseanwright/705a8f7fa803fa5a04d79569891a4ae9 to your computer and use it in GitHub Desktop.
Creating TypeScript object types with mapped types
type LogLevel =
| 'debug'
| 'info'
| 'warning'
| 'error';
type Logger = {
[Level in LogLevel]: (...args: unknown[]) => void;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment