How to import js-modules into TypeScript file?

前端 未结 5 1180
自闭症患者
自闭症患者 2020-11-28 10:28

I have a Protractor project which contains such a file:

var FriendCard = function (card) {
    var webElement = card;
    var menuButton;
    var serialNumber         


        
5条回答
  •  伪装坚强ぢ
    2020-11-28 10:45

    I'm currently taking some legacy codebases and introducing minimal TypeScript changes to see if it helps our team. Depending on how strict you want to be with TypeScript, this may or may not be an option for you.

    The most helpful way for us to get started was to extend our tsconfig.json file with this property:

    // tsconfig.json excerpt:
    
    {
      ...
    
      "allowJs": true,
    
      ...
    }
    

    This change lets our JS files that have JSDoc type hints get compiled. Also our IDEs (JetBrains IDEs and VS Code) can provide code-completion and Intellisense.

    References:

    • TypeScript - Compiler Options
    • TypeScript: TSConfig Reference - Compiler Options - allowJs

提交回复
热议问题