(TypeScript) Property 'msg' has no initializer and is not definitely assigned in the constructor.
See original GitHub issueVersion
3.0.0-alpha.12
Steps to reproduce
vue create hello-world
使用 TypeScript 和使用 class-style 风格组件cd hello-world
yarn serve
oryarn build
What is expected?
Success
What is actually happening?
提示:
Property 'msg' has no initializer and is not definitely assigned in the constructor.
没有修改任何文件,创建默认项目后运行报错。
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Property '...' has no initializer and is not definitely assigned ...
The simple way to fix this error in Angular applications is to disable --strictPropertyInitialization flag in typescript compiler options in ...
Read more >Property '...' has no initializer and is not ... - Angular Wiki
The simple way to fix this error in Angular applications is to disable --strictPropertyInitialization flag in typescript compiler options in ...
Read more >Property has no initializer and is not definitely assigned
If you have ever seen an error that looks like Property 'X' has no initializer and is not definitely assigned in the constructor....
Read more >has no initializer and is not definitely assigned in the cons
The best solution to fix error “Property has no initializer and is not definitely assigned in the constructor” is either provide initial value...
Read more >has no initializer and is not definitely assigned in the ...
strictPropertyInitialization to false in tsconfig.json In tsconfig.json; StrictPropertyInitialzer is a typescript rule released in the typescript 2.7 version..
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
The issue is most likely related to the
strictPropertyInitialization
flag introduced in TypeScript 2.7, which is also set to TRUE by default (see official docs).If you’re using TS 2.7, try to turn it off by adding a
"strictPropertyInitialization": false
setting to thecompilerOptions
object within thetsconfig.json
root file: if that doesn’t fix it, try to temporarily downgrade to TS 2.6 and see if the error persists.For a detailed explanation of the issue and some possible workarounds/fixes, read this post.
remove “strict”: true,