My project was set up using npm create svelte@latest
, with ts
enabled and tailwind
added.
However, when declaring
<script lang="ts">
, I encountered an Unexpected Token
error, like the one below:
D:/gits/rpg-board/src/lib/components/FilterBar.svelte:3:12 Unexpected token
1 | <script lang="ts">"use strict";
2 | class Greeter {
3 | greeting;
^
4 | constructor(message) {
5 | this.greeting = message;
\r\n\r\n
WatWat
\r\n"}, node_ids: [0, 1], params: {}, routeId: "deck", data: (function(a){return [a,a]}(null)), errors: null }, paths: {"base":"","assets":""}, target: document.querySelector('[data-sveltekit-hydrate="1regxrp"]').parentNode, trailing_slash: "never" });
The repository can be found here: https://github.com/FurtherUnspecified/rpg-board/commit/8ce8eed599bf042f1d8ccd6db2d57456e6d7f15c
I am unsure of what I may have missed in the setup configuration.
Below is the full log of the Svelte project initialization process:
PS D:\gits> npm init vite
√ Project name: ... rpg-board
√ Select a framework: » Svelte
√ Select a variant: » SvelteKit
Need to install the following packages:
<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="95f6e7f0f4e1f0b8e6e3f0f9e1f0d5a7bba5bba5b8fbf0ede1bba4a2a7">[email protected]</a>
Ok to proceed? (y) y
create-svelte version 2.0.0-next.172
Welcome to SvelteKit!
This is beta software; expect bugs and missing features.
Problems? Open an issue on https://github.com/sveltejs/kit/issues if none exists already.
√ Directory not empty. Continue? ... yes
√ Which Svelte app template? » Skeleton project
√ Add Prettier for code formatting? ... No / Yes
√ Add Playwright for browser testing? ... No / Yes
Your project is ready!
✔ Typescript
Inside Svelte components, use <script lang="ts">
✔ ESLint
✔ Prettier
https://prettier.io/docs/en/options.html
https://github.com/sveltejs/prettier-plugin-svelte#options
✔ Playwright
https://playwright.dev
Install community-maintained integrations:
https://github.com/svelte-add/svelte-adders
Next steps:
1: cd rpg-board
2: npm install (or pnpm install, etc)
3: git init && git add -A && git commit -m "Initial commit" (optional)
4: npm run dev -- --open
To close the dev server, hit Ctrl-C
Stuck? Visit us at https://svelte.dev/chat
Despite this setup, I am still unable to use TypeScript.