Description
Thank you for a great library!
We've just upgraded from v3 to v4, and now we're running into a build problem. We use the error handling described in your documentation: [https://next-intl.dev/docs/usage/configuration#error-handling], and we are checking error codes with if (error.code === IntlErrorCode.MISSING_MESSAGE). We now get the following build error: Type error: Cannot access ambient const enums when 'isolatedModules' is enabled, obviously caused by the change from: declare enum IntlErrorCode to declare const enum IntlErrorCode. In your documentation on error handling, the enum is used at runtime, which is very useful. But v4 made this use impossible by the conversion to a const enum.
I see several potential "solutions":
- Disable
isolatedModules, which is a no-go for our Next.js project;
- Bypass the definition of
IntlErrorCode and define our own, which is undesirable;
- Redefine the
IntlErrorCode enum in your library (overwrite, which is also undesirable).
Do you see a feasible alternative, or would you be willing to revert to the old declaration, so we can use the enum both at compile time and at runtime?
Thanks in advance.
Verifications
Mandatory reproduction URL
https://github.com/jl75/next-intl-ambient-enum-bug/tree/main
Reproduction description
Steps to reproduce: clone repository, install and build.
Expected behaviour
Build without errors.
Description
Thank you for a great library!
We've just upgraded from v3 to v4, and now we're running into a build problem. We use the error handling described in your documentation: [https://next-intl.dev/docs/usage/configuration#error-handling], and we are checking error codes with
if (error.code === IntlErrorCode.MISSING_MESSAGE). We now get the following build error:Type error: Cannot access ambient const enums when 'isolatedModules' is enabled, obviously caused by the change from:declare enum IntlErrorCodetodeclare const enum IntlErrorCode. In your documentation on error handling, the enum is used at runtime, which is very useful. But v4 made this use impossible by the conversion to a const enum.I see several potential "solutions":
isolatedModules, which is a no-go for our Next.js project;IntlErrorCodeand define our own, which is undesirable;IntlErrorCodeenum in your library (overwrite, which is also undesirable).Do you see a feasible alternative, or would you be willing to revert to the old declaration, so we can use the enum both at compile time and at runtime?
Thanks in advance.
Verifications
Mandatory reproduction URL
https://github.com/jl75/next-intl-ambient-enum-bug/tree/main
Reproduction description
Steps to reproduce: clone repository, install and build.
Expected behaviour
Build without errors.