Skip to content

error TS2339: Property 'propMessage' does not exist on type 'App'. #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
onecentlin opened this issue Dec 14, 2016 · 5 comments
Closed

Comments

@onecentlin
Copy link

Execute README example code, and get this error message.

It seems cannot understand variables defined in Component props section.

error TS2339: Property 'propMessage' does not exist on type 'App'.

Develop Environment:

  • Typescript: 2.1.4
  • Vue: 2.1.6
  • vue-class-component 4.3.1
@HerringtonDarkholme
Copy link
Member

Hi, the example in README is for Babel.
If you need use property please declare it in class body, it's TypeScript's feature.

@ktsn should we change the documentation, for example adding one comment line of declaration in class body, to indicate this? (Though IMHO TS users should already know that.)

@ktsn
Copy link
Member

ktsn commented Dec 14, 2016

Adding Example (Babel) over the code block?

@HerringtonDarkholme
Copy link
Member

class App extends Vue {
  // initial data
  msg = 123
  // you need manually add props in TypeScript, like below
  // propMessage: string
  // use prop values for initial data
  helloMsg = 'Hello, ' + this.propMessage
}

@ktsn
Copy link
Member

ktsn commented Dec 14, 2016

Hmm, I'm unwilling to add the comment because it is the description of TypeScript rather than vue-class-component.
How about referring to example/example.ts from readme? It does not equal to the babel example since it uses render function but I'll rewrite it with template option.

@HerringtonDarkholme
Copy link
Member

Sounds good to me! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants