Typescript: how to fix error: Property does not exist on type?


Sample error:

ERROR in src/App.vue:149:14
TS2339: Property 'getAnswer' does not exist on type '{ question(newQuestion: string, oldQuestion: string): void; }'.

Original code:

this.getAnswer()

Method 1:

this["getAnswer"]()

Method 2:

(this as any).getAnswer()

Method 3: not use in jsx

(<any>this).getAnswer()

Recent search terms:

  • property tostring does not exist on type never

Leave a Reply