'require' call may be converted to import #1786
-
In a freshly ignited project there are code action suggestions in a few files that declare images like this: export const logoIgnite = require("./logo-ignite.png") I'm pretty new to typescript, so not sure if my previous experience applies here, but I would assume that if code action is available, it means that there is something at least sub-optimal in your code. Funnily enough, when I take the code action, I get diagnostic errors, yet since those are not compiler errors the code still runs just fine. Is there something one can add to I read a bunch of issues online where users report annoying code action suggestions like "This may be converted to an async function" that they can't silence or deal with. So if there is no oversight with EDIT: Fix references to |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@dklymenk This is a reasonable question, for sure. React Native uses Metro, which is a bundler, and as far as I know, Metro requires (heh) that we use If you know of a way to globally disable this rule/code action, please let me know, and I'd love a PR! |
Beta Was this translation helpful? Give feedback.
-
Thanks for your response. Actually there is no way to disable these rules. This issue is pretty close to becoming a meme at this point. Some of these code actions are known to either break the code or do something unreasonable like making a function async for no actual reason. If you're curious I ended up forking typescript and adding support for filtering those error codes myself. That entire project is a huge mess, there is no centralized place where you can filter all the errors, so I ended up creating a higher order function that filters the codes. It's nowhere near a PR status as error codes are hard-coded and I haven't had time to figure out how to fetch them from project's tsconfig, but it works great for me, even though it's kinda annoying to recompile it every time I want to add a new suggestion to the ignore list. |
Beta Was this translation helpful? Give feedback.
@dklymenk This is a reasonable question, for sure. React Native uses Metro, which is a bundler, and as far as I know, Metro requires (heh) that we use
require
to pull in images. It's interesting to me thatimport
worked at all, there.If you know of a way to globally disable this rule/code action, please let me know, and I'd love a PR!