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

Wrong typings for echo function #658

Closed
jcubic opened this issue May 2, 2021 · 2 comments
Closed

Wrong typings for echo function #658

jcubic opened this issue May 2, 2021 · 2 comments
Labels
Bug resolved if issue is resolved, it will be open until merge with master
Milestone

Comments

@jcubic
Copy link
Owner

jcubic commented May 2, 2021

Issue summary

It seems that the typings for echo are wrong.

Expected behavior

It should accept function that only returns string, string[] or Promise

Actual behavior

it accepts to return type of promise of everything.

Here are the typings:

declare namespace JQueryTerminal {
    type echoValue = string | string[] | Element | JQuery<Element> | (() => string | string[]);
    type setEchoValueFunction = (value: TypeOrPromise<echoValue>) => void;
    type greetingsArg = ((this: JQueryTerminal, setGreeting: setEchoValueFunction) => (void | TypeOrPromise<JQueryTerminal.echoValue>)) | string | null;
}
interface JQueryTerminal<TElement = HTMLElement> extends JQuery<TElement> {
    echo<TValue = JQueryTerminal.echoValue>(arg: TypeOrPromise<TValue>, options?: JQueryTerminal.EchoOptions): JQueryTerminal;
}

You can't return the promise of jQuery Element, but this is how works according to types.

@jcubic
Copy link
Owner Author

jcubic commented May 2, 2021

it should be:

type echoValue = TypeOrPromise<string | string[] | Element | JQuery<Element>>| (() => TypeOrPromise<string | string[]>);

@jcubic
Copy link
Owner Author

jcubic commented May 2, 2021

Also maybe it should be any because of renderHandler, but maybe that will be solved by a generic echo.

@jcubic jcubic added this to the 2.24.0 milestone May 20, 2021
jcubic added a commit that referenced this issue May 20, 2021
@jcubic jcubic added Bug resolved if issue is resolved, it will be open until merge with master labels May 22, 2021
@jcubic jcubic closed this as completed May 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug resolved if issue is resolved, it will be open until merge with master
Projects
None yet
Development

No branches or pull requests

1 participant