TypeScript '...' does not exist on type 'typeof ...'

alik

I have this piece of code that whatever I try, I can not get passed the following error.

Error: Property 'EmailValidator' does not exist on type 'typeof UserValidators'.

Code:

import {EMAIL_REGEX} from '../constants';
import {Control} from 'angular2/common';

export interface IUserValidators {
  EmailValidator(control: Control) : Object;
}

export class UserValidators implements IUserValidators {
  EmailValidator(control: Control) : Object {
    if (!control.value) {
      return {
        required: true
      };
    } else if (control.value) {
      if (!new RegExp(EMAIL_REGEX).test(control.value)) {
        return {
          invalid: true
        };
      }
    }
    return {};
  }
}

This is how I try to inject the EmailValidator:

this.fb.group({
      email: ['', UserValidators.EmailValidator]
});
gilamran

You should create an instance of this class to be able to access it, like this:

var userValidators : IUserValidators = new UserValidators();
userValidators.EmailValidator(ctrl);

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

typescript does not exist on type 'typeof object

分類Dev

Angular 6 : Property 'fromEvent' does not exist on type 'typeof Observable'

分類Dev

property then does not exist on type void , A typescript error

分類Dev

Typescript: Property 'DB' does not exist on type 'Global'

分類Dev

Typescript property does not exist on union type

分類Dev

リーフレットProperty-Routing-does-not-exist-on-type-typeof-import

分類Dev

How to prevent "Property '...' does not exist on type 'Global'" with jsdom and typescript?

分類Dev

useRef Typescript error: Property 'current' does not exist on type 'HTMLElement'

分類Dev

Typescript - property scan does not exist on type Subject...?

分類Dev

React & Typescript: Property 'id' does not exist on type 'number'

分類Dev

Typescript: typeof check in list item does not work

分類Dev

Typescript+React+Redux+reactrouter:"property does not exist on type IntrinsicAttributes & IntrinsicClassAttributes" passing props from parent to child

分類Dev

uisng multer with typescript: Property 'file' does not exist on type 'Request'.ts(2339)

分類Dev

TypeScript "Property does not exist on type" error when setting up a "Profile Details" page in Angular

分類Dev

'Property does not exist on type 'never'

分類Dev

Property 'xxx' does not exist on type '{}'

分類Dev

Property 'values' does not exist on type 'ObjectConstructor'

分類Dev

Property 'values' does not exist on type 'ObjectConstructor'

分類Dev

Angular2 - 'then' does not exist on type 'void'

分類Dev

TSLint: Property 'params' does not exist on type 'NavigationState'

分類Dev

Property 'subscribe' does not exist on type 'Subscription

分類Dev

Property 'entries' does not exist on type ObjectConstructor

分類Dev

Property 'innerText' does not exist on type 'Element'

分類Dev

Property 'VAR_PLURAL' does not exist on type

分類Dev

Property 'detailed' does not exist on type 'Console'

分類Dev

Property 'store' does not exist on type 'Readonly<AppInitialProps

分類Dev

Generic property 'enabled' does not exist on type 'Node'?

分類Dev

Type Checking: typeof, GetType, or is?

分類Dev

What is the type of typeof in JS

Related 関連記事

  1. 1

    typescript does not exist on type 'typeof object

  2. 2

    Angular 6 : Property 'fromEvent' does not exist on type 'typeof Observable'

  3. 3

    property then does not exist on type void , A typescript error

  4. 4

    Typescript: Property 'DB' does not exist on type 'Global'

  5. 5

    Typescript property does not exist on union type

  6. 6

    リーフレットProperty-Routing-does-not-exist-on-type-typeof-import

  7. 7

    How to prevent "Property '...' does not exist on type 'Global'" with jsdom and typescript?

  8. 8

    useRef Typescript error: Property 'current' does not exist on type 'HTMLElement'

  9. 9

    Typescript - property scan does not exist on type Subject...?

  10. 10

    React & Typescript: Property 'id' does not exist on type 'number'

  11. 11

    Typescript: typeof check in list item does not work

  12. 12

    Typescript+React+Redux+reactrouter:"property does not exist on type IntrinsicAttributes & IntrinsicClassAttributes" passing props from parent to child

  13. 13

    uisng multer with typescript: Property 'file' does not exist on type 'Request'.ts(2339)

  14. 14

    TypeScript "Property does not exist on type" error when setting up a "Profile Details" page in Angular

  15. 15

    'Property does not exist on type 'never'

  16. 16

    Property 'xxx' does not exist on type '{}'

  17. 17

    Property 'values' does not exist on type 'ObjectConstructor'

  18. 18

    Property 'values' does not exist on type 'ObjectConstructor'

  19. 19

    Angular2 - 'then' does not exist on type 'void'

  20. 20

    TSLint: Property 'params' does not exist on type 'NavigationState'

  21. 21

    Property 'subscribe' does not exist on type 'Subscription

  22. 22

    Property 'entries' does not exist on type ObjectConstructor

  23. 23

    Property 'innerText' does not exist on type 'Element'

  24. 24

    Property 'VAR_PLURAL' does not exist on type

  25. 25

    Property 'detailed' does not exist on type 'Console'

  26. 26

    Property 'store' does not exist on type 'Readonly<AppInitialProps

  27. 27

    Generic property 'enabled' does not exist on type 'Node'?

  28. 28

    Type Checking: typeof, GetType, or is?

  29. 29

    What is the type of typeof in JS

ホットタグ

アーカイブ