Exporting a declaration
Any declaration (such as a variable, function, class, type alias, or interface) can be exported by adding the export
keyword.
Validation.ts
1 2 3 | export interface StringValidator { isAcceptable(s: string): boolean; } |
ZipCodeValidator.ts
1 2 3 4 5 6 7 | export const numberRegexp = /^[0-9]+$/; export class ZipCodeValidator implements StringValidator { isAcceptable(s: string) { return s.length === 5 && numberRegexp.test(s); } } |
Please login to continue.