Error at /Users/user/project/.tmp/shared/validation/validators/unicode-characters.validator.ts:12:52: Return type of public static method from exported class has or is using private name 'ValidationResult'.
import {FormControl} from "@angular/forms";
interface ValidationResult {
[key:string]:boolean;
}
export class UnicodeCharactersValidator {
/* tslint:disable:max-line-length */
private static UNICODE_CHARS_PATTERN = /^[ \u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0]*$/;
public static check(formControl: FormControl): ValidationResult {
if ( !UnicodeCharactersValidator.UNICODE_CHARS_PATTERN.test(formControl.value) ) {
return { "invalidCharacters": true };
}
return null;
}
}
我该如何解决这个问题?
答案 0 :(得分:4)
您还必须导出界面:
export interface ValidationResult {
[key:string]:boolean;
}
公共函数返回ValidationResult
。这意味着它可以从外部访问。这就是为什么你也应该导出ValidationResult
:)