I'm using the new TypeScript for VS tooling system to generate JavaScript programs from TypeScript syntax. I need to define my app and the utils in seperate files, and I need to know how the util "classes" and functions will be included into the main app.
I've heard of the /// <reference path="....ts" />
syntax that lets you access code from external files. Does this syntax act like include
would in C++? Would it pull the used classes/functions into the main app.ts
file or would it simply expect the target files to exist as .js
files in the same directory?
Should I use internal modules to define classes that will be included (inlined) into the main app?
If you have a /// <reference ... >
tag to an other .ts file, those referenced files (recursively) will be compiled into the same .js file if you specify a filename to the --out
switch. Otherwise, that same set of files will be side-by-side compiled ( a.ts
-> a.js
).
None of this behavior is dependent on using internal modules vs keeping things at top-level. If you choose to use external modules, though, the story is very different (see existing material on this, probably).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.