microsoft / microsoft/TypeScript

TS3.6 regression: Map constructor overloads

Aperta
#33,611 0 commenti 8 reazioni 1 assegnatario Vedi su GitHub

@rbuckton ci sta già lavorando.

Dal 26/9/2019.

Needs Investigation
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.