@@ -31,6 +31,8 @@ describe("Types", () => {
31
31
it ( "two types" , ( ) => {
32
32
type Structure = { a : number , b : string } ;
33
33
const map : TypedMap < Structure > = new Map ( ) ;
34
+
35
+ map . set ( "a" , 1 ) ;
34
36
let valA : number | undefined = undefined ;
35
37
valA = map . get ( "a" )
36
38
expect ( valA ) . to . equal ( 1 )
@@ -51,14 +53,18 @@ describe("Types", () => {
51
53
52
54
describe ( "Nested object to map" , ( ) => {
53
55
it ( "simple structure" , ( ) => {
54
- type Structure = { a : number , b : string } ;
55
- const map = new Map < "a" | "b" , number | string > ( [ [ "a" , 1 ] , [ "b" , "text" ] ] ) as NestedObjectToMap < Structure >
56
- expect ( map . keys ( ) ) . to . deep . equal ( [ "a" , "b" ] )
57
- } )
56
+ type Structure = { a : number , b : string } ;
57
+ const map = new Map < "a" | "b" , number | string > ( [ [ "a" , 1 ] , [ "b" , "text" ] ] ) as NestedObjectToMap < Structure >
58
+
59
+ const a = map . get ( "a" )
60
+ expect ( a ) . to . equal ( 1 )
61
+ } )
58
62
it ( "nested structure" , ( ) => {
59
63
type Structure = { a : number , b : { c : string , d : boolean } } ;
64
+
60
65
const map = new Map < "a" | "b" , number | Map < "c" | "d" , string | boolean > > ( [ [ "a" , 1 ] , [ "b" , new Map < "c" | "d" , string | boolean > ( [ [ "c" , "text" ] , [ "d" , true ] ] ) ] ] ) as NestedObjectToMap < Structure >
61
- expect ( map . keys ( ) ) . to . deep . equal ( [ "a" , "b" ] )
66
+ const c = map . get ( "b" ) ?. get ( "c" )
67
+ expect ( c ) . to . equal ( "text" )
62
68
} )
63
69
it ( "error on wrong key" , ( ) => {
64
70
type Structure = { a : number , b : string } ;
0 commit comments