jgpacheco / ngx-translate-cache

MIT License
14 stars 11 forks source link

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

Open maxibroin opened 3 years ago

maxibroin commented 3 years ago

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 commented 3 years ago

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

maxibroin commented 3 years ago

Hi! I am working with Angular 10 and Typescript 3.9.5

hasanoqdeh commented 1 year ago

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