File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 compileTemplate ,
55 SFCDescriptor ,
66 SFCTemplateCompileOptions ,
7- SFCTemplateCompileResults
7+ SFCTemplateCompileResults ,
8+ CompilerOptions
89} from '@vue/compiler-sfc'
910import { PluginContext , TransformPluginContext } from 'rollup'
1011import { ResolvedOptions } from '.'
@@ -157,6 +158,16 @@ export function resolveTemplateCompilerOptions(
157158 }
158159 }
159160
161+ // if using TS, support TS syntax in template expressions
162+ const expressionPlugins : CompilerOptions [ 'expressionPlugins' ] =
163+ options . template ?. compilerOptions ?. expressionPlugins || [ ]
164+ if (
165+ descriptor . script ?. lang === 'ts' ||
166+ descriptor . scriptSetup ?. lang === 'ts'
167+ ) {
168+ expressionPlugins . push ( 'typescript' )
169+ }
170+
160171 return {
161172 ...options . template ,
162173 id,
@@ -173,7 +184,8 @@ export function resolveTemplateCompilerOptions(
173184 compilerOptions : {
174185 ...options . template ?. compilerOptions ,
175186 scopeId : hasScoped ? `data-v-${ id } ` : undefined ,
176- bindingMetadata : resolvedScript ? resolvedScript . bindings : undefined
187+ bindingMetadata : resolvedScript ? resolvedScript . bindings : undefined ,
188+ expressionPlugins
177189 }
178190 }
179191}
You can’t perform that action at this time.
0 commit comments