Skip to content

Instantly share code, notes, and snippets.

@sitepodmatt
Last active July 13, 2019 13:56
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 sitepodmatt/b42e6ba1aa74d10794a534f1970cc1a7 to your computer and use it in GitHub Desktop.
Save sitepodmatt/b42e6ba1aa74d10794a534f1970cc1a7 to your computer and use it in GitHub Desktop.
babysteps.js
class DType<A> {
readonly _A!: { [P in keyof A] : A[P] }
constructor(t : A) {
}
}
const UserModel = new DType({ name: ""})
type Infer<C extends any> = C['_A']
type User = Infer<typeof UserModel>
function sayHello(s : User) {
console.log(s.name)
}
sayHello({ xname: "Matt" })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment