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

Breaking Change Regression: Svelte fails to parse non-null assert in functions #14748

Closed
AlbertMarashi opened this issue Dec 18, 2024 · 3 comments

Comments

@AlbertMarashi
Copy link

AlbertMarashi commented Dec 18, 2024

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.3

Severity

blocking all usage of svelte

@AlbertMarashi
Copy link
Author

AlbertMarashi commented Dec 18, 2024

@xeho91
Copy link
Contributor

xeho91 commented Dec 18, 2024

Another hotfix that may potentially solve this issue hasn't been released yet. You can track progress here: #14745

If you're inpatient, there's a workaround: #14741 (comment)

@dummdidumm
Copy link
Member

Should be fixed now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants