@@ -336,8 +336,11 @@ ${commandLine.vueOptions.target < 3 ? vue2TypeHelpersCode : typeHelpersCode}
336
336
? ( vueFile instanceof vue . VueVirtualCode ? readVueComponentDefaultProps ( vueFile , printer , ts ) : { } )
337
337
: { } ;
338
338
const tsDefaults = ! vueFile ? readTsComponentDefaultProps (
339
- componentPath . slice ( componentPath . lastIndexOf ( '.' ) + 1 ) , // ts | js | tsx | jsx
340
- snapshot . getText ( 0 , snapshot . getLength ( ) ) ,
339
+ ts . createSourceFile (
340
+ '/tmp.' + componentPath . slice ( componentPath . lastIndexOf ( '.' ) + 1 ) , // ts | js | tsx | jsx
341
+ snapshot . getText ( 0 , snapshot . getLength ( ) ) ,
342
+ ts . ScriptTarget . Latest
343
+ ) ,
341
344
exportName ,
342
345
printer ,
343
346
ts
@@ -785,7 +788,7 @@ function readVueComponentDefaultProps(
785
788
const sfc = root . _sfc ;
786
789
787
790
if ( sfc . script ) {
788
- const scriptResult = readTsComponentDefaultProps ( sfc . script . lang , sfc . script . content , 'default' , printer , ts ) ;
791
+ const scriptResult = readTsComponentDefaultProps ( sfc . script . ast , 'default' , printer , ts ) ;
789
792
for ( const [ key , value ] of Object . entries ( scriptResult ) ) {
790
793
result [ key ] = value ;
791
794
}
@@ -794,14 +797,11 @@ function readVueComponentDefaultProps(
794
797
}
795
798
796
799
function readTsComponentDefaultProps (
797
- lang : string ,
798
- tsFileText : string ,
800
+ ast : ts . SourceFile ,
799
801
exportName : string ,
800
802
printer : ts . Printer | undefined ,
801
803
ts : typeof import ( 'typescript' )
802
804
) {
803
-
804
- const ast = ts . createSourceFile ( '/tmp.' + lang , tsFileText , ts . ScriptTarget . Latest ) ;
805
805
const props = getPropsNode ( ) ;
806
806
807
807
if ( props ) {
0 commit comments