Angular-cookies DefinitelyTyped

I am creating an application using angularjsand typescript. I use cookies to store the same data about logins and user rights, etc. I encountered a problem with the angular-cookies.d.ts file.

$ cookieStore is working fine, but according to AngularJS docs this service is deprecated, so I tried using $ cookie instead. Using $ cookies caused a compilation error Property 'put' does not exist, so I checked the definition and there really is no property with that name in the ICookiesService interface.

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;
    }
}

Is there a mistake in defining this type or am I doing something wrong? Thank you for your responses.

+4
source share
1

, DefinitelyTyped Angular 1.4. 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;
}

GitHub . .

:

, .

+5

Source: https://habr.com/ru/post/1584913/


All Articles