microsoft / microsoft/TypeScript
`Exclude<Exclude<T, null>, undefined>` is not assignable to `Exclude<T, null | undefined>` and vice versa
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
TypeScript Version: Nightly
Search Terms:
typescript nullness inference
Expected behavior:
They should be assignable to each other.
Actual behavior:
They are not considered assignable to each other.
Type 'Exclude<Exclude<T, null>, undefined>' is not assignable to type 'Exclude<T, null | undefined>'.
Type 'Exclude<T, null>' is not assignable to type 'Exclude<T, null | undefined>'.
Type 'T' is not assignable to type 'Exclude<T, null | undefined>'.(2322)
and
Type 'Exclude<T, null | undefined>' is not assignable to type 'Exclude<Exclude<T, null>, undefined>'.
Type 'T' is not assignable to type 'Exclude<Exclude<T, null>, undefined>'.(2322)
Related Issues:
N/A
Code
export function f<T>(v: Exclude<Exclude<T, null>, undefined>) {
const w: Exclude<T, null | undefined> = v;
}
export function g<T>(v: Exclude<T, null | undefined>) {
const w: Exclude<Exclude<T, null>, undefined> = v;
}
Output
export function f(v) {
const w = v;
}
export function g(v) {
const w = v;
}
Compiler Options
{
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"useDefineForClassFields": false,
"alwaysStrict": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"downlevelIteration": false,
"noEmitHelpers": false,
"noLib": false,
"noStrictGenericChecks": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"esModuleInterop": true,
"preserveConstEnums": false,
"removeComments": false,
"skipLibCheck": false,
"checkJs": false,
"allowJs": false,
"declaration": true,
"experimentalDecorators": false,
"emitDecoratorMetadata": false,
"target": "ES2017",
"module": "ESNext"
}
}
Playground Link: Provided
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 dal link Playground fornito e dalle funzioni generiche f e g con le opzioni rigorose del compilatore indicate. Traccia il modo in cui il compilatore verifica i due tipi Exclude annidati, quindi verifica che entrambe le assegnazioni vengano accettate senza gli errori TS2322 segnalati, preservando l'output emesso mostrato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 35/100