我可以在没有RequireJS的情况下使用TypeScript吗? [英] Can I use TypeScript without RequireJS?

查看:68
本文介绍了我可以在没有RequireJS的情况下使用TypeScript吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在不同的文件中有两个类:

I have two classes in different files:

export class ActionsCollection{
    constructor(greeting :string){
        this.greet(greeting);
    }

    public greet(greeting :string) {
        return "<h1>"+greeting+"</h1>";
    }
}

还有

import {ActionsCollection} from "./actionsCollection";

class Greeter extends ActionsCollection{
    constructor(public greeting: string) {
        super(greeting);
    }
}

alert(new Greeter("Hello, world!"));

在这样的文件中生成

Greeter ,其中需要行("./actionsCollection").但是我想确保所有文件(* .ts)都只在一个文件main.js中生成,它不需要 require .我可以那样做吗?如果可以,怎么办?

Greeter is generated in such a file in which there is require line ("./ actionsCollection"). But I want to make sure that all the files (*.ts) generates in only one file main.js, it does not need require. Can I do that? And if so, how?

PS:同时,对于程序集,您可以使用标准的 WebStorm 工具和Gulp.还有,除了Gulp的模块之外,什么都没有.

PS: At the same time, for the assembly, you can use standard WebStorm tools and Gulp. And nothing more, besides modules for Gulp.

推荐答案

替换

从"./actionsCollection"中导入{ActionsCollection};

///<参考路径="./actionsCollection.ts"/> .

有关使用以下命令的更多信息,请参见三斜杠.三斜杠导入.

See Triple Slashes for more info on using the triple slash imports.

这篇关于我可以在没有RequireJS的情况下使用TypeScript吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆