代码之家  ›  专栏  ›  技术社区  ›  CodyBugstein

是否可以将Typescript导入正在运行的ts node REPL实例?

  •  1
  • CodyBugstein  · 技术社区  · 7 年前

    ts-node my-file-name.ts .

    不过,我想让它更具交互性,类似于Python REPL如何允许您导入模块,然后根据需要从REPL调用then函数。

    例如,会话可能看起来像

    $ ts-node
    > import my-file-name.ts
    > myFunctionFromMyFile("specialParam")
    > "you just called a function from my-file-name.ts with param specialParam"
    

    ts-node ?

    1 回复  |  直到 7 年前
        1
  •  6
  •   CodyBugstein    7 年前

    我发现的一种方法是:

    $ ts-node
    > import * as abc from './my-file'
    > abc.myFunction()
    > "works!"
    
    推荐文章