“setTextRange”的作用是什么?在编写TypeScript转换时,何时有必要?
这是我在网上找到的一个片段!它更改“setTextRange”的作用是什么?在编写TypeScript转换时,何时有必要?,typescript,abstract-syntax-tree,Typescript,Abstract Syntax Tree,这是我在网上找到的一个片段!它更改源文件语句,但它是通过setTextRange调用来更改的,我不明白为什么需要它,或者它的预期用途是什么。这不是语法 return ts.updateSourceFileNode( sf, ts.setTextRange( ts.createNodeArray([ ...sf.statements.slice(0, firstHoistableNodeIndex + 1), // Inject hoisted variab
源文件
语句
,但它是通过setTextRange
调用来更改的,我不明白为什么需要它,或者它的预期用途是什么。这不是语法
return ts.updateSourceFileNode(
sf,
ts.setTextRange(
ts.createNodeArray([
...sf.statements.slice(0, firstHoistableNodeIndex + 1),
// Inject hoisted variables
...hoistedVariables,
...transformedStatements
]),
sf.statements
)
);
有关编写TypeScript转换的提示和技巧,请参阅。显然,TypeScript是最近为其中一些API制作的。