When Anders Hejlsberg is talking about external modules around 35:00 in the following video...
Anders Hejlsberg: Introducing TypeScript
... why does the file server.ts
require a triple slash reference to node.d.ts where as hello.ts
doesn't require a similar reference to server.ts
?
In particular in hello.ts
he mentions that intellisense is present plus he gets to use the exported item from server.ts
. So what more could the triple slash reference add?
You need a triple slash reference in two scenarios:
--out
you can reference your files using /// <reference
.You need a import/require
combo when using external modules i.e. amd
/commonjs
. If you don't know what these mean (amd/commonjs are javascript terms, not specific to typescript) you don't have to care. Just use /// <reference
and compile with --out
.
PS: I have a video tutorial on internal vs. external modules: TypeScript Modules Demystified : Internal, AMD with RequireJS, CommonJS with NodeJS
Please use tsconfig.json
for new projects instead of reference comments : https://basarat.gitbook.io/typescript/project/compilation-context
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With