Error: Cannot invoke an expression whose type lacks a call signature

后端 未结 8 2097
执笔经年
执笔经年 2020-12-02 17:50

I am brand new to typescript, and I have two classes. In the parent class I have:

abstract class Component {
  public deps: any = {};
  public props: any = {         


        
8条回答
  •  鱼传尺愫
    2020-12-02 18:23

    This error can be caused when you are requesting a value from something and you put parenthesis at the end, as if it is a function call, yet the value is correctly retrieved without ending parenthesis. For example, if what you are accessing is a Property 'get' in Typescript.

    private IMadeAMistakeHere(): void {
        let mynumber = this.SuperCoolNumber();
    }
    
    private IDidItCorrectly(): void {
        let mynumber = this.SuperCoolNumber;
    }
    
    private get SuperCoolNumber(): number {
        let response = 42;
        return response;
    };
    

提交回复
热议问题