Skip to content

Could we strongly type LoaderContext? #13162

@johnnyreilly

Description

@johnnyreilly

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions