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.

(TypeScript) Property 'msg' has no initializer and is not definitely assigned in the constructor.

See original GitHub issue

Version

3.0.0-alpha.12

Steps to reproduce

  1. vue create hello-world 使用 TypeScript 和使用 class-style 风格组件
  2. cd hello-world
  3. yarn serve or yarn 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:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

28reactions
Darksealcommented, Feb 18, 2018

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 the compilerOptions object within the tsconfig.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.

2reactions
adminparrycommented, Apr 29, 2019

remove “strict”: true,

Read more comments on GitHub >

github_iconTop 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 >

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