When using shorthand function initializer on `computed`, `this.foo` shows error
See original GitHub issueInfo
- 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.
- imports can’t be found using the ‘@’ shortcut:
Variables defined in a data() section are not recognized:
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:
- Created 4 years ago
- Reactions:4
- Comments:21 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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: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.