-
Notifications
You must be signed in to change notification settings - Fork 3.4k
chore: convert additional server files to TypeScript #32950
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
0d1dd13 to
f262fa7
Compare
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.
Bug: Silent Encoding Failure in `readJson` Calls
The fs.readJsonAsync call passes 'utf8' as a second parameter, but fs-extra's readJson/readJsonSync methods only accept an options object as the second parameter, not an encoding string. This will cause the encoding to be ignored or potentially throw an error. The original code had a @ts-expect-error comment acknowledging this type mismatch, which was removed during the TypeScript conversion without fixing the underlying issue.
packages/server/lib/util/file.ts#L161-L162
cypress/packages/server/lib/util/file.ts
Lines 161 to 162 in 32aa387
| return fs.readJsonAsync(this.path, 'utf8') |
32aa387 to
1fea56c
Compare
0d5411e to
1fd4bad
Compare
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.
Bug: `readJsonAsync` Parameter Type Mismatch
The fs.readJsonAsync call passes 'utf8' as a second parameter, but fs-extra's readJson method expects an options object, not a direct encoding string. When promisified by Bluebird, readJsonAsync should be called as fs.readJsonAsync(this.path, { encoding: 'utf8' }) or simply fs.readJsonAsync(this.path) since utf8 is the default encoding. This will cause the method to fail or behave unexpectedly.
packages/server/lib/util/file.ts#L161-L162
cypress/packages/server/lib/util/file.ts
Lines 161 to 162 in 03ffbf0
| return fs.readJsonAsync(this.path, 'utf8') |
0989d19 to
7db621a
Compare
jennifer-shehane
left a comment
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.
A few comments, fine to merge
packages/server/lib/fixture.ts
Outdated
| // @ts-expect-error | ||
| err.code = 'ENOENT' |
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.
comment on this expect-error?
convert fixture file to TS fix types remove only
7db621a to
0625ed6
Compare
Additional details
Converts files, fixtures, resolve, status_code, system, and a few other files to TypeScript
Steps to test
How has the user experience changed?
PR Tasks
cypress-documentation?type definitions?Note
Converts several server modules to TypeScript, updates imports/usages and typings across the codebase, and adjusts tests/snapshots accordingly.
lib/files,lib/fixture,lib/util/{resolve,status_code,system,terminal,tty}to TypeScript with async/await and explicit typings.lib/util/{terminal,tty,status_code}and update call sites (e.g.,server-base,print-run,start-cypress).fs.readJsonAsyncand use infiles/util/file.* as system/* as filesandfixture.getinxhrs,socket-base,privileged-commands-manager,modes/run,project-base,server-base.BufferEncoding,HorizontalAlignment, Bluebird timeout types, and selective@ts-expect-errorannotations.files_spec,fixture_spec,status_code_spec,terminal_spec,tty_spec) and update snapshots.NODE_OPTIONS=--import tsxfor TypeScript config loading.Written by Cursor Bugbot for commit 0625ed6. This will update automatically on new commits. Configure here.