Closed iliakan closed 1 year ago
@iliakan Can you try npm i recast@next
?
It's with recast@next
;)
I thought... Maybe there's a limitation inside find
... Such as it doesn't go into some types of nodes...
@benjamn Also, here it can't find IPaginatedItems
.
Tried to make it as simple as possible. May be related.
export class A {
public test: () => void = () =>
pluck<IPaginatedItems>('data')
}
This looks like a bug in jscodeshift. Using recast
and @babel/core
visits those nodes just fine:
import { transform } from '@codemod/core';
const sources = [`
class SelectedFiltersComponent {
public ngOnInit(): void {
combineLatest()
.pipe(
map(([data, selectedData]: [IFilterData, IFilterParams]) => {
return items;
}),
)
}
}
`,
`
export class A {
public test: () => void = () =>
pluck<IPaginatedItems>('data')
}
`
];
for (const source of sources) {
transform(source, {
plugins: [
{
visitor: {
TSTypeReference(path) {
// prints:
// IFilterData
// IFilterParams
// IPaginatedItems
console.log(source.slice(path.node.start, path.node.end));
}
}
}
],
});
}
Hello,
Could you please explain, how's that possible?
In other words, I can access the node, but it's not found. WAT? 😮
Here's the code:
As you can see, there're at least two TypeReference nodes
IFilterData
andIFilterParams
, but for some reason they're not found.