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

Compilation errors in typescript type definition? #425

Closed
Moulde opened this issue Aug 27, 2018 · 12 comments
Closed

Compilation errors in typescript type definition? #425

Moulde opened this issue Aug 27, 2018 · 12 comments

Comments

@Moulde
Copy link

Moulde commented Aug 27, 2018

Expected behavior

That everything compiles in my angular 6 application.

Actual behavior

I get the following error after upgrading from v1.12.1 to v1.21.0

ERROR in node_modules/jquery.terminal/js/jquery.terminal.d.ts(324,54): error TS2344: Type 'TElement' does not satisfy the constraint 'Node'. node_modules/jquery.terminal/js/jquery.terminal.d.ts(363,38): error TS2344: Type 'TElement' does not satisfy the constraint 'EventTarget'. node_modules/jquery.terminal/js/jquery.terminal.d.ts(364,42): error TS2344: Type 'TElement' does not satisfy the constraint 'EventTarget'. node_modules/jquery.terminal/js/jquery.terminal.d.ts(439,65): error TS2344: Type 'TElement' does not satisfy the constraint 'Node'. node_modules/jquery.terminal/js/jquery.terminal.d.ts(465,41): error TS2344: Type 'TElement' does not satisfy the constraint 'EventTarget'. node_modules/jquery.terminal/js/jquery.terminal.d.ts(467,38): error TS2344: Type 'TElement' does not satisfy the constraint 'EventTarget'. node_modules/jquery.terminal/js/jquery.terminal.d.ts(487,38): error TS2344: Type 'TElement' does not satisfy the constraint 'EventTarget'. node_modules/jquery.terminal/js/jquery.terminal.d.ts(488,42): error TS2344: Type 'TElement' does not satisfy the constraint 'EventTarget'. node_modules/jquery.terminal/js/jquery.terminal.d.ts(500,38): error TS2344: Type 'TElement' does not satisfy the constraint 'EventTarget'. node_modules/jquery.terminal/js/jquery.terminal.d.ts(501,42): error TS2344: Type 'TElement' does not satisfy the constraint 'EventTarget'.

Browser and OS

Angular CLI: 6.1.3
Node: 8.11.3
OS: darwin x64
Angular: 6.1.1

@jcubic
Copy link
Owner

jcubic commented Aug 27, 2018

which version of typescript and jquery lib and @types do you use? Do you have this project somewhere where I can check?

@Moulde
Copy link
Author

Moulde commented Aug 27, 2018

Typescript: 2.9.2
jQuery: 3.3.1

I don't have any @types for jquery.terminal installed. I get the above errors just from installing the new version of the package and importing it in my typescript file.
The project is not public, but I'll see if I can reproduce the issue in a stackblitz or new ang application.

@jcubic
Copy link
Owner

jcubic commented Aug 27, 2018

from version 1.19.0 the package include typings, maybe there is something in your code, do you use any any to make terminal work with typescript?

@jcubic
Copy link
Owner

jcubic commented Aug 27, 2018

do you have @types/jquery installed? that's required in typescript.

@jcubic
Copy link
Owner

jcubic commented Aug 27, 2018

If you have @types/jquery installed try to update it.

@Moulde
Copy link
Author

Moulde commented Aug 28, 2018

I updated the @types/jquery to the most recent version, and now everything is good. Thanks!
Now i just have to update my code to use the new types as it seems like there are some differences.
Like setting the prompt using set_prompt does now take a ExtendedPrompt instead of a string.
Do you have any usage examples?

(btw, it seems like the greetings property is missing from the TerminalOptions type?)

@Moulde Moulde closed this as completed Aug 28, 2018
jcubic added a commit that referenced this issue Aug 28, 2018
@jcubic
Copy link
Owner

jcubic commented Aug 28, 2018

prompt was a bug it should be:

type ExtendedPrompt = ((this: JQueryTerminal, setPrompt: setStringFunction) => (void | PromiseLike<string>)) | string;

I thought that | string was function or string and it was function that returns void, promise or string.

jcubic added a commit that referenced this issue Aug 28, 2018
@jcubic
Copy link
Owner

jcubic commented Aug 28, 2018

I thought that typescript d.ts file is complete but it still need work like echo value can be string, array of strings or function that return string or array and any promise that is passed to echo like the one in prompt can resolve to the same value.

so if fact this should be

type echoValue = string | string[] | (() => string | string[]);
type ExtendedPrompt = ((this: JQueryTerminal, setPrompt: setStringFunction) => (void | PromiseLike<echoValue>)) | string;

@Moulde
Copy link
Author

Moulde commented Aug 29, 2018

@jcubic So right now keeping the type definition up to date is a seperate task, which is hard to verify besides having a complete usage example to build? Is the only way to avoid this, to rewrite everything in typescript (seems like an enormous task, but would it actually? since it could start out with exactly what you have now, and then types could be added along the way. Anyway, just throwing it out there.), or is there other preferably automated way to verify the types against the library?

Anyway, I will keep this in mind and see if I can contribute to the type definitions at some point.

@jcubic
Copy link
Owner

jcubic commented Aug 29, 2018

I will add typescript as dev dependency and I will run tsc on test.ts file on build, that will be compete api usage in one file, it will not be that big, spec file (__test__ directory) that test the library will be much bigger. I think that typescript definition will be more complex then api usage.

@jcubic
Copy link
Owner

jcubic commented Sep 8, 2018

I've updated d.ts file with after adding test for all related to terminal, cmd still need testing.

@jcubic
Copy link
Owner

jcubic commented Sep 9, 2018

Version 1.22.0 with updated d.ts file just got released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants