In TypeScript this kind of syntax is supported for CommonJS modules
import foo = require('foo');
reference: https://www.typescriptlang.org/docs/handbook/2/modules.html#commonjs-style-import-and-export-
currently it is impossible to catch this type of import with Semgrep patterns
expected support would look smth like this:
https://semgrep.dev/s/6WOW
pattern:
import "fs";
code:
import fs = require("fs");
@inkz do you know what the priority is here?
@aryx do you have a sense of how much work this would involve?
My initial thoughts here are that we hold off until we decide to do The Big Imports Refactor. Instead of fixing these import issues one by one we could lump this into https://github.com/returntocorp/semgrep/issues/285 or https://github.com/returntocorp/semgrep/issues/975 and fix everything all at once. Thoughts?
@inkz raised this from a thread I started on slack. To me it make sense to fix it all at once if that's going to happen sometime in the coming months.
yep, as this is a user request, and @ben-elttam is ok with waiting a little bit, it would be awesome to tackle it during Big Imports Refactor!
I'll be happy to help with testing and some practical examples. :+1:
Assigning to @aryx for now - we can unassign later if this is too much work.
What is the "The Big Imports Refactor"? I've spent some time on import related issue a few weeks ago, to get metavariable to match the whole path, but I don't think there's a more general refactoring solving all the problems.
Hopefully I can work on it next week. A it swamped this week with backlogs.