Recently, I delved into TypeScript to work on my new AngularJS project. However, I encountered an issue where the id, which is supposed to be of type number, is actually being treated as a string. Have I overlooked something in my code?
interface IRouteParams extends ng.route.IRouteParamsService {
id: number;
}
class FooController {
constructor(private $routerParams: IRouteParams, private fooService: IFooService) {
fooService.getById($routerParams.id);
}
}
export interface IFooService {
getById(id: number): ng.IPromise<number>;
}
class FooService implements IFooService {
getById(id: number): angular.IPromise<number> {
const defer = this.$q.defer<IRace>();
if (id === -1) {
// not working
}
return defer.promise;
}
}