MCPcopy Index your code
hub / github.com/nodejs/node / isReusableVariableDeclaration

Function isReusableVariableDeclaration

test/fixtures/snapshot/typescript.js:32974–32994  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

32972 return false;
32973 }
32974 function isReusableVariableDeclaration(node) {
32975 if (node.kind !== 254 /* SyntaxKind.VariableDeclaration */) {
32976 return false;
32977 }
32978 // Very subtle incremental parsing bug. Consider the following code:
32979 //
32980 // let v = new List < A, B
32981 //
32982 // This is actually legal code. It's a list of variable declarators "v = new List<A"
32983 // on one side and "B" on the other. If you then change that to:
32984 //
32985 // let v = new List < A, B >()
32986 //
32987 // then we have a problem. "v = new List<A" doesn't intersect the change range, so we
32988 // start reparsing at "B" and we completely fail to handle this properly.
32989 //
32990 // In order to prevent this, we do not allow a variable declarator to be reused if it
32991 // has an initializer.
32992 var variableDeclarator = node;
32993 return variableDeclarator.initializer === undefined;
32994 }
32995 function isReusableParameter(node) {
32996 if (node.kind !== 164 /* SyntaxKind.Parameter */) {
32997 return false;

Callers 1

canReuseNodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected