@@ -23,17 +23,19 @@ const DEFINE_MODEL = 'defineModel'
2323 * Pre-transpile script setup block to remove type syntax and replace it with runtime declarations.
2424 * This function only performs minimal error checking, it means that it will preserve all errors that can be triggered at runtime
2525 */
26- export async function preTranspileScriptSetup ( sfc : SFCDescriptor & { scriptSetup : SFCScriptBlock } , id : string ) : Promise < SFCScriptBlock > {
27- const context = await prepareContext ( sfc , id )
26+ export async function preTranspileScriptSetup ( sfc : SFCDescriptor , id : string ) : Promise < SFCScriptBlock > {
27+ if ( ! sfc . scriptSetup ) {
28+ throw new Error ( 'No script setup block found' )
29+ }
30+ const context = await prepareContext ( sfc as SFCDescriptor & { scriptSetup : SFCScriptBlock } , id )
2831 const resultBuilder = new context . utils . MagicString ( sfc . scriptSetup . content )
2932
3033 for ( const node of context . ctx . ast ) {
3134 if ( node . type === 'ExpressionStatement' ) {
32- const processedTypeSyntax
33- = processDefineProps ( node . expression , context )
34- || processDefineEmits ( node . expression , context )
35- || processWithDefaults ( node . expression , context )
36- || processDefineModel ( node . expression , context )
35+ const processedTypeSyntax = processDefineProps ( node . expression , context )
36+ || processDefineEmits ( node . expression , context )
37+ || processWithDefaults ( node . expression , context )
38+ || processDefineModel ( node . expression , context )
3739
3840 if ( processedTypeSyntax !== undefined ) {
3941 resultBuilder . overwrite ( node . start ! , node . end ! , processedTypeSyntax )
0 commit comments