Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE-40 + index.ts: modified the require statement at end of file. Unsa… #226

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

oliviax727
Copy link

No description provided.

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const command = require(path);
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
return (typeof command === 'object' ? command.default : command)(rootCommand);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this unsafe convenience has aged out and should be replaced with explicit imports?

Copy link
Member

@SamMurphyDev SamMurphyDev Oct 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an option of using a dynamic import. It sorta fixes the problem. It does have typing on the return value from the import import("./somePath"). The types turn to any when you're using a string like we are instead of a string const. The advantage that import gives us regardless is it will always be an object. Even with cast from any to a module, we could do ((await import(path)) as {default: FuncType}).default(rootCommand)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants