Typescript: Component props not parsed with 'call signature' type
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- react, typescript
- Ambito
- documentation, tooling
Direzione di ricerca
Inizia riproducendo l’esempio .tsx nel playground di react-docgen con Language impostato su Typescript, confrontando Component1 e Component2. Traccia il punto di ingresso del parsing TypeScript per i componenti a cui è assegnato un tipo con firma di chiamata; il lavoro è completo quando Component1 include gli stessi metadati della prop foo di Component2.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
In Typescript, it's possible to type a function using a call signature.
For example, this is valid TS:
interface A {
foo: string;
}
type FnType = (props: A) => string;
const Fn1: FnType = (props) => props.foo; // valid
const Fn2 = (props: A) => props.foo; // also valid
See example in TS Playground
In the above example, react-docgen generates types for Fn2, but does not generate types for Fn1 which is defined with a call signature type.
Expected Behavior
This code:
// component.tsx
interface A {
foo: string;
}
type ComponentType = (props: A) => JSX.Element;
const Component1: ComponentType = (props) => <div />; // does not include generated props
const Component2 = (props: A) => <div />; // includes generated props
Produces this output:
[
{
"description": "",
"displayName": "Component1",
"methods": [],
"props": {
"foo": {
"required": true,
"tsType": {
"name": "string"
},
"description": ""
}
}
},
{
"description": "",
"displayName": "Component2",
"methods": [],
"props": {
"foo": {
"required": true,
"tsType": {
"name": "string"
},
"description": ""
}
}
}
]
Actual Behavior
The same code produces this output:
[
{
"description": "",
"displayName": "Component1",
"methods": []
},
{
"description": "",
"displayName": "Component2",
"methods": [],
"props": {
"foo": {
"required": true,
"tsType": {
"name": "string"
},
"description": ""
}
}
}
]
Steps to Reproduce
Paste the .tsx sample code from the "Expected Behavior" section in the react-docgen playground with Language set to Typescript.
- Lingua principale
- TypeScript
- Stelle
- 3.8k
- Fork
- 316
- Merge medio
- 3h 28m
- PR unite (30g)
- 6
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.
Altre issue di reactjs/react-docgen
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
reactjs/react-docgen#1102 ·
-
Typescript Status Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
reactjs/react-docgen#1005 · 4 reazioni ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
reactjs/react-docgen#997 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
reactjs/react-docgen#994 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
reactjs/react-docgen#982 · 2 commenti ·
Tutte le issue di reactjs/react-docgen
Issue simili
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
Mend: dependency security vulnerability untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100