question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'length' of undefined error in VS Code with wc, and named slot with a binding directive

See original GitHub issue

Is this about svelte@next? This project is currently in a pre-release stage and breaking changes may occur at any time. Please do not post any kind of bug reports or questions on GitHub about it.

No

Describe the bug A clear and concise description of what the bug is.

When compiling to custom elements, if you have a named slot with a binding directive, VS Code will emit a false error of Cannot read property 'length' of undefined in the VS Code console, even if you have a svelte config file with customElement: true in it.

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

n/a

To Reproduce To help us help you, if you’ve found a bug please consider the following:

Svelte Component:

<div bind:this={rootEl} class="root">
  <h1 class="x">Hi there BEFORE SLOT</h1>
  <slot name="s" bind:this={s} />
  <h1>Hi there AFTER SLOT</h1>
</div>

svelte.config.js

module.exports = {
  compilerOptions: {
    customElement: true
  }
};

Removing the bind:this={s} causes the error to disappear.

With the necessary webpack config, this code all works properly, but the false error in the console is concerning.

Occasionally, this won’t be possible, and that’s fine – we still appreciate you raising the issue. But please understand that Svelte is run by unpaid volunteers in their free time, and issues that follow these instructions will get fixed faster.

Expected behavior A clear and concise description of what you expected to happen.

No error.

Stacktraces If you have a stack trace to include, we recommend putting inside a <details> block for the sake of the thread’s readability:

Stack trace

Stack trace goes here…

Information about your Svelte project: To make your life easier, just run npx envinfo --system --npmPackages svelte,rollup,webpack --binaries --browsers and paste the output here.

  • Your browser and the version: (e.x. Chrome 52.1, Firefox 48.0, IE 10)

N/A

VS Code: latest

  • Your operating system: (e.x. OS X 10, Ubuntu Linux 19.10, Windows XP, etc)

Mac

  • Svelte version (Please check you can reproduce the issue with the latest release!)

3.32.1

  • Whether your project uses Webpack or Rollup

webpack

Severity How severe an issue is this bug to you? Is this annoying, blocking some users, blocking an upgrade or blocking your usage of Svelte entirely?

Moderate

Note: the more honest and specific you are here the more we will take you seriously.

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
arackafcommented, Feb 5, 2021

@dummdidumm jesus that was fast - https://github.com/sveltejs/language-tools/pull/804

I know it’s not done yet but thanks a ton! Svelte team is amazing.

1reaction
arackafcommented, Feb 5, 2021

@dummdidumm gotcha - thanks again for the info!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Select2.js error: Cannot read property 'length' of undefined
I am using Select2 jquery plugin and I can't get results with json. When looking json response in browser ...
Read more >
Code - GitHub
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may...
Read more >
Untitled
bindToController&&!e.controller)throw ro("noctrl","Cannot bind to controller without ... parent directive that requires a transclusion with slot name "{0}".
Read more >
Fix List for DB2 Version 10.1 for Linux, UNIX and Windows - IBM
APAR Sev. Abstract IT14877 2 REDIRECT RESTORE FAILS WITH "DBPATH ON" OPTION IT09299 2 ROLLFORWARD CAN FAIL WITH SQL1271W ERROR IT10347 2 DB2 MIGHT ABORT WITH...
Read more >
2 fs.syncfs operations in flight at once, probably just doing ...
dotnet.js:2347 Error #1 "TypeError: Cannot read properties of undefined (reading ... keyCodes instead of Vue.directive('on').keyCodes ); v-bind
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found