Skip to content

Instantly share code, notes, and snippets.

@ken-okabe
Created August 1, 2018 23:08
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 ken-okabe/d88fa7359d722765dbb828676058668b to your computer and use it in GitHub Desktop.
Save ken-okabe/d88fa7359d722765dbb828676058668b to your computer and use it in GitHub Desktop.
const typedPrimitive = (I: Function) => (i: undefined) => {
const derived = Object(i);
Object.setPrototypeOf(derived, Object(i));
const typeProperty = {
enumerable: false,
configurable: false,
writable: false,
value: I
};
Object.defineProperty(derived, String(I), typeProperty);
return <undefined>derived;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment