🔎 Search Terms
content-mapper
🕗 Version & Regression Information
- I was unable to test this on prior versions because content mappers aren’t even released yet :)
⏯ Playground Link
n/a
💻 Code
https://github.com/remcohaszing/mdx-content-mapper/tree/auto-import-issue
Specifically, remcohaszing/mdx-content-mapper@04037c2
🙁 Actual behavior
Automatic imports work, if the statement to insert it to is already present. However, if the import statement isn’t present yet, then TypeScript won’t generate the statement.
This works:
This does not:
🙂 Expected behavior
Automatic imports always work.
Additional information about the issue
I tried to make this work by pushing an empty verbatim mapping to the start of the virtual content, like below. The virtual content may start with '// @ts-check\n'. In this case, the mapping is placed after that comment.
let esm = checkMdx ? '// @ts-check\n' : ''
esmMappings.push([
0,
0,
esm.length,
0,
/** @satisfies {SpanMapKind.Verbatim} */ (0),
/** @satisfies {SpanMapFeature.AutoInsert} */ (131_072)
])
🔎 Search Terms
content-mapper🕗 Version & Regression Information
⏯ Playground Link
n/a
💻 Code
https://github.com/remcohaszing/mdx-content-mapper/tree/auto-import-issue
Specifically, remcohaszing/mdx-content-mapper@04037c2
🙁 Actual behavior
Automatic imports work, if the statement to insert it to is already present. However, if the import statement isn’t present yet, then TypeScript won’t generate the statement.
This works:
This does not:
🙂 Expected behavior
Automatic imports always work.
Additional information about the issue
I tried to make this work by pushing an empty verbatim mapping to the start of the virtual content, like below. The virtual content may start with
'// @ts-check\n'. In this case, the mapping is placed after that comment.