reactjs / reactjs/react-docgen
[TS] parse returns props without type field.
Aperta
Nessuno ha ancora preso questa issue.
typescript
- Lingua principale
- TypeScript
- Stelle
- 3.8k
- Fork
- 316
- Merge medio
- 5h 7m
- PR unite (30g)
- 4
Descrizione
the input code
import React from 'react';
import './button.css';
export interface ButtonProps {
/**
* Is this the principal call to action on the page?
*/
primary?: boolean;
/**
* What background color to use
*/
backgroundColor?: string;
/**
* How large should the button be?
*/
size?: 'small' | 'medium' | 'large';
/**
* Button contents
*/
label: string;
/**
* Optional click handler
*/
onClick?: () => void;
}
/**
* Primary UI component for user interaction
*/
export const Button: React.FC<ButtonProps> = ({
primary = false,
size = 'large',
backgroundColor,
label,
...props
}) => {
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
return (
<button
type="button"
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
style={{ backgroundColor }}
{...props}
>
{label}
</button>
);
};
the parse code
const rawReactDocs = parse(context.code, null, null, {
filename: context.fileName, //path.resolve(),
babelrc: false,
});
console.log("rawReactDocs", rawReactDocs)
const rawProps = rawReactDocs.props || {};
const props = Object.keys(rawProps)
.filter(name => name !== "children")
// .filter(name => rawProps[name].type || rawProps[name].tsType || rawProps[name].flowType)
.map(name => ({ name, value: rawProps[name] }));
console.log("props", props)

Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci l'input TSX fornito tramite l'entry point parse(context.code, ...) e ispeziona rawReactDocs.props. Quindi confronta i metadati delle props restituiti con il campo type previsto. Traccia il motivo per cui l'output del parser omette quel campo e aggiungi una coverage che mostri i metadati corretti per questo esempio.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- react, typescript
- Ambito
- documentation, tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100