Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jelly
Copy link
Member

@jelly jelly commented Oct 21, 2024

read() returns the content and the read tag.

read() returns the content and the read tag.
@jelly jelly added the no-test For doc/workflow changes, or experiments which don't need a full CI run, label Oct 21, 2024
@jelly jelly requested a review from martinpitt October 21, 2024 15:27
@@ -247,7 +247,7 @@ declare module 'cockpit' {
}

interface FileHandle<T> {
read(): Promise<T>;
read(callback: (data: T | null) => T, tag?: FileTag): Promise<T>;
Copy link
Member

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>;
Copy link
Member

@mvollmer mvollmer Oct 21, 2024

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.

Copy link
Member

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?

Copy link
Member Author

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 :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-test For doc/workflow changes, or experiments which don't need a full CI run,
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants