NarHakobyan / awesome-nest-boilerplate

Awesome NestJS Boilerplate 😍, Typescript 💪, Postgres 🎉, TypeORM 🥳
https://narhakobyan.github.io/awesome-nest-boilerplate
MIT License
2.4k stars 452 forks source link

nestjs-i18n related errors #278

Closed sergiuturus closed 2 years ago

sergiuturus commented 2 years ago

Encountered a bunch of errors related to nestjs-i18n package after cloning the repo, created the .env, ran npm install and npm run start:dev

TSError: ⨯ Unable to compile TypeScript:
src/app.module.ts:7:10 - error TS2305: Module '"nestjs-i18n"' has no exported member 'I18nJsonParser'.

7 import { I18nJsonParser, I18nModule } from 'nestjs-i18n';
           ~~~~~~~~~~~~~~
src/app.module.ts:34:7 - error TS2322: Type '(configService: ApiConfigService) => { fallbackLanguage: string; parserOptions: { path: string; watch: boolean; }; }' is not assignable to type '(...args: any[]) => I18nOptionsWithoutResolvers | Promise<I18nOptionsWithoutResolvers>'.
  Type '{ fallbackLanguage: string; parserOptions: { path: string; watch: boolean; }; }' is not assignable to type 'I18nOptionsWithoutResolvers | Promise<I18nOptionsWithoutResolvers>'.
    Property 'loaderOptions' is missing in type '{ fallbackLanguage: string; parserOptions: { path: string; watch: boolean; }; }' but required in type 'I18nOptionsWithoutResolvers'.

34       useFactory: (configService: ApiConfigService) => ({
         ~~~~~~~~~~

  node_modules/nestjs-i18n/dist/interfaces/i18n-options.interface.d.ts:22:5
    22     loaderOptions: any;
           ~~~~~~~~~~~~~
    'loaderOptions' is declared here.
  node_modules/nestjs-i18n/dist/interfaces/i18n-options.interface.d.ts:35:5
    35     useFactory?: (...args: any[]) => Promise<I18nOptionsWithoutResolvers> | I18nOptionsWithoutResolvers;
           ~~~~~~~~~~
    The expected type comes from property 'useFactory' which is declared here on type 'I18nAsyncOptions'

Tried to remove the package but received other errors. Current node version v14.17,0

g1mi commented 2 years ago

I have the same issue, change to yarn or pnpm still have this problem. plz check

NarHakobyan commented 2 years ago

Hi Guys, this issue is already fixed here https://github.com/NarHakobyan/awesome-nest-boilerplate/pull/277 :)

duynvh commented 2 years ago

I also have the same issue. After I checked PR, I still see PR 277 not merged yet

NarHakobyan commented 2 years ago

yeah, I'll try to do my best just to fix all the issues and merge. :)

prathd commented 2 years ago

I'm getting the same error. Is there an expected timeline for #277?

NarHakobyan commented 2 years ago

yes, today everything will be done and merged :)

ikhanhmai commented 2 years ago

hi team, facing the same error, hopefully we will have this PR merged today

NarHakobyan commented 2 years ago

Hi folks, I've updated main branch, please take a look and if you will catch any kind of bug please ping me here :)

ikhanhmai commented 2 years ago

hi @NarHakobyan, thanks for the fix, now another error happens, it's reported on March: https://github.com/NarHakobyan/awesome-nest-boilerplate/issues/273

any idea?

NarHakobyan commented 2 years ago

@ikhanhmai could you please send some reproduction steps?

ikhanhmai commented 2 years ago

sure @NarHakobyan steps to reproduce:

now got the error: TypeError: Cannot read properties of undefined (reading 'split') at I18nService.translateObject (D:\awesome-nest-boilerplate\node_modules\nestjs-i18n\src\services\i18n.service.ts:128:22) at I18nService.translate (D:\awesome-nest-boilerplate\node_modules\nestjs-i18n\src\services\i18n.service.ts:62:36) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async AllExceptionsFilter.catch (D:\awesome-nest-boilerplate\src\filters\all-exceptions.filter.ts:22:15)

current workaround: add try catch block to filters/all-exceptions.filter.ts try { message = await this.i18n.translate(message.key, { lang: ctx.getRequest().i18nLang, args: message.args, }); } catch (e) {}

NarHakobyan commented 2 years ago

thanks, all-exceptions.filter.ts filter file was experimental, so it needs to be removed. I've deleted it from main repo.