Skip to content

Errors/warnings added by ts-loader do not respect webpack API #1199

Closed
@lorenzodallavecchia

Description

@lorenzodallavecchia

I'm processing webpack errors/warnings in the compilation results.

Expected Behaviour

The errors and warnings reported by ts-loader through webpack should implement the WebpackError interface.
Starting from webpack 5 the interface is part of webpack's official typings.

Actual Behaviour

Instead of including the loc property with start/end positions of the error, the object added by ts-loader includes a location property with just the starting position. This is easily seen in the webpack stats object produced by the compilation.

stats.compilation.errors; // each error misses the 'loc' property
stats.compilation.warnings; // each warning misses the 'loc' property

Probably as a consequence of this, when I transform the stats into JSON, there is no location information for the errors.

const json = stats.toJson({ all: false, errors: true, warnings: true });
json.errors; // 'loc' missing in errors
json.warnings; // 'loc' missing in warnings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions