-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
lib: type cockpit.file.read() correctly #21145
base: main
Are you sure you want to change the base?
Conversation
read() returns the content and the read tag.
@@ -247,7 +247,7 @@ declare module 'cockpit' { | |||
} | |||
|
|||
interface FileHandle<T> { | |||
read(): Promise<T>; | |||
read(callback: (data: T | null) => T, tag?: FileTag): Promise<T>; |
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.
cockpit.file().read() does not take a callback. And if it would, it'd probably be optional?
@@ -247,7 +247,7 @@ declare module 'cockpit' { | |||
} | |||
|
|||
interface FileHandle<T> { | |||
read(): Promise<T>; | |||
read(callback: (data: T | null) => T, tag?: FileTag): Promise<T>; |
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.
read
doesn't have a callback parameter. Or am I misreading the type annotations?
I wouldn't be surprised if we can't type read
correctly. It would be something like read(): Promise<T, FileTag>
, no? But Promise
probably takes only one type parameter.
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.
Oh, modify
has been annotated as : Promise<[T, FileTag]>
. Does that 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.
Yeah hmm this is all wrong :-)
read() returns the content and the read tag.