@@ -31,6 +31,8 @@ describe("Types", () => {
3131 it ( "two types" , ( ) => {
3232 type Structure = { a : number , b : string } ;
3333 const map : TypedMap < Structure > = new Map ( ) ;
34+
35+ map . set ( "a" , 1 ) ;
3436 let valA : number | undefined = undefined ;
3537 valA = map . get ( "a" )
3638 expect ( valA ) . to . equal ( 1 )
@@ -51,14 +53,18 @@ describe("Types", () => {
5153
5254 describe ( "Nested object to map" , ( ) => {
5355 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+ } )
5862 it ( "nested structure" , ( ) => {
5963 type Structure = { a : number , b : { c : string , d : boolean } } ;
64+
6065 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" )
6268 } )
6369 it ( "error on wrong key" , ( ) => {
6470 type Structure = { a : number , b : string } ;
0 commit comments