3

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?

2
  • 2
    TypeScript uses modules and ES6 style import statements - consult the official documentation: typescriptlang.org/docs/handbook/modules.html Commented Mar 8, 2017 at 8:45
  • You can also use triple-slashes depending on what you're doing. But it's not a recommended technique. JavaScript (and TypeScript) rely on modules instead like UnholySheep mentioned. Commented Mar 8, 2017 at 16:42

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.