You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make Map constructor argument optional and nullable (microsoft#43396)
* Make Iterable Map constructor argument optional
Fixesmicrosoft#37779
* Change Map constructor in iterable to accept both null and undefined.
According to the spec (https://tc39.es/ecma262/#sec-map-iterable), the sole argument passed to Map is allowed to be null or undefined.
* Changed Map constructor to ensure new Map() still types as Map<any, any>.
* Add map constructor test.
This proves that the previous commit fixesmicrosoft#37779, as well as that new Map() still types as Map<any, any>.
* Update baseline.
Co-authored-by: Jared Neil <[email protected]>
!!! error TS2769: Overload 1 of 3, '(iterable: Iterable<readonly [string, boolean]>): Map<string, boolean>', gave the following error.
20
+
!!! error TS2769: Overload 1 of 4, '(iterable?: Iterable<readonly [string, boolean]>): Map<string, boolean>', gave the following error.
21
21
!!! error TS2769: Argument of type '([string, number] | [string, true])[]' is not assignable to parameter of type 'Iterable<readonly [string, boolean]>'.
22
22
!!! error TS2769: The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types.
23
23
!!! error TS2769: Type 'IteratorResult<[string, number] | [string, true], any>' is not assignable to type 'IteratorResult<readonly [string, boolean], any>'.
@@ -27,7 +27,7 @@ tests/cases/conformance/es6/for-ofStatements/for-of39.ts(1,11): error TS2769: No
27
27
!!! error TS2769: Type '[string, number]' is not assignable to type 'readonly [string, boolean]'.
28
28
!!! error TS2769: Type at position 1 in source is not compatible with type at position 1 in target.
29
29
!!! error TS2769: Type 'number' is not assignable to type 'boolean'.
30
-
!!! error TS2769: Overload 2 of 3, '(entries?: readonly (readonly [string, boolean])[]): Map<string, boolean>', gave the following error.
30
+
!!! error TS2769: Overload 2 of 4, '(entries?: readonly (readonly [string, boolean])[]): Map<string, boolean>', gave the following error.
31
31
!!! error TS2769: Type 'number' is not assignable to type 'boolean'.
!!! error TS2769: Overload 1 of 3, '(iterable: Iterable<readonly [string, number]>): Map<string, number>', gave the following error.
21
+
!!! error TS2769: Overload 1 of 4, '(iterable?: Iterable<readonly [string, number]>): Map<string, number>', gave the following error.
22
22
!!! error TS2769: Argument of type '([string, number] | [string, boolean])[]' is not assignable to parameter of type 'Iterable<readonly [string, number]>'.
23
23
!!! error TS2769: The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types.
24
24
!!! error TS2769: Type 'IteratorResult<[string, number] | [string, boolean], any>' is not assignable to type 'IteratorResult<readonly [string, number], any>'.
0 commit comments