microsoft / microsoft/TypeScript

Bloomberg feedback for 5.9

Offen
#62,156 1 Kommentar 7 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Discussion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

### Comment

We evaluated the 5.9 RC releases and 5.9 is a low impact release for us.

| # | Change | Affects | Release notes | Packages affected | PR / Issue |
| - | -------------------------------------------------------------------------- | ---------------- | ------------- | ----------------- | ---------- |
| 1 | Class expressions with private fields produce invalid `.d.ts` output | Declaration Emit | No | <1% | [#62153](https://github.com/microsoft/TypeScript/issues/62153) |
| 2 | `Promise.all` over constant tuples no longer infers tuple | Type Checking | No | <1% | [#62071](https://github.com/microsoft/TypeScript/issues/62071) |
| 3 | JavaScript emit removes parentheses around `??` in conditional expressions | Emit | No | <1% | – |
| 4 | Better detection of always-true errors in `??` expressions | Type Checking | No | <1% | – |

## Class expressions with private fields produce invalid `.d.ts` output

With TypeScript 5.9, the following code:

```ts
export const ClassExpression = class {
#context = 0
};
```

Produces invalid declaration output:

```ts
export declare const ClassExpression: {
new (): {
#context: number;
};
};
```

5.8 output was also incorrect but at least syntactically valid:

```ts
export declare const ClassExpression: {
new (): {
"__#1@#context": number;
};
};
```

❗This seems like a major regression, since emitted declarations are now invalid.
Tracked in [#62153](https://github.com/microsoft/TypeScript/issues/62153)

## `Promise.all` over array literal no longer infers a tuple

This issue is easier to reproduce than the linked ticket may suggest. It affects any use of `Promise.all` in the return position of a `.then()` that chains from a promise resolving to an array:

```ts
const p = Promise.resolve([]).then(() => {
return Promise.all([0, ""]);
});
const test: Promise<[number, string]> = p; // error
```

This now fails to infer a tuple and infers `Promise<(string | number)[]>` instead.
While we can work around this issue by assigning the result of `Promise.all` to an intermediate variable, this does seem like an unfortunate regression.

Tracked in [#62071](https://github.com/microsoft/TypeScript/issues/62071)

## JavaScript emit removes parentheses around `??` in conditional expressions

In some cases, parentheses are removed from nullish coalescing expressions in emitted JavaScript. This change seems benign.

```ts
(test ?? true) ? A : B
```

Becomes:

```ts
test ?? true ? A : B
```

## Better detection of always-true errors in `??` expressions

We observed two new diagnostics related to always-true `??` expressions.
The improved detection highlighted logic errors that were previously missed.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit den Reproduktions-Snippets im Issue und den verlinkten Tickets #62153 und #62071, in denen zwei der gemeldeten Regressionen nachverfolgt werden. Vergleiche das Deklarations- oder Type-Checking-Verhalten von 5.8 und 5.9 und begrenze die Arbeiten dann auf eine bestätigte Regression; der Bericht selbst identifiziert keine Dateien, Tests oder eine einzelne Definition of done.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, typescript
Bereich
compilers
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
15/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.