extract-react-types icon indicating copy to clipboard operation
extract-react-types copied to clipboard

Add support for prop types which extend other types/interfaces

Open GlennSouthern opened this issue 5 years ago • 3 comments

For example

interface Foo {
 foo: boolean;
}
interface BarProps extends Foo {
 bar: string;
}
const BarComponent: FC<BarProps> = (props) => {}

GlennSouthern avatar Feb 06 '20 06:02 GlennSouthern

Issue makes sense - just commenting that if you are only using typescript, we've also built a library called magical types that's basically this but slightly better because it only needs to resolve typescript, and taking advantage of that.

Noviny avatar Feb 06 '20 23:02 Noviny

@Noviny what's a like for like usage of extractReactTypes vs magical-types look like?

eg:

const { extractReactTypes } = require('extract-react-types');

/// ....
extractReactTypes(content, typeSystem, filename, resolveOpts);

Roughly translates to which API in @magical-types

DarkPurple141 avatar Dec 02 '20 05:12 DarkPurple141

Same issue here. As soon as we do something like:

const Label: FC<Props & ComponentProps<'label'>> = ({ [...]

We end up with nothing in ___types at all.

strange avatar Oct 04 '21 13:10 strange