-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Description
Describe the bug
Svelte fails to parse a non-null assertion within a function has a return type annotation
Reproduction
<script lang="ts">
function foo(): string {
return ""!
}
</script>// works
function foo(): string {
return ""
}
// works
function foo() {
return ""!
}
// fails
function foo(): string {
return ""!
}Logs
error during build:
[vite-plugin-svelte] [plugin vite-plugin-svelte] Cannot read properties of undefined (reading 'startsWith')
file: /Users/albert/svelte-bug-3/src/routes/+page.svelte
TypeError: [plugin vite-plugin-svelte] Cannot read properties of undefined (reading 'startsWith')
at couldBeFixedByCssPreprocessor (file:///Users/albert/svelte-bug-3/node_modules/@sveltejs/vite-plugin-svelte/src/utils/error.js:111:72)
at enhanceCompileError (file:///Users/albert/svelte-bug-3/node_modules/@sveltejs/vite-plugin-svelte/src/utils/error.js:126:6)
at compileSvelte (file:///Users/albert/svelte-bug-3/node_modules/@sveltejs/vite-plugin-svelte/src/utils/compile.js:148:4)
at async Object.transform (file:///Users/albert/svelte-bug-3/node_modules/@sveltejs/vite-plugin-svelte/src/index.js:164:20)
at async transform (file:///Users/albert/svelte-bug-3/node_modules/rollup/dist/es/shared/node-entry.js:19663:16)
at async ModuleLoader.addModuleSource (file:///Users/albert/svelte-bug-3/node_modules/rollup/dist/es/shared/node-entry.js:19879:36)
error: script "build" exited with code 1
System Info
System:
OS: macOS 15.1
CPU: (8) arm64 Apple M1 Pro
Memory: 84.80 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
npm: 10.8.2 - ~/.nvm/versions/node/v20.17.0/bin/npm
pnpm: 9.7.0 - ~/Library/pnpm/pnpm
bun: 1.1.39 - ~/.bun/bin/bun
Browsers:
Chrome: 131.0.6778.140
Safari: 18.1
npmPackages:
svelte: ^5.14.3 => 5.14.3Severity
blocking all usage of svelte
Metadata
Metadata
Assignees
Labels
No labels