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.

When using shorthand function initializer on `computed`, `this.foo` shows error

See original GitHub issue
  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ

Info

  • Platform: MacOS
  • Vetur version: 0.18.0
  • VS Code version: Version 1.33.0-insider (1.33.0-insider)

Problem

In a Vue application that is using just plain Javascript (<script>), setting

  "compilerOptions": {
    "checkJs": true
  }

in jsconfig.json to enable the new features mentioned in 0.18.0 ( “compilerOptions”: { “checkJs”: true }) causes many things that were errors to show up as errors.

  1. imports can’t be found using the ‘@’ shortcut: image image

Variables defined in a data() section are not recognized: image

image

Reproducible Case

Create a new vue (cli) app, add some variables in a data statement, see the errors. Try adding an import with a @.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
mrozekmacommented, Sep 12, 2019

@denis-pujdak-adm-it Patcher56 is correct, you need to use Vue.extend(...) or Typescript can’t infer anything about the component options. You’re missing the parentheses in your screenshot; it’s a function call:

export default Vue.extend({
    data() {
        // etc.
    }
});
1reaction
octrefcommented, Apr 3, 2019

Sorry that’s overlapped behind the hover. Try thisIsSelected: function() {.

As for mapState. I didn’t find your usage in the docs: https://vuex.vuejs.org/guide/state.html.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Shorthand for field initializer when class has computed property
This gives me an error: Type '{ firstName: string; lastName: string; }' is not assignable to type 'Person'. Property 'fuillName' is missing in ......
Read more >
Object initializer - JavaScript - MDN Web Docs - Mozilla
The property name must be double-quoted, and the definition cannot be a shorthand. Computed property names are not allowed either.
Read more >
Initialization — The Swift Programming Language (Swift 5.7)
The memberwise initializer is a shorthand way to initialize the member properties of new structure instances. Initial values for the properties of the...
Read more >
Object initializer - JavaScript | MDN - LIA
Objects can be initialized using new Object() , Object.create() , or using the literal notation (initializer notation).
Read more >
C++11 Language Extensions — General Features, C++ FAQ
The use of auto to deduce the type of a variable from its initializer is obviously ... vector<string> v = { "foo", "...
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