Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Can't use Typescript in <script> inside .svelte #1255

@jlkiri

Description

@jlkiri

Describe the bug

Build (and VSCode check) fails when TS is used in <script>. You can see the unexpected token error on the screenshot. Build fails with the same unexpected token error. Not quite sure why. I followed all the recommendations from svelte-preprocess docs.

image

Logs
Please include browser console and server logs around the time this bug occurred.

To Reproduce

  1. Create a fresh sapper project with degit
  2. Follow the instructions from here
  3. Add lang="typescript" to any <script>.
  4. Inside that script, add let a: number = 1

tsconfig.json:

{
  "include": ["src/**/*"],
  "exclude": ["node_modules/*"],
  "compilerOptions": {
    "target": "es2017",
    "types": ["svelte", "node"],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "noEmit": true,
    "lib": ["dom.iterable", "es5", "es6", "esnext", "dom"],
    "downlevelIteration": true
  }
}

Expected behavior
Build doesn't fail. VSCode shows no errors.

Information about your Sapper Installation:

  • WSL2 Ubuntu 18.04 (Windows 10)
"sapper": "^0.27.0",
"svelte": "^3.0.0",
  • Rollup

Severity
Moderate

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions