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.

Accessors are throwing type errors and there's no autocomplete for them

See original GitHub issue

Describe the bug Accessors work, but are throwing type errors and there’s no autocomplete for them.

To Reproduce Install Svelte-ts-template, update all dependencies and test with this simple App while using the latest Svelte for VSCode (v104.6.4):

image image

Expected behavior No type errors. Autocomplete: ability to select accessors from the list.

System (please complete the following information):

  • Windows 10
  • VSCode
  • Svelte for VSCode v104.6.4

Additional context

"devDependencies": {
    "@rollup/plugin-commonjs": "^17.1.0",
    "@rollup/plugin-node-resolve": "^11.2.0",
    "@rollup/plugin-typescript": "^8.2.0",
    "@tsconfig/svelte": "^1.0.10",
    "rollup": "^2.41.4",
    "rollup-plugin-css-only": "^3.1.0",
    "rollup-plugin-livereload": "^2.0.0",
    "rollup-plugin-svelte": "^7.1.0",
    "rollup-plugin-terser": "^7.0.2",
    "svelte": "^3.35.0",
    "svelte-check": "^1.2.5",
    "svelte-preprocess": "^4.6.9",
    "tslib": "^2.1.0",
    "typescript": "^4.2.3"
  },
  "dependencies": {
    "sirv-cli": "^1.0.11"
  }

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
dummdidummcommented, Mar 19, 2021

Yes the eslint error does not matter, we can do all kinds of dirty stuff in there 😄 One thing I noticed is that the generated code for a setter is set foo(foo) without {} afterwards which is invalid syntax. This needs to be added. Also one more test to check if there’s no setter for things like export const foo = '' is created would be good. Other than this looks good, you might as well go ahead and open a PR and we can put the finishing touches to it over there 👍

1reaction
vatrocommented, Mar 19, 2021

@dummdidumm Ok, I’m done! 👉 add-accessors-autocomplete (branch deleted after PR merge)

Remarks:

  • Turns out type SvelteTsxRender is not even needed to infer the type of the setter, since corresponding getters are also always generated for accessors, so they can be used for that. With this solution there’s an adjacent-overload-signatures eslint error in the generated tsx class, but I guess this is not important, right?
  • There are 5 new ‘use-accessors’ tests and I had to change a bunch of existing tests (113) because of the new setters: {} object in the render() output. All 217 svelte2tsx tests are passing.

Feedback much appreciated + I’m awaiting further instructions. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Improve error message "No value accessor for form control ...
When you get the error No value accessor for form control with unspecified name attribute , there are generally two things that possibly...
Read more >
No value accessor for form control with unspecified name ...
I fixed this error by adding the name="fieldName" ngDefaultControl attributes to the element that carries the [(ngModel)] attribute.
Read more >
Angular Development #8 - Control Value Accessor
Learn about the well-known and some lesser known uses of ControlValueAccessor in the latest post of our series on Angular Development.
Read more >
9 UX Best Practice Design Patterns for Autocomplete ...
Sweetwater displays 20 autocomplete suggestions on desktop, including some redundancies (e.g., “drumsticks” and “drum sticks”) that can make it ...
Read more >
TypeScript errors and how to fix them
A list of common TypeScript errors and how to fix them.
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