Skip to content

Types: target not available on loader context #16753

@askoufis

Description

@askoufis

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions