Русское сообщество разработки на PHP-фреймворке Laravel.
Ты не вошёл. Вход тут.
Страницы 1
The red line, even though the code works, can indeed be quite confusing. To correct this, you might want to try specifying the actual type of ComponentProps instead of using <any>. The use of <any> can be a bit broad and may cause type checking errors, which is likely what's happening here.
Here's an approach to help resolve the error:
page.then((module: ComponentProps<Record<string, unknown>>) => {
module.default.layout = module.default.layout || ((page: ReactNode) => <Layout>{page}</Layout>);
});
By using Record<string, unknown> instead of <any>, you can make the type more specific, which helps TypeScript better understand what to expect. This should ideally get rid of the red line error you're seeing in PHP Storm. If you continue to face issues, you might want to delve deeper into the specific types being passed and ensure they align correctly with what ComponentProps expects.
Remember to also check your project configurations in PHP Storm and ensure that TypeScript is set up correctly. This can sometimes be a source of such issues. Good luck!
Страницы 1