microsoft / microsoft/TypeScript
Missing definition from union type when triggered from JSX tag name
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
Bug Report
This is a sample code for have a clean issue.
import React from 'react';
class A {
Renderer = RendererA;
}
class B {
Renderer = RendererB;
}
const RendererA = () => {
return <div> A </div>;
};
const RendererB = () => {
return <div> B </div>;
};
const TestRendererTypes = () => {
const AB: A | B = null; // just for the demo, AB can be A or B !
AB.Renderer; //🟩 okey cool,ts find all refs !
const LostRef = <AB.Renderer />; //🟥 not cool ,ts seem remove refs !
return LostRef;
};
🙁 Actual behavior
Ts decode only one reference to a function jsx when using inside tag </>
It should show both Renderer ref here !

🙂 Expected behavior
We should get all refs like that's . (working if use only a variable ref without a jsx tag <></> )

The example is basic, but inside my project i losing all refs, and this is a issu if i need fast track where a rendering is pointing !
And also will give incorrect props Intelisence !
Example here is missing all my others plugins !

But if i add a direct ref like that's , i can get all refs, but is polluting my code

It seem that's TS have some difficulty to understand JSX !
Is there a hacky and (clean way) to fix this ? or tell me if you guys have temp solutions ?
I hope i exposed correctly my issue !
thanks @+
TSC: Version 4.2.3
Version : 1.55.0 (user setup)
Commit : c185983a683d14c396952dd432459097bc7f757f
Date : 2021-03-30T16:01:55.261Z
Electron : 11.3.0
Chrome : 87.0.4280.141
Node.js : 12.18.3
V8 : 8.7.220.31-electron.0
OS : Windows_NT x64 10.0.19042
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
Inizia con la riproduzione TSX fornita e il TypeScript Playground collegato, confrontando la risoluzione dei riferimenti per AB.Renderer con <AB.Renderer />. Traccia il percorso di risoluzione del nome del tag JSX; completato quando vengono riportati entrambi i riferimenti a RendererA e RendererB per l’unione e JSX props/intellisense includono entrambi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- react, typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100