best way to import external javascript with typescript

前端 未结 1 726
执念已碎
执念已碎 2021-01-27 03:06

Currently I have 2 different ways in case I want to load in external code into my typescript file.

If i refer to another typescript file I have to write:



        
相关标签:
1条回答
  • 2021-01-27 03:41

    Just declare it as an external module

    /// <reference path="./types/angular/angular.d.ts" />
    declare module 'angular'{
        var angular:ng.IAngularStatic;
        export = angular;
    }
    
    // now you can do: 
    import angular = require('angular');
    
    0 讨论(0)
提交回复
热议问题