Skip to content

Commit 311a924

Browse files
committed
Fix broken types
The estree types were updated to support string literals in import specifiers. There are no tests, because acorn doesn’t support it yet.
1 parent ed87d22 commit 311a924

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

packages/language-service/lib/virtual-code.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,11 @@ function processExports(mdx, node, mapping, esm) {
260260
const {specifiers} = child
261261
for (let index = 0; index < specifiers.length; index++) {
262262
const specifier = specifiers[index]
263-
if (specifier.local.name === 'default') {
263+
if (
264+
specifier.local.type === 'Identifier'
265+
? specifier.local.name === 'default'
266+
: specifier.local.value === 'default'
267+
) {
264268
esm = addOffset(mapping, mdx, esm, start, specifier.start)
265269
const nextPosition =
266270
index === specifiers.length - 1
@@ -269,7 +273,9 @@ function processExports(mdx, node, mapping, esm) {
269273
return (
270274
addOffset(mapping, mdx, esm, nextPosition, end, true) +
271275
'\nimport {' +
272-
specifier.exported.name +
276+
(specifier.exported.type === 'Identifier'
277+
? specifier.exported.name
278+
: JSON.stringify(specifier.exported.value)) +
273279
' as MDXLayout} from ' +
274280
JSON.stringify(child.source.value) +
275281
'\n'

0 commit comments

Comments
 (0)