Declaring multiple TypeScript variables with the same type

后端 未结 11 1329
半阙折子戏
半阙折子戏 2020-12-10 00:09

I\'m coding a large TypeScript class and I\'ve set noImplicitAny to true. Is there any way to declare multiple variables of the same type on the same line?

I\'d lik

11条回答
  •  半阙折子戏
    2020-12-10 00:50

    Just adding that even if you do the following:

    let notes, signatureTypeName: string;
    

    it still does not work. In this case, notes is declared as type any and signatureTypeName as type string. You can verify all this by simply hovering over the variable, for example in Visual Studio Code. The declared type appears then in a popup.

提交回复
热议问题