Skip to content

Instantly share code, notes, and snippets.

@xwartz
Last active January 28, 2022 02:31
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 xwartz/a38da0a520c8907d50ac44ca51d87f39 to your computer and use it in GitHub Desktop.
Save xwartz/a38da0a520c8907d50ac44ca51d87f39 to your computer and use it in GitHub Desktop.
interview-type
/**
* 给定数组,转换为对象类型,键/值必须在给定数组中。
**/
// Example:
const tuple = ['tesla', 'model 3', 'model X', 'model Y'] as const
const result: TupleToObject<typeof tuple> // expected { tesla: 'tesla', 'model 3': 'model 3', 'model X': 'model X', 'model Y': 'model Y'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment