-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Ensure all scripts are checked, fix errors #50326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
const fs = require("fs"); | ||
const async = require("async"); | ||
const glob = require("glob"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are arguably more correct though, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean the old requires, or the new imports? (Some of the scripts already used imports; I have these changes also on my module transform branch too.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(The output code is the same; with the imports, we generate const fs = require("fs")
exactly)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant the old require
s since those correspond to these being true CommonJS require calls anyway. It probably doesn't matter, so long as glob
doesn't get called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, are you suggesting import glob from "glob"
? I can do that, so long as we enable esModuleInterop
. I opted to not change the tsconfig settings since import *
seem to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right so that's the thing - import
/require
allows us to not worry about interop at all because we get to just say "yeah, the thing Node actually does with CJS.
The alternative is to swap to ESM scripts which I am actually open to as well for dog-fooding purposes. But maybe do that as a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is actually the next step I wanted to take, but I wanted to get them to type check first.
I'm missing something - why are we changing import styles? |
When I open say,
Technically, this is because the files are not included in the scripts project, so are getting some unspecified config. Fixing I can totally undo the import changes and just leave the |
I think as long as they type check and run, it doesn’t matter that much, but for my 2 cents, I think it’s strange to have ESM- and CJS-style imports in the same file, which is what we have before the change. I am totally on board with Daniel’s assessment that the requires are technically “more correct” but only if we also replace all the |
That's next up; DT is already mjs (woo) |
Don't block on me - I didn't read it carefully, but I have no objections. |
All good, I was busy with something else and just hadn't yet hit the button. |
While working on a new lint rule, I noticed that a lot of the scripts have errors when I open them in the editor for various reasons, be it improper imports, type errors, etc.
Fix everything up and ensure any .ts files are included in this project, so we see their errors at build time.
There are a couple of the scripts that are written in
js
directly, so have handwrittend.ts
files for them. I don't like that, but I think there must be some external callers (I see VSTS mentioned) that rely on being able to run the project without being compiled, it seems, so I won't change the status quo there quite yet.