Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs Typescript:让ts知道函数中的类_Angularjs_Typescript - Fatal编程技术网

Angularjs Typescript:让ts知道函数中的类

Angularjs Typescript:让ts知道函数中的类,angularjs,typescript,Angularjs,Typescript,我在角度工厂函数中定义了我的类: export default function ($resource, $http:angular.IHttpService) { return class Account{} } 我还有一个all.ts,其中包括我的FinitelyTyped打字。当我想在另一个类中使用Account时,我会向它注入: class AccountsController { public static $inject = ['Account']; construct

我在角度工厂函数中定义了我的类:

export default function ($resource, $http:angular.IHttpService) {
  return class Account{}
}
我还有一个all.ts,其中包括我的FinitelyTyped打字。当我想在另一个类中使用Account时,我会向它注入:

class AccountsController {
  public static $inject = ['Account'];
  constructor(public Account:Account){}
}
但是,帐户是未知的,即使我将工厂文件添加到所有.ts引用中,它也找不到它


理想情况下,我如何让typescript知道Account,而无需再次定义接口(因为它已经通过类定义了,不是吗?)。

我通常这样做:

export function theService(...): theService {
  return {
    theServiceMethod1: function(id) {
  }
}

export declare interface theService {
  theServiceMethod1(id): void;
  ....
}
这同样适用于类。类成员是已知的,但导出函数的返回类型并不是我所能说的