-
Notifications
You must be signed in to change notification settings - Fork 1.8k
vscode extension: migrate from any to unknown where possible #2989
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
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,12 +52,12 @@ export class Ctx { | |
overrideCommand(name: string, factory: (ctx: Ctx) => Cmd) { | ||
const defaultCmd = `default:${name}`; | ||
const override = factory(this); | ||
const original = (...args: any[]) => | ||
const original = (...args: unknown[]) => | ||
vscode.commands.executeCommand(defaultCmd, ...args); | ||
try { | ||
const d = vscode.commands.registerCommand( | ||
name, | ||
async (...args: any[]) => { | ||
async (...args: unknown[]) => { | ||
if (!(await override(...args))) { | ||
return await original(...args); | ||
} | ||
|
@@ -73,11 +73,11 @@ export class Ctx { | |
} | ||
} | ||
|
||
get subscriptions(): { dispose(): any }[] { | ||
get subscriptions(): { dispose(): unknown }[] { | ||
return this.extCtx.subscriptions; | ||
} | ||
|
||
pushCleanup(d: { dispose(): any }) { | ||
pushCleanup(d: { dispose(): unknown }) { | ||
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. Similarly, this wants to be a 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. In general, yes you are right, now when I am looking at it, this seems reasonable |
||
this.extCtx.subscriptions.push(d); | ||
} | ||
|
||
|
@@ -86,12 +86,12 @@ export class Ctx { | |
} | ||
} | ||
|
||
export type Cmd = (...args: any[]) => any; | ||
export type Cmd = (...args: any[]) => unknown; | ||
|
||
export async function sendRequestWithRetry<R>( | ||
client: lc.LanguageClient, | ||
method: string, | ||
param: any, | ||
param: unknown, | ||
token?: vscode.CancellationToken, | ||
): Promise<R> { | ||
for (const delay of [2, 4, 6, 8, 10, null]) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hm, this maybe should be
=> void
, or whats the TypeScript alternative for-> ()
?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.
Also, this is just a horrible hack which needs to die in flames...
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.
Okay, let me revisit this)
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, you are right,
void
is semantically-> ()
, but not the unit type itself()
. It is quite a special language item that is meant to be used only for the function return type and denotes that the value should be discarded (also function withvoid
return type is covariant to other functions with different return type, in which wayvoid
type is different fromundefined
type).I would say that the concept of unit type the way it is present in Rust is not implemented in TypeScripts type system.