-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Types: target not available on loader context #16753
Copy link
Copy link
Closed
Description
Bug report
What is the current behavior?
The target property is not available on the LoaderContext (this) type, despite the documentation stating that it should be there, and my experience with an existing loader that successfully accesses this property at runtime.
If the current behavior is a bug, please provide the steps to reproduce.
Import the LoaderContext type and try to access the target property.
import { type LoaderContext } from 'webpack';
const myLoader = (this: LoaderContext<any>) => {
console.log(this.target); // TypeScript error: Property 'target' does not exist on type 'LoaderContext<any>'
}What is the expected behavior?
The property should be accessible on the type and there should be no TypeScript error.
Other relevant information:
webpack version: 5.75.0
Node.js version: 16.19.0
Operating System: MacOS 13.1
Additional tools: pnpm
Reactions are currently unavailable