next-i18next: 8.0.2 types causing
Describe the bug
Upgrading from 8.0.1 to 8.0.2 created an TypeScript:
app_1 | ./node_modules/next-i18next/src/appWithTranslation.tsx:61:3
app_1 | Type error: Type '((props: AppProps) => Element) & NonReactStatics<ComponentType<any>, {}>' is not assignable to type 'ComponentClass<P, any> | FunctionComponent<P> | (P extends SVGProps<SVGSymbolElement> ? "symbol" : never) | ... 173 more ... | (P extends SVGProps<...> ? "view" : never)'.
app_1 | Type '((props: AppProps) => Element) & NonReactStatics<ComponentType<any>, {}>' is not assignable to type 'FunctionComponent<P>'.
app_1 | Types of parameters 'props' and 'props' are incompatible.
app_1 | Property 'pageProps' is missing in type 'Record<string, unknown> & { children?: ReactNode; }' but required in type 'AppProps'.
app_1 |
app_1 | 59 | }
app_1 | 60 |
app_1 | > 61 | return hoistNonReactStatics(AppWithTranslation, WrappedComponent)
app_1 | | ^
app_1 | 62 | }
app_1 | 63 |
Occurs in next-i18next version
When moving from 8.0.1 to 8.0.2 (likely the type inclusion caused it).
Steps to reproduce
- Can’t right now, can do over the weekend
Expected behaviour
No error caused from the type casting.
OS
- Device: Linux, Ubuntu 20.10
- Browser: N/A
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 11
- Comments: 21 (7 by maintainers)
Commits related to this issue
- fix: typescript closes #995 — committed to ianldgs/next-i18next by ianldgs 3 years ago
- fix: typescript closes #995 — committed to ianldgs/next-i18next by ianldgs 3 years ago
- fix: typescript closes #995 — committed to ianldgs/next-i18next by ianldgs 3 years ago
- fix: typescript closes #995 — committed to ianldgs/next-i18next by ianldgs 3 years ago
Just want to say that all TS issues should be fixed from v8.0.6. You can see an example here of a
next-i18next
TypeScript app, with strict mode enabled:https://github.com/isaachinman/next-i18next-typescript
OK, I think there are two steps to fixing this for users who have
strict
set totrue
:"strict": true
in thenext-i18next
tsconfig
and fix up all errorsI have already begun work on the first item.
@isaachinman My tsconfig contains both
"skipLibCheck": true
and"exclude": ["node_modules"]
- same as @Cretezy.I’ve just cloned the repo you posted and played around with the tsconfig settings to reproduce the issue. Only change needed is to set
strict
to betrue
and all the below errors are presented:Here’s the offending tsconfig from that repo for clarity:
That said, I’m not sure why my own project isn’t adhering to the
skipLibCheck
rule and throwing these errors fromnext-i18next@8.0.2
🤔@aaesis You probably need to use
as const
. Next time please post questions on StackOverflow.@isaachinman Indeed it seems to be fixed with
v8.0.6
! Works on our project flawlessly 🎉For now, my workaround is to ignore build errors.