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

Could we strongly type LoaderContext? #13162

Closed
johnnyreilly opened this issue Apr 16, 2021 · 1 comment · Fixed by #13164
Closed

Could we strongly type LoaderContext? #13162

johnnyreilly opened this issue Apr 16, 2021 · 1 comment · Fixed by #13164

Comments

@johnnyreilly
Copy link
Contributor

johnnyreilly commented Apr 16, 2021

Hey all!

Maintainer of ts-loader here. I'm just writing up the migration of ts-loader to be built / run it's test packs against webpack 5 on my blog: johnnyreilly/blog.johnnyreilly.com#35

One thing that happened as part of the migration was that we started using the TypeScript types that webpack ships with as of v5. This has been great! However, we did find one omission in the form of the LoaderContext which is typed as any:

* @returns {any} loader context

Is this intentional? Or would it be possible for this to become strongly typed in future as well?

Looking at this:

Object.assign(loaderContext, options.loader);

It would seem the type is something like this:

type LoaderContext = typeof loaderContext & typeof options.loader

Related PR: TypeStrong/ts-loader#1251

@johnnyreilly
Copy link
Contributor Author

I've opened a speculative PR to demonstrate what I had in mind: #13164

What do you think?

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

Successfully merging a pull request may close this issue.

2 participants