【问题标题】:How do i get the output of this following typescript code using command prompt ?如何使用命令提示符获取以下打字稿代码的输出?
【发布时间】:2017-09-27 22:02:54
【问题描述】:
class Book{
    public title : string;
    public year  : number;

    constructor( title :string ,year:number){
        this.title = title;
        this.year  = year ; 


    }
}
var details = new Book("werr",2017);
console.log(details);

我仍然是 Typescript 的初学者。非常感谢任何帮助。

【问题讨论】:

标签: javascript typescript


【解决方案1】:

命令是

tsc .ts && 节点.js

您应该在系统中安装 nodeJs 以运行上述命令。 你可以从这里下载 NodeJs https://nodejs.org/en/

假设您的 TypeScript 文件名是 ma​​in.ts

那么命令将是

tsc main.ts && 节点 main.js

如果您愿意,也可以单独运行它。
首先使用以下命令编译

tsc main.ts

然后使用以下命令运行

节点 main.js

【讨论】:

    猜你喜欢
    • 2022-01-23
    • 1970-01-01
    • 1970-01-01
    • 2021-07-27
    • 1970-01-01
    • 1970-01-01
    • 2013-06-21
    • 1970-01-01
    • 2012-10-20
    相关资源
    最近更新 更多