Skip to content

Instantly share code, notes, and snippets.

@mfbx9da4
Created May 5, 2021 17:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfbx9da4/92e8cd311f07bc3afdf58f228710aca5 to your computer and use it in GitHub Desktop.
Save mfbx9da4/92e8cd311f07bc3afdf58f228710aca5 to your computer and use it in GitHub Desktop.
class Foo {
public a string
public b number
}
function getDefault(fieldAsString: 'a' | 'b') {
if (field === 'a') return 'asdf'
if (field === 'b') return 3
}
const ret = getDefault('a') // returns string
const ret = getDefault('b') // returns number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment