Skip to content

TypeScript Error: No element indexed by 0 #424

@GrygrFlzr

Description

@GrygrFlzr

This is caused by Vite's source map handling on .svelte files that are not dynamic files.
As a temporary workaround, make sure to have src/routes/$layout.svelte with at least some "dynamic" content, e.g.

<slot />
{''}

Describe the bug
As long as svelte-preprocess is used in svelte.config.cjs, attempting to run dev mode results in internal errors.

Logs
With TypeScript, the page is a plaintext error:

Error: No element indexed by 0
    at ArraySet_at [as at] (C:\Users\GrygrFlzr\Documents\projects\sk-36\node_modules\vite\dist\node\chunks\dep-1bdbec90.js:24278:9)
    at BasicSourceMapConsumer.<anonymous> (C:\Users\GrygrFlzr\Documents\projects\sk-36\node_modules\vite\dist\node\chunks\dep-1bdbec90.js:25193:67)
    at Array.map (<anonymous>)
    at BasicSourceMapConsumer.SourceMapConsumer_eachMapping [as eachMapping] (C:\Users\GrygrFlzr\Documents\projects\sk-36\node_modules\vite\dist\node\chunks\dep-1bdbec90.js:25192:14)
    at merge (C:\Users\GrygrFlzr\Documents\projects\sk-36\node_modules\vite\dist\node\chunks\dep-1bdbec90.js:26656:18)
    at ssrTransform (C:\Users\GrygrFlzr\Documents\projects\sk-36\node_modules\vite\dist\node\chunks\dep-1bdbec90.js:61375:15)
    at transformRequest (C:\Users\GrygrFlzr\Documents\projects\sk-36\node_modules\vite\dist\node\chunks\dep-1bdbec90.js:61643:48)
    at async instantiateModule (C:\Users\GrygrFlzr\Documents\projects\sk-36\node_modules\vite\dist\node\chunks\dep-1bdbec90.js:67986:10)

To Reproduce

npm init svelte@next
# enable typescript
npm install
npm run dev

Expected behavior
No errors out of the box.

Information about your SvelteKit Installation:

  npmPackages:
    @sveltejs/kit: next => 1.0.0-next.36
    svelte: ^3.29.0 => 3.35.0

Severity
Unusable dev mode.

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