Skip to content

Errors generated by isolatedDeclaration don't contain location specifier #8684

@voronin-ivan

Description

@voronin-ivan

After #7724, produced errors became less useful since they don't contain a reference to the problematic spot in a source file. Example:

const oxc = require('oxc-transform')

const source = `
    export const sum = (a: number, b: number): number => a + b

    export const subtract = (a: number, b: number) => a - b
`

const {errors} = oxc.isolatedDeclaration('example.ts', source)

console.log(errors)

oxc-transform@0.39.0

[
    '\n' +
      '  x TS9007: Function must have an explicit return type annotation with\n' +
      '  | --isolatedDeclarations.\n' +
      '   ,-[example.ts:4:29]\n' +
      ' 3 | \n' +
      ' 4 |     export const subtract = (a: number, b: number) => a - b\n' +
      '   :                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n' +
      '   `----\n'
]

oxc-transform@0.40.0 and later versions

[
    {
      severity: 'Error',
      message: 'TS9007: Function must have an explicit return type annotation with --isolatedDeclarations.',
      labels: [ [ { start: 93, end: 120 } ] ]
    }
]

It would be super helpful to have the location specifier back. Thank you!

Metadata

Metadata

Assignees

Labels

C-bugCategory - Bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions