How to import js-modules into TypeScript file?

前端 未结 5 1172
自闭症患者
自闭症患者 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:46

    I tested 3 methods to do that...

    Method1:

          const FriendCard:any = require('./../pages/FriendCard')
    

    Method2:

          import * as FriendCard from './../pages/FriendCard';
    

    Method3:

    if you can find something like this in tsconfig.json:

          { "compilerOptions": { ..., "allowJs": true }
    

    then you can write: import FriendCard from './../pages/FriendCard';

提交回复
热议问题