File tree Expand file tree Collapse file tree 4 files changed +42
-7
lines changed
typescript/src/transpiler Expand file tree Collapse file tree 4 files changed +42
-7
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @knuckles/fabricator " : patch
3
+ ---
4
+
5
+ Add "if" method to chunk.
Original file line number Diff line number Diff line change
1
+ ---
2
+ " @knuckles/typescript " : patch
3
+ ---
4
+
5
+ Fix mapping with "with" hint.
Original file line number Diff line number Diff line change @@ -79,6 +79,18 @@ export class Chunk {
79
79
return this ;
80
80
}
81
81
82
+ if (
83
+ condition : unknown ,
84
+ positive : ( chunk : this) => void ,
85
+ negative ?: ( chunk : this) => void ,
86
+ ) {
87
+ if ( condition ) {
88
+ positive ( this ) ;
89
+ } else {
90
+ negative ?.( this ) ;
91
+ }
92
+ }
93
+
82
94
marker ( id : string ) : this {
83
95
this . #markers. add ( new DynamicMarker ( id , this . #text. length ) ) ;
84
96
return this ;
Original file line number Diff line number Diff line change @@ -281,13 +281,26 @@ class Renderer {
281
281
282
282
#renderWithVirtualElement( node : ko . WithVirtualElement ) : Chunk {
283
283
const childContext = new Chunk ( )
284
- . append ( `${ ns } .hints.with(${ ns } .type<typeof import(` )
285
- . append ( quote ( node . import . module . value ) )
286
- . append ( ")" )
287
- . append (
288
- node . import . identifier . value === "*"
289
- ? ""
290
- : "[" + quote ( node . import . identifier . value ) + "]" ,
284
+ . append ( `${ ns } .hints.with(${ ns } .type<` )
285
+ . while (
286
+ ( chunk ) =>
287
+ chunk
288
+ . append ( "typeof import(" )
289
+ . append ( node . import . module . text , { mirror : node . import . module } )
290
+ . append ( ")" )
291
+ . if ( node . import . identifier . value !== "*" , ( chunk ) =>
292
+ chunk . while (
293
+ ( chunk ) =>
294
+ chunk
295
+ . append ( '["' )
296
+ . append ( quote ( node . import . identifier . value ) . slice ( 1 , - 1 ) , {
297
+ mirror : node . import . identifier ,
298
+ } )
299
+ . append ( '"]' ) ,
300
+ { blame : node . import . identifier } ,
301
+ ) ,
302
+ ) ,
303
+ { blame : node . import } ,
291
304
)
292
305
. append ( ">(), $context)" ) ;
293
306
You can’t perform that action at this time.
0 commit comments