admin管理员组文章数量:1417045
I have two classes in different files:
export class ActionsCollection{
constructor(greeting :string){
this.greet(greeting);
}
public greet(greeting :string) {
return "<h1>"+greeting+"</h1>";
}
}
And
import {ActionsCollection} from "./actionsCollection";
class Greeter extends ActionsCollection{
constructor(public greeting: string) {
super(greeting);
}
}
alert(new Greeter("Hello, world!"));
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: At the same time, for the assembly, you can use standard WebStorm tools and Gulp. And nothing more, besides modules for Gulp.
I have two classes in different files:
export class ActionsCollection{
constructor(greeting :string){
this.greet(greeting);
}
public greet(greeting :string) {
return "<h1>"+greeting+"</h1>";
}
}
And
import {ActionsCollection} from "./actionsCollection";
class Greeter extends ActionsCollection{
constructor(public greeting: string) {
super(greeting);
}
}
alert(new Greeter("Hello, world!"));
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: At the same time, for the assembly, you can use standard WebStorm tools and Gulp. And nothing more, besides modules for Gulp.
Share Improve this question edited Oct 3, 2020 at 19:57 Peter Mortensen 31.6k22 gold badges110 silver badges133 bronze badges asked Apr 19, 2016 at 6:59 sanusanu 57011 silver badges31 bronze badges 2- If you use "files" in tsconfig and you write all files in the correct order it will pile everything in a single file (of course having the "out" directive in your tsconfig.json). The problem with this approach is that you cannot forget any file in the list. Using ES6 imports should be enough if you indicate your entry point though – iberbeu Commented Apr 19, 2016 at 9:03
- You can use the gulp webpack module I suppose – bryan60 Commented Oct 3, 2020 at 20:00
3 Answers
Reset to default 4Replace
import {ActionsCollection} from "./actionsCollection";
with
/// <reference path="./actionsCollection.ts" />
.
See Triple Slashes for more info on using the triple slash imports.
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
You can use it quite easily with Webpack: https://basarat.gitbooks.io/typescript/content/docs/quick/browser.html
This has the additional advantage that you can use all the wonderful libraries on npm seamlessly.
The tsconfig.json file may help you.
It has an "out" g.
本文标签: javascriptCan I use TypeScript without RequireJSStack Overflow
版权声明:本文标题:javascript - Can I use TypeScript without RequireJS? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745263209a2650453.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论