microsoft / microsoft/TypeScript
Bloomberg feedback for 5.8
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
### Acknowledgement
- [x] I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.
### Comment
We evaluated the 5.8 beta and RC releases and 5.8 seems to be a low impact release for us.
We are excited to adopt the new flag --erasableSyntaxOnly for the improved Editor experience for features we already avoid. A significant number of our projects already comply with the corresponding rules due to custom error checks that will happily become redundant. We remain interested in gaining the ability to use first-class enums that comply with the TS=JS+types model. For example via the [erasable as enum syntax proposal](https://github.com/microsoft/TypeScript/issues/60790).
| # | Change | Affects | Release notes | Packages affected|
|---|-------------------------------------------------------------------------|------------------|---------------|------------------|
| 1 |Computed properties with a non literal type now appear in declarations | Declaration Emit | Yes |>1% |
| 2 | Better type checking of conditional expressions | Type Checking | ~No~ Yes | ~1-2% |
### Computed properties with a non literal type now appear in declarations
Some declaration files changed and now preserve computed properties where index signatures would previously be created. This is an expected change and part of ongoing Isolated Declarations work.
```ts
// index.ts
export let foo = "x"
export class Bar {
[foo]: string
}
// index.d.ts
export declare let foo: string;
export declare class Bar {
// in 5.8
[foo]: string;
// in 5.7
[x: string]: string;
}
```
### Better checking in conditional expressions
We observed roughly a dozen new compile errors relating to improved conditional return checking.
While not directly announced the change seems related to [Checked Returns for Conditional and Indexed Access Types](https://devblogs.microsoft.com/typescript/announcing-typescript-5-8-beta/#checked-returns-for-conditional-and-indexed-access-types)
In TypeScript 5.7 and before, if a branch of a conditional expression returned any we would not get an error if we returned the wrong type on the other branch. Now we do, at least if the expression is in the return of a function:
```ts
declare const data: number | string | undefined;
const result = (): number =>
typeof data === 'string'
? null as any
: data; // Error now
const result2: number =
typeof data === 'string'
? null as any
: data; // Still not an error ? 😕
```
[Link](https://www.typescriptlang.org/play/?ts=5.7.3#code/LAKAJgpgxgNghgJwgAigewHYGcAuyxw5wBcyGArgLYBGECyAPsrggJYYDmjy5GkAZuwhgA3KHTY8yJFnIw8AXmQAKAJSkKNOsgUA+ZKGRHkOAJ4AHCGn75CcHQqUByFuw5PDxrwH4ycmMhwWIEYpp5eRqQERCLIAPRxyACiCAho9BhoAO6g4pi4RjJyOABMGlS09EoGIF5mlta2RA7OrpwetRFGvhQwAUEhYZ1dUXaxCcgAyjisfWRoeHAYyHRp9L6AvBuAqHtAA)
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 riproducendo l’esempio di espressione condizionale nel TypeScript Playground collegato usando 5.7.3 e 5.8, quindi confronta tra le versioni l’esempio di declaration emit riportato. L’issue documenta il comportamento osservato, ma non indica un file sorgente, un test o una modifica desiderata specifica; per completarla sarebbe quindi necessaria una guida da parte di un maintainer per stabilire se uno dei due comportamenti sia errato.
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
- Da chiarire
- Idoneità per principianti
- 25/100