-
-
Notifications
You must be signed in to change notification settings - Fork 33
typo: release lockfile #256
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,12 +108,12 @@ export async function writeFileWithLock(path: string, content: string, retry = 3 | |
| return | ||
| } | ||
|
|
||
| let relase: () => Promise<void> | undefined | ||
| let release: () => Promise<void> | undefined | ||
|
|
||
| try { | ||
| try { | ||
| // 获取文件锁 | ||
| relase = await lockfile.lock(path, { realpath: false }) | ||
| release = await lockfile.lock(path, { realpath: false }) | ||
| } | ||
| catch { | ||
| // 获取文件锁失败 | ||
|
|
@@ -125,8 +125,8 @@ export async function writeFileWithLock(path: string, content: string, retry = 3 | |
| finally { | ||
| // eslint-disable-next-line ts/ban-ts-comment | ||
| // @ts-expect-error' | ||
| if (relase) { | ||
| await relase() // 释放文件锁 | ||
| if (release) { | ||
|
Comment on lines
126
to
+128
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clean up type suppression if possible. The Consider removing the type suppression after fixing the type annotation, or at minimum fix the comment typo: - // eslint-disable-next-line ts/ban-ts-comment
- // @ts-expect-error'
if (release) {
🤖 Prompt for AI Agents |
||
| await release() // 释放文件锁 | ||
| } | ||
| } | ||
| } | ||
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.
Fix the type annotation precedence.
The type
() => Promise<void> | undefinedmeans a function that returns eitherPromise<void>orundefined. However,lockfile.lock()returns a function that always returnsPromise<void>, neverundefined. The variable itself can beundefinedbefore assignment.Apply this diff to correct the type annotation:
This change clarifies that
releaseis eitherundefinedor a function returningPromise<void>, and may eliminate the need for the@ts-expect-errordirective below.📝 Committable suggestion
🤖 Prompt for AI Agents