File tree Expand file tree Collapse file tree 4 files changed +36
-17
lines changed Expand file tree Collapse file tree 4 files changed +36
-17
lines changed Original file line number Diff line number Diff line change 11{
22 "rules" : {
3- "@definitelytyped/no-type-only-packages" : " off" ,
4- "@typescript-eslint/no-unsafe-function-type" : " off" ,
5- "@typescript-eslint/no-wrapper-object-types" : " off" ,
6- "@typescript-eslint/no-empty-interface" : " off"
3+ "@definitelytyped/no-type-only-packages" : " off"
74 }
85}
Original file line number Diff line number Diff line change 1- declare var Elm : ElmInstance < ShanghaiPorts > ;
1+ declare var Elm : ElmInstance < { } , { } > ;
2+
3+ Elm . Main . init ( ) ;
4+
5+ declare var Shanghai : ElmInstance <
6+ ShanghaiPorts ,
7+ ShanghaiFlags , // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type
8+ [ "Shanghai" ]
9+ > ;
10+
11+ interface ShanghaiFlags {
12+ coordinates : [ number , number ] ;
13+ incomingShip : Ship ;
14+ outgoingShip : string ;
15+ }
216
317interface ShanghaiPorts {
4- coordinates : PortToElm < number [ ] > ;
18+ coordinates : PortToElm < [ number , number ] > ;
519 incomingShip : PortToElm < Ship > ;
620 outgoingShip : PortToElm < string > ;
721 totalCapacity : PortFromElm < number > ;
@@ -14,15 +28,15 @@ interface Ship {
1428
1529// initialize the Shanghai component which keeps track of
1630// shipping data in and out of the Port of Shanghai.
17- var shanghai = Elm . Main . init ( {
31+ var shanghai = Shanghai . Shanghai . init ( {
1832 flags : {
1933 coordinates : [ 0 , 0 ] ,
2034 incomingShip : { name : "" , capacity : 0 } ,
2135 outgoingShip : "" ,
2236 } ,
2337} ) ;
2438
25- function logger ( x : any ) {
39+ function logger ( x : number ) {
2640 console . log ( x ) ;
2741}
2842shanghai . ports . totalCapacity . subscribe ( logger ) ;
Original file line number Diff line number Diff line change 1- interface ElmInstance < P = { } > {
2- Main : ElmMain < P > ;
3- }
1+ type ElmInstance <
2+ P ,
3+ F ,
4+ Entrypoints extends string [ ] =
5+ // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type
6+ [ "Main" ] ,
7+ > = NestedEntrypoints < Entrypoints , P , F > ;
8+
9+ type NestedEntrypoints < Entrypoints extends string [ ] , P , F > = Entrypoints extends [
10+ infer First extends string ,
11+ ...infer Rest extends string [ ] ,
12+ ] ? { [ K in First ] : NestedEntrypoints < Rest , P , F > }
13+ : ElmMain < P , F > ;
414
5- interface ElmMain < P > {
6- init ( options : { node ?: Node | undefined ; flags ?: any } ) : ElmApp < P > ;
15+ interface ElmMain < P , F > {
16+ init ( options ? : { node ?: Node | undefined ; flags : F } | undefined ) : ElmApp < P > ;
717}
818
919interface ElmApp < P > {
Original file line number Diff line number Diff line change 55 " es6" ,
66 " dom"
77 ],
8- "noImplicitAny" : true ,
9- "noImplicitThis" : true ,
10- "strictNullChecks" : true ,
11- "strictFunctionTypes" : true ,
8+ "strict" : true ,
9+ "exactOptionalPropertyTypes" : true ,
1210 "types" : [],
1311 "noEmit" : true ,
1412 "forceConsistentCasingInFileNames" : true
You can’t perform that action at this time.
0 commit comments