You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The m.match function doesn't seem to properly work with TypeScript. Example from the jsdoc:
import*asmfrom'@codemod/matchers';letid: m.CapturedMatcher<t.Identifier>;constidPlusIdMatcher=m.binaryExpression('+',(id=m.capture(m.identifier())),m.fromCapture(id));exportdefaultfunction(){return{BinaryExpression(path: NodePath<t.BinaryExpression>): void{m.match(idPlusIdMatcher,{ id },path.node,({ id })=>{path.replaceWith(t.binaryExpression('*',id,t.numericLiteral(2)));});}};}
This can be fixed by importing from ../matchers instead, because the published package doesn't contain src.
The
m.match
function doesn't seem to properly work with TypeScript. Example from the jsdoc:This can be fixed by importing from
../matchers
instead, because the published package doesn't containsrc
.codemod/packages/matchers/src/utils/match.ts
Line 1 in 505da37
codemod/packages/matchers/src/utils/matchPath.ts
Line 1 in 505da37
Another thing I noticed is that .fromCapture only works with captured primitives like strings, not matchers themselves:
Would be nice if both ways work to compare whole code structures
And when matching with containers it shouldn't narrow the type:
The text was updated successfully, but these errors were encountered: