Skip to content

Instantly share code, notes, and snippets.

@blemoine
Created March 23, 2017 00:23
Show Gist options
  • Save blemoine/1556781059b4f0a15c5882b240282a64 to your computer and use it in GitHub Desktop.
Save blemoine/1556781059b4f0a15c5882b240282a64 to your computer and use it in GitHub Desktop.
//A simple identity function for string literals
function<P extends string>myId(param: P): P {
return param;
}
const r: "foo" = myId("foo")
const r2: "bar" = myId("bar")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment