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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use <script setup lang="ts"> in markdown file #693

Closed
3 tasks done
olivervorasai opened this issue Jun 2, 2022 · 2 comments · Fixed by #701
Closed
3 tasks done

Cannot use <script setup lang="ts"> in markdown file #693

olivervorasai opened this issue Jun 2, 2022 · 2 comments · Fixed by #701
Labels
bug Something isn't working

Comments

@olivervorasai
Copy link

Describe the bug

Using script setup with lang="ts" causes [plugin:vite:vue] [@vue/compiler-sfc] <script> and <script setup> must have the same language type. error. The error does not occur if lang="ts" is removed.

#575 is the same issue except a reproduction is included in this issue.

Reproduction

Minimal reproduction available here: https://github.com/olivervorasai/vitepress-starter-ts-bug

  1. npm install
  2. npm run docs:dev

This reproduction was creating using the following documentation:

Expected behavior

Vitepress should render with or without lang="ts".

System Info

System:
    OS: Windows 10 10.0.19043
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 9.27 GB / 15.85 GB
  Binaries:
    Node: 16.13.1 - C:\Program Files\nodejs\node.EXE
    npm: 8.3.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (101.0.1210.53)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    vitepress: ^1.0.0-alpha.1 => 1.0.0-alpha.1

Additional context

No response

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@olivervorasai olivervorasai added the bug: pending triage Maybe a bug, waiting for confirmation label Jun 2, 2022
@kecrily
Copy link
Contributor

kecrily commented Jun 2, 2022

See #667 (comment)

@brc-dd brc-dd added bug Something isn't working and removed bug: pending triage Maybe a bug, waiting for confirmation labels Jun 2, 2022
@brc-dd
Copy link
Member

brc-dd commented Jun 2, 2022

As stated by the error: <script> and <script setup> must have the same language type. We inject a <script> block by default to each md file. But since not everyone uses TS, it doesn't has lang set to ts.

As a workaround, add empty <script> block with lang="ts" to your md file:

<script lang="ts"></script>

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants