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

Kanav Malik

Code:

 reset(){
  let alert = this.AlertCtrl.create({
    buttons :['ok']
  });
  this.userservice.passwordreset(this.email).then((res: any)=>{
    if(res.success){
      alert.setTitle('Email sent');
      alert.setSubTitle('please follow the instructions in the email to reset the password')

    }
    else{
      alert.setTitle('failed');
    }
  })
}

Error:

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

can someone please help me by correcting this code snippet so that the 'then' function works cheers!

Vivek Doshi

The issues here is with passwordreset() function ,

It should look like this :

passwordreset(): Promise<any> {
  // this should return a promise
  // make sure , you are returning promise from here
  return this.http.get(url)
             .toPromise()
             .then(response => response.json().data)
             .catch(this.handleError);
}

You were returning the promise inside promise function , but not returning it from passwordreset(),

Please have a look at your code and updated code , you will get an idea

Your code :

passwordreset(email)
{ 
        var promise = new Promise((resolve,reject)=>{ 
            firebase.auth().sendPasswordResetEmail(email).then(()=>{ 
                            resolve({success :true}); 
                            })
                            .catch((err)=>{ 
                                reject(err); 
                            }) 
                            return promise; 
        }); 
}

Updated Code :

passwordreset(email): Promise<any>
{ 
        return new Promise((resolve,reject)=>{ 
            firebase.auth().sendPasswordResetEmail(email).then(()=>{ 
                                resolve({success :true}); 
                            })
                            .catch((err)=>{ 
                                reject(err); 
                            }); 
        }); 
}

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

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

編集
0

コメントを追加

0

関連記事

分類Dev

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

分類Dev

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

分類Dev

Typescript property does not exist on union type

分類Dev

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

分類Dev

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

分類Dev

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

分類Dev

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

分類Dev

'Property does not exist on type 'never'

分類Dev

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

分類Dev

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

分類Dev

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

分類Dev

Typescript error: Type 'undefined[]' is not assignable to type 'void'

分類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

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

分類Dev

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

分類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

typescript does not exist on type 'typeof object

分類Dev

express-jwt and express-graphql: error TS2339: Property 'user' does not exist on type 'Request'

分類Dev

Angular 7 : Build Prod Error: Property 'value' does not exist on type 'Component'

分類Dev

How to define a property to avoid: Property 'X' does not exist on type 'Y'

分類Dev

Firebase error when subscribing to ref.on(‘value’, callback); | Property 'subscribe' does not exist on type '(a: DataSnapshot, b?: string) => any'

Related 関連記事

  1. 1

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

  2. 2

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

  3. 3

    Typescript property does not exist on union type

  4. 4

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

  5. 5

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

  6. 6

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

  7. 7

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

  8. 8

    'Property does not exist on type 'never'

  9. 9

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

  10. 10

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

  11. 11

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

  12. 12

    Typescript error: Type 'undefined[]' is not assignable to type 'void'

  13. 13

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

  14. 14

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

  15. 15

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

  16. 16

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

  17. 17

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

  18. 18

    Property 'subscribe' does not exist on type 'Subscription

  19. 19

    Property 'entries' does not exist on type ObjectConstructor

  20. 20

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

  21. 21

    Property 'VAR_PLURAL' does not exist on type

  22. 22

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

  23. 23

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

  24. 24

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

  25. 25

    typescript does not exist on type 'typeof object

  26. 26

    express-jwt and express-graphql: error TS2339: Property 'user' does not exist on type 'Request'

  27. 27

    Angular 7 : Build Prod Error: Property 'value' does not exist on type 'Component'

  28. 28

    How to define a property to avoid: Property 'X' does not exist on type 'Y'

  29. 29

    Firebase error when subscribing to ref.on(‘value’, callback); | Property 'subscribe' does not exist on type '(a: DataSnapshot, b?: string) => any'

ホットタグ

アーカイブ