I attempted to employ a promise for an Async call in my custom form validator, so I created a separate TypeScript file called usernameValidators.ts.
import { Control } from 'angular2/common';
export class UsernameValidators {
static shouldBeUnique(control: Control){
return new Promise((resolve, reject) => {
setTimeout(function(){
if(control.value == "mosh")
resolve({ shouldBeUnique: true });
else
resolve(null);
}, 1000);
});
}
}
While working on this in VS Code, I noticed that there is a red squiggly line under Promise, and upon checking the PROBLEMS tab, I found the following error message:
https://i.sstatic.net/5bMTp.png
Can anyone provide guidance on how to resolve this issue?