Typescript: Calling a “method” of another class

后端 未结 5 2058
故里飘歌
故里飘歌 2021-02-13 11:51

I\'m pretty new to java-/type-script and I\'ve some troubles grasping their concepts. I would like to call a method of another class. However, I\'ve been unsuccessful s

5条回答
  •  执笔经年
    2021-02-13 12:20

    calcSomeThing is a non-static method/function. Create an instance of Foo to be able to call it:

    let foo:Foo = new Foo();
    let result:number = foo.calcSomeThing( parameter );
    

    Never use var in Typescript - let is your friend.

提交回复
热议问题