qui*_*cky 5 typescript definitelytyped angular-cookies
我正在使用angularjs和创建一个应用程序typescript.我使用cookie来存储有关用户登录和权限等的相同数据.我遇到了angular-cookies.d.ts文件的问题.
$ cookieStore工作得很好但是根据AngularJS docs这个服务已被弃用,所以我尝试使用$ cookies代替.使用$ cookies在编译时导致错误,Property 'put' does not exist因此我检查了定义,并且在ICookiesService接口中确实没有具有此类名称的属性.
declare module "angular-cookies" {
var _: string;
export = _;
}
declare module angular.cookies {
interface ICookiesService {
[index: string]: any;
}
interface ICookieStoreService {
get(key: string): any;
put(key: string, value: any): void;
remove(key: string): void;
}
}
Run Code Online (Sandbox Code Playgroud)
这种类型定义中是否存在错误或我做错了什么?谢谢你的回复.
似乎还没有为Angular 1.4更新DefinitelyTyped定义.ICookiesService接口应该是这样的:
interface ICookiesService {
get(key: string): string;
getObject(key: string): any;
getAll(): any;
put(key: string, value: string, options?: any): void;
putObject(key: string, value: any, options?: any): void;
remove(key: string, options?: any): void;
}
Run Code Online (Sandbox Code Playgroud)
将来,您可以随意在GitHub上提交拉取请求以更新定义.我现在已经为此创建了一个.
上面提到的拉取请求已合并,因此这应该不再是一个问题.
| 归档时间: |
|
| 查看次数: |
4497 次 |
| 最近记录: |