use root <template script="ts"> #389
Replies: 2 comments 8 replies
-
Currently you can already use TS in template expressions by specifying |
Beta Was this translation helpful? Give feedback.
-
While vite now allows TS in template expressions, webpack with With this webpack config: {
test: /\.tsx?$/,
exclude: /node_modules/,
use: [{
loader: 'ts-loader',
options: {
appendTsSuffixTo: [/\.vue$/],
},
}],
},
test: /\.vue$/,
use: [{
loader: 'vue-loader',
options: {
exposeFilename: true,
compilerOptions: {
expressionPlugins: ['typescript'],
},
},
}],
}, It seems As a result, the generated code is still includes Typescript annotations: ERROR in ./src/web/client/components/App.vue?vue&type=template&id=1abc23c8 (./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[1]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/web/client/components/App.vue?vue&type=template&id=1abc23c8) 4:36
Module parse failed: Unexpected token (4:36)
File was processed with these loaders:
* ./node_modules/vue-loader/dist/templateLoader.js
* ./node_modules/vue-loader/dist/index.js
You may need an additional loader to handle the result of these loaders.
|
| export function render(_ctx, _cache, $props, $setup, $data, $options) {
> return _toDisplayString((_ctx.val as string).toUpperCase())
| }
@ ./src/web/client/components/App.vue?vue&type=template&id=1abc23c8 1:0-206 1:0-206
@ ./src/web/client/components/App.vue 1:0-64 4:16-22 14:63-16:3 15:29-35 14:2-16:4
@ ./node_modules/ts-loader/index.js??clonedRuleSet-1.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/web/client/components/AppLoader.vue?vue&type=script&lang=ts 2:0-28 5:8-11
@ ./src/web/client/components/AppLoader.vue?vue&type=script&lang=ts 1:0-205 1:0-205 1:206-400 1:206-400
@ ./src/web/client/components/AppLoader.vue 2:0-60 3:0-55 3:0-55 6:0-13 9:2-16 12:36-42 13:27-33 22:0-13 24:15-21
@ ./src/web/app.ts 2:0-58 14:29-38
@ ./src/web/entryClient.ts 5:0-34 16:26-35 I'm not sure if I should report this issue with |
Beta Was this translation helpful? Give feedback.
-
What do you think having a new
script
attribute allowed in the root<template>
tag of SFC components ? (and notlang
which is already used)This would allow using typescript in anonymous functions in our templates:
Taking the idea to the end, it may allow other parser like
dart
(maybe to port vue to native mobile components with flutter?)Beta Was this translation helpful? Give feedback.
All reactions