import MagicString from 'magic-string' ; import ts from 'typescript' ; /**
 * Transform type assertion to as expression: <Type>a => a as Type
 */ export function handleTypeAssertion ( str , assertion , astOffset ) { const { expression , type } = assertion ; const assertionStart = assertion . getStart ( ) + astOffset ; const typeStart = type . getStart ( ) + astOffset ; const typeEnd = type . getEnd ( ) + astOffset ; const expressionStart = expression . getStart ( ) + astOffset ; const expressionEnd = expression . getEnd ( ) + astOffset ; str . appendLeft ( expressionEnd , ' as ' ) ; str . move ( assertionStart , typeEnd , expressionEnd ) ; str . remove ( assertionStart , typeStart ) ; str . remove ( typeEnd , expressionStart ) ; }