Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript syntax does not work in Vue templates #9566

Open
Demivan opened this issue Mar 6, 2024 · 0 comments 路 May be fixed by #9567
Open

TypeScript syntax does not work in Vue templates #9566

Demivan opened this issue Mar 6, 2024 · 0 comments 路 May be fixed by #9567
Labels

Comments

@Demivan
Copy link

Demivan commented Mar 6, 2024

馃悰 bug report

Compilation fails when using TypeScript syntax in Vue <template>:

<script setup lang="ts">
let x: string | number = 1
</script>

<template>
  {{ (x as number).toFixed(2) }}
</template>

馃帥 Configuration (.babelrc, package.json, cli command)

Default config

{
  "scripts": {
    "build": "parcel build index.html"
  },
  "devDependencies": {
    "@parcel/transformer-vue": "2.12.0",
    "parcel": "^2.12.0"
  },
  "dependencies": {
    "vue": "^3.4.21"
  }
}

馃 Expected Behavior

No error.

馃槸 Current Behavior

@parcel/transformer-js: Expected ',', got 'as'

  /parcel-vue/src/App.vue:6:8
    5 | <template>
  > 6 |   {{ (x as number).toFixed(2) }}
  >   |        ^
    7 | </template>
    8 | 

馃拋 Possible Solution

When lang="ts" is specified for the <script>, <template> should be processed using TypeScript too.

馃敠 Context

馃捇 Code Sample

https://github.com/Demivan/parcel-vue/tree/typescript-template

馃實 Your Environment

Software Version(s)
Parcel 2.12.0
Node 21.6.2
pnpm 8.12.1
Operating System Linux (NixOS)
@Demivan Demivan linked a pull request Mar 6, 2024 that will close this issue
3 tasks
@mischnic mischnic added the Vue label Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants