Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'cookieAttributes' does not exist in type 'TranslateCacheConfig' #33

Open
maxibroin opened this issue Apr 9, 2021 · 3 comments
Open

Comments

@maxibroin
Copy link

Hi! I'm trying to set cookie attributes like this example:

import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { TranslateCacheModule, TranslateCacheSettings, TranslateCacheService } from 'ngx-translate-cache';

@NgModule({
    imports: [
        TranslateModule.forRoot(),
        TranslateCacheModule.forRoot({
          cacheService: {
            provide: TranslateCacheService,
            useFactory: (translateService, translateCacheSettings) => {
                return new TranslateCacheService(translateService, translateCacheSettings)
            },
            deps: [ TranslateService, TranslateCacheSettings ]
          },
          cacheName: 'mylang', // default value is 'lang'.
          cacheMechanism: 'Cookie', // default value is 'LocalStorage'.
          cookieExpiry: 1, // default value is 720, a month. Set to a negative value and the cookie becomes a session cookie.
          **cookieAttributes: 'SameSite=Strict; Secure' // no default, optional specification of additional attributes.**
        })
    ],
    ...
})
export class AppModule {}

I get the following error:

ERROR in src/app/shared/components/language-picker/language-picker.module.ts:34:7 - error TS2345: Argument of type '{ cacheService: { provide: typeof TranslateCacheService; useFactory: (translateService: TranslateService, translateCacheSettings: TranslateCacheSettings) => TranslateCacheService; deps: (typeof TranslateService | typeof TranslateCacheSettings)[]; }; cacheMechanism: "Cookie"; cookieAttributes: string; }' is not assignable to parameter of type 'TranslateCacheConfig'.
Object literal may only specify known properties, and 'cookieAttributes' does not exist in type 'TranslateCacheConfig'.

If if go to the code cookieAttribute is not defined

export interface TranslateCacheConfig {
cacheService: Provider;
cacheName?: string;
cacheMechanism?: CacheMechanismType;
cookieExpiry?: number;
}

@jgpacheco
Copy link
Owner

Hi @maxibroin. Which Angular, TS versions are you using?

@maxibroin
Copy link
Author

Hi! I am working with Angular 10 and Typescript 3.9.5

@hasanoqdeh
Copy link

hasanoqdeh commented Feb 14, 2023

i have same issue, any help for this case @maxibroin @jgpacheco thanks on advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants