microsoft / microsoft/TypeScript

TS3.6 regression: Map constructor overloads

Offen
#33,611 0 Kommentare 8 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@rbuckton arbeitet bereits daran.

Seit 26.9.2019.

Needs Investigation
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

TypeScript Version: 3.7.0-dev.20190917

Search Terms: Map constructor overload array concatenation

Code

const M1 = new Map([
  ['k', {a: 1, b: 'asd'}],
  ['k', {a: 2, b: 'asd'}],
]);

const M2 = new Map([
  ...M1,
  ['k', {a: 1}],
]);

Expected behavior:

Success, constructs a const M2: Map<string, {a: number;}>.

Actual behavior:

input.ts(6,20): error TS2769: No overload matches this call.
  The last overload gave the following error.
    Argument of type '([string, { a: number; b: string; }] | [string, { a: number; }])[]' is not assignable to parameter of type 'readonly (readonly [string, { a: number; b: string; }])[]'.
      Type '[string, { a: number; b: string; }] | [string, { a: number; }]' is not assignable to type 'readonly [string, { a: number; b: string; }]'.
        Type '[string, { a: number; }]' is not assignable to type 'readonly [string, { a: number; b: string; }]'.
          Types of property '1' are incompatible.
            Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: string; }'.

Playground Link:
https://www.typescriptlang.org/play/#code/MYewdgzgLgBAsgRhgXhmApgd3gQwA4AUA2gFAwxEDkA1pQDQwDeOAXDAgwEZuU4QAmlAL4BdOmQo16TVjABMXHn0GjxIgJQBuEiVCRYcOSjRZchUuQB01xOPJVaDZmwSqSGkkA

Related Issues:

None found.

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.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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