Re-exports
Often modules extend other modules, and partially expose some of their features. A re-export does not import it locally, or introduce a local variable.
ParseIntBasedZipCodeValidator.ts
1 2 3 4 5 6 7 8 | export class ParseIntBasedZipCodeValidator { isAcceptable(s: string) { return s.length === 5 && parseInt(s).toString() === s; } } // Export original validator but rename it export {ZipCodeValidator as RegExpBasedZipCodeValidator} from "./ZipCodeValidator" ; |
Optionally, a module can wrap one or more modules and combine all their exports using export * from "module"
syntax.
AllValidators.ts
1 2 3 | export * from "./StringValidator" ; // exports interface 'StringValidator' export * from "./LettersOnlyValidator" ; // exports class 'LettersOnlyValidator' export * from "./ZipCodeValidator" ; // exports class 'ZipCodeValidator' |
Please login to continue.