Open
Description
Original Example (fixtures_23.tsx)
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
import React, { Component } from 'react';
type BaseProps = {
/** Optional prop */
foo?: string,
/** Required prop */
bar: number
};
type TransitionDuration = number | { enter?: number, exit?: number } | 'auto';
type Props = BaseProps & {
/** Complex union prop */
baz: TransitionDuration
}
/**
* This is a typescript class component
*/
export default class TSComponent extends Component<Props> {
render() {
return <h1>Hello world</h1>;
}
}
The output for the above example seems to be generated correctly.
Modified example with interfaces
import React, { Component } from "react";
interface BaseProps {
/** Optional prop */
foo?: string;
/** Required prop */
bar: number;
}
type TransitionDuration = number | { enter?: number; exit?: number } | "auto";
interface Props {
something: BaseProps;
/** Complex union prop */
baz: TransitionDuration;
}
/**
* This is a typescript class component
*/
export default class TSComponent extends Component<Props> {
render() {
return <h1>Hello world</h1>;
}
}
Output
{
"description": "This is a typescript class component",
"displayName": "TSComponent",
"methods": [],
"props": {
"something": {
"required": true,
"tsType": {
"name": "BaseProps"
},
"description": ""
},
"baz": {
"required": true,
"tsType": {
"name": "union",
"raw": "number | { enter?: number; exit?: number } | \"auto\"",
"elements": [{
"name": "number"
}, {
"name": "signature",
"type": "object",
"raw": "{ enter?: number; exit?: number }",
"signature": {
"properties": [{
"key": "enter",
"value": {
"name": "number",
"required": false
}
}, {
"key": "exit",
"value": {
"name": "number",
"required": false
}
}]
}
}, {
"name": "literal",
"value": "\"auto\""
}]
},
"description": "Complex union prop"
}
}
}
Issue
props.something
in the above output has only the name
and not the interface
which is defines.