microsoft / microsoft/TypeScript

bug(lib): Explicitly stating wrong return type of `Promise.then` without arguments results in no error

Aperta
#63,244 5 commenti 1 reazione 0 assegnatari Vedi su GitHub
Needs Proposal
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

### 🔎 Search Terms

- silenced Promise resolution type mismatch
- Promise generic explicit no error
- no error when Promise type is specified explicitly
- generic inside optional argument

### 🕗 Version & Regression Information

TS v3.3.3 correctly detects the error, which is the earliest Playground version. All other Playground versions silence the error.

### ⏯ Playground Link

https://www.typescriptlang.org/play/?ts=6.0.0-dev.20260312#code/MYewdgzgLgBFCm0BcMAKAnEBbAlheAPNOjmAOYB8MAvGprvgHTqIgA2AbvABQCMAlIygALeGG78A3EA

### 💻 Code

```ts
const test: Promise = Promise.resolve(1).then();
```

### 🙁 Actual behavior

No TypeScript errors.

### 🙂 Expected behavior

I expected a similar error to what TS v3.3.3 yields:
> Type `Promise` is not assignable to type `Promise`. Type `number` is not assignable to type `string`.

### Additional information about the issue

_No response_

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Riproduci l’esempio segnalato nel TypeScript Playground collegato e confronta il comportamento attuale con il risultato di TypeScript 3.3.3 descritto nell’issue. Traccia il percorso del controllo dei tipi per Promise.then chiamato senza argomenti; il lavoro è completato quando l’assegnazione esplicita a Promise segnala l’incompatibilità con Promise.

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.