|
|
@@ -10,6 +10,7 @@ import {
|
|
|
NewlineType,
|
|
|
type SimpleExpressionNode,
|
|
|
type SourceLocation,
|
|
|
+ TS_NODE_TYPES,
|
|
|
advancePositionWithClone,
|
|
|
createSimpleExpression,
|
|
|
isInDestructureAssignment,
|
|
|
@@ -63,6 +64,7 @@ export function genExpression(
|
|
|
let hasMemberExpression = false
|
|
|
if (ids.length) {
|
|
|
const [frag, push] = buildCodeFragment()
|
|
|
+ const isTSNode = ast && TS_NODE_TYPES.includes(ast.type)
|
|
|
ids
|
|
|
.sort((a, b) => a.start! - b.start!)
|
|
|
.forEach((id, i) => {
|
|
|
@@ -71,8 +73,10 @@ export function genExpression(
|
|
|
const end = id.end! - 1
|
|
|
const last = ids[i - 1]
|
|
|
|
|
|
- const leadingText = content.slice(last ? last.end! - 1 : 0, start)
|
|
|
- if (leadingText.length) push([leadingText, NewlineType.Unknown])
|
|
|
+ if (!(isTSNode && i === 0)) {
|
|
|
+ const leadingText = content.slice(last ? last.end! - 1 : 0, start)
|
|
|
+ if (leadingText.length) push([leadingText, NewlineType.Unknown])
|
|
|
+ }
|
|
|
|
|
|
const source = content.slice(start, end)
|
|
|
const parentStack = parentStackMap.get(id)!
|
|
|
@@ -99,7 +103,7 @@ export function genExpression(
|
|
|
),
|
|
|
)
|
|
|
|
|
|
- if (i === ids.length - 1 && end < content.length) {
|
|
|
+ if (i === ids.length - 1 && end < content.length && !isTSNode) {
|
|
|
push([content.slice(end), NewlineType.Unknown])
|
|
|
}
|
|
|
})
|