February 2019
Beginner
694 pages
18h 4m
English
There are two things we need in order to write and use modules. Firstly, a module needs to be exposed to the outside world in order to be consumed. This is called exporting, and uses the TypeScript keyword export. This means that, within a particular source file, you may have functions and classes that are considered internal, and should not be made available to the outside world. Only components that are designed to be used outside of the source file should be exported. As an example of this, consider a module written in a file named lib/Module1.ts:
export class Module1 {
print() {
print(`Module1.print()`);
}
}
function print(functionName: string) {
console.log(`print() called with ${functionName}`);
}
Here, we have a ...
Read now
Unlock full access