Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property 'then' does not exist on type '() => Promise<{}>'. - Ionic 3

Method

  hola() {
        return new Promise((resolve, reject) => {
          if(true) {
            resolve(true)
          }
        })
    }

Calling the method

this.hola.then(data => console.log(data));

Error

Property 'then' does not exist on type '() => Promise<{}>'.

I already tried to restart ionic serve but it keeps throwing that error

like image 439
poimsm2 Avatar asked Dec 18 '22 21:12

poimsm2


2 Answers

The parenthesis is missing while you are calling the method hola.

this.hola().then(data => console.log(data));
like image 165
arun kumar Avatar answered Dec 20 '22 17:12

arun kumar


When you call the method, try this instead, storring it in a variable of type "any" makes it ignore the "existence" of the proprety

    var a:any = this.slides.getActiveIndex()
    a.then(data => {
        console.log(data)
    })
like image 20
a big expert Avatar answered Dec 20 '22 17:12

a big expert