File tree Expand file tree Collapse file tree 3 files changed +17
-8
lines changed
Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -3,14 +3,19 @@ class Map<TKey, TValue> {
33
44 private items : { [ key : string ] : TValue } ; // Type of key is actually TKey
55
6- constructor ( other : any ) {
6+ constructor ( other : Map < TKey , TValue > | Array < [ TKey , TValue ] > ) {
77 this . items = { } ;
88 this . size = 0 ;
99
10- if ( other ) {
10+ if ( other instanceof Map ) {
1111 this . size = other . size ;
1212 for ( const [ key , value ] of other . entries ( ) ) {
13- this . items [ key ] = value ;
13+ this . items [ key as any ] = value ;
14+ }
15+ } else if ( other !== undefined ) {
16+ this . size = other . length ;
17+ for ( const [ key , value ] of other ) {
18+ this . items [ key as any ] = value ;
1419 }
1520 }
1621 }
Original file line number Diff line number Diff line change @@ -3,14 +3,19 @@ class Set<TValue> {
33
44 private items : { [ key : string ] : boolean } ; // Key type is actually TValue
55
6- constructor ( other : any ) {
6+ constructor ( other : Set < TValue > | TValue [ ] ) {
77 this . items = { } ;
88 this . size = 0 ;
99
10- if ( other ) {
10+ if ( other instanceof Set ) {
1111 this . size = other . size ;
1212 for ( const value of other . values ( ) ) {
13- this . items [ value ] = true ;
13+ this . items [ value as any ] = true as any ;
14+ }
15+ } else if ( other !== undefined ) {
16+ this . size = other . length ;
17+ for ( const value of other ) {
18+ this . items [ value as any ] = true as any ;
1419 }
1520 }
1621 }
Original file line number Diff line number Diff line change 1- import { Expect , Test , TestCase , FocusTests } from "alsatian" ;
1+ import { Expect , Test , TestCase } from "alsatian" ;
22import * as util from "../../src/util" ;
33
4- @FocusTests
54export class SetTests {
65 @Test ( "set constructor" )
76 public setConstructor ( ) {
You can’t perform that action at this time.
0 commit comments