gcanti / typelevel-ts

Type level programming in TypeScript
https://gcanti.github.io/typelevel-ts
MIT License
356 stars 12 forks source link

Using `Exact` with React props it doesn't warn on prop of type `any` #31

Closed leighman closed 6 years ago

leighman commented 6 years ago

Using Exact to correct overly broad Props types with React

interface Props {
  something: string
}

class Blah<T extends Exact<Props, T>> extends React.PureComponent<T> {}

...

const foo: any = 1

return (<Blah something="test" foo={foo} />)

seems to be accepted.

Changing to export type Exact<A extends object, B extends A> = A & Record<Exclude<keyof B, keyof A>, never> works as I would expect.

Is there a reason that undefined is used? Should I be using RowLacks or something instead?

gcanti commented 6 years ago

Is there a reason that undefined is used?

Actually no, thanks for pointing out. I'll put up a PR