Skip to content

[Bug]: BindingSourceMap is incompatible to ExistingRawSourceMap #9135

Description

@jurijzahn8019

Reproduction link or steps

If i return source map from the RolldownMagicString["generateMap"];
Type check fails.

export default {
   transform: {
      order: "post",
      handler(this, code, id) {
        const ms = new RolldownMagicString(code);

        // Do Something with the string

        // Error Here
        const result = { code: ms, map: ms.generateMap({ hires: true }) } satisfies TransformResult;
        return result;
      },
    },
}

What is expected?

tsc does not fail

What is actually happening?

Image

This because BindingSourceMap has `get sourcesContent(): Array<string | undefined | null>;``

And ExistingRawSourceMap has sourcesContent?: (string | null)[];

i would like to avoid using strictNullChecks: false

System Info

System:
    OS: macOS 26.4
    CPU: (10) arm64 Apple M2 Pro
    Memory: 77.16 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.11.0 - /Users/jurij.zahn/.local/state/fnm_multishells/35855_1776071072676/bin/node
    npm: 11.6.1 - /Users/jurij.zahn/.local/state/fnm_multishells/35855_1776071072676/bin/npm
    pnpm: 10.30.3 - /Users/jurij.zahn/.local/state/fnm_multishells/35855_1776071072676/bin/pnpm
  Browsers:
    Brave Browser: 147.1.89.132
    Chrome: 147.0.7727.56
    Edge: 147.0.3912.60
    Firefox: 149.0.2
    Safari: 26.4

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions