import { walkTSNodeRecursive } from './tsUtils' ; import { createSourceFile , ScriptTarget } from 'typescript' ; import { OptionsStruct } from './type' ; import Diagnostic from './diagnostic' ; param code param position export default function tsParser < T extends ( ... args : any ) => any > ( code , position , option , optionsStruct , diagnostic , checkTsCodeDebounce ) { try { const sourceFile = createSourceFile ( 'Example.ts' , code , ScriptTarget . Latest ) ; checkTsCodeDebounce ( diagnostic , optionsStruct , code , sourceFile ) ; option = walkTSNodeRecursive ( sourceFile , position , position , '' ) || option ; return option . replace ( /.rich.(\S*)/ , '.rich.<style_name>' ) ; } catch ( error ) { console . error ( 'tsParse error' ) ; return option ; } }