Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Use Promise with TypeScript

ANSWERED

I can't get Promise working when using TypeScript.

 

My code is:

import geolocation from 'geolocation';

export function getCurrentLocation(): Promise<any> {
  return new Promise<any>((resolve: any, reject: any) => {
    
    geolocation.getCurrentPosition((position: any) => {
      resolve(position.coords);
    }, (error: any) => {
      reject(error);
    });
  });
}

When building I get the error:

/companion/util.ts (4,14): TS2693: 'Promise' only refers to a type, but is being used as a value here.
Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

TypeScript is not officially supported by Fitbit Studio yet, but as a temporary solution:

 

declare const Promise: any;

I took this from your own message on Discord 🙂

View best answer in original post

Best Answer
0 Votes
1 REPLY 1

TypeScript is not officially supported by Fitbit Studio yet, but as a temporary solution:

 

declare const Promise: any;

I took this from your own message on Discord 🙂

Best Answer
0 Votes