Alex Cube
Alex Cube

Reputation: 442

How can i include another file in Typescript?

I have many typescript file a.ts, and another typescript file b.ts. how can i inlcude a.ts into b.ts? so when compile b.ts to javascript b.js, the content from a.ts is attached to b.js automatically. I know, in LESS we can use import "a.less' inside b.less, so when compiled to b.css, the content of a.css is automatically included in b.css. Does typescript have similar syntax?

Upvotes: 3

Views: 6034

Answers (1)

basarat
basarat

Reputation: 276219

Does typescript have similar syntax?

You can use outFile and if a.ts and b.ts are in your compilation context.

But instead I highly recommend you use modules : https://basarat.gitbook.io/typescript/content/docs/project/modules.html

And then compile using webpack : https://basarat.gitbook.io/typescript/content/docs/quick/browser.html

Upvotes: 3

Related Questions