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

TypeScript definition #61

Closed
nya1 opened this issue Apr 4, 2020 · 7 comments
Closed

TypeScript definition #61

nya1 opened this issue Apr 4, 2020 · 7 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@nya1
Copy link

nya1 commented Apr 4, 2020

Hello,
I would like to use this module in my typescript project but currently is missing the extended chai methods such as satisfySchemaInApiSpec, it would be nice to have the typescript definition

@nya1 nya1 added the enhancement New feature or request label Apr 4, 2020
@rwalle61
Copy link
Collaborator

rwalle61 commented Apr 4, 2020

Thanks for raising this! I have wanted to support Typescript features for a while but not had time to implement it, especially as I’m fairly new to Typescript.

To clarify:

  • are you unable to use this module at all in your Typescript project, because we are missing some type definitions?
  • What is the minimum change needed for this module to work in your project? Is it to add some types like for the standard chai assertions https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/chai/v2/index.d.ts ?
  • what are the Typescript changes you would like to see to this module, after that first step?

@nya1
Copy link
Author

nya1 commented Apr 5, 2020

are you unable to use this module at all in your Typescript project, because we are missing some type definitions?

I'm able to use this module but I need some workarounds to not have type errors

What is the minimum change needed for this module to work in your project? Is it to add some types like for the standard chai assertions https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/chai/v2/index.d.ts ?

what are the Typescript changes you would like to see to this module, after that first step?

Yes I think is the only thing needed to make it work properly

Other examples are:

@rwalle61
Copy link
Collaborator

rwalle61 commented Apr 5, 2020

Glad you can still run this module, albeit with some workarounds.

Thanks for the examples, sounds like a good change.

I'm currently fixing another bug (issue 54) but will look into this when I have time. Happy to take a PR earlier if you fancy it

@rwalle61
Copy link
Collaborator

rwalle61 commented Apr 7, 2020

@nya1 would you like to pull that branch to check it solves your issue?

Would also appreciate suggestions to improve the Declaration File and README, as I'm not sure what a TypeScript user would like to see.

@nya1
Copy link
Author

nya1 commented Apr 8, 2020

I'll give a try this weekend, it looks good, maybe I think the return type Assertion can be replaced with void because in your JS code you cannot chain other chai methods to satisfyApiSpec & satisfySchemaInApiSpec methods

@rwalle61
Copy link
Collaborator

rwalle61 commented Apr 8, 2020

Thanks!

Re chaining other chai methods, I seem to be able to - these are hitting the foo assertions

expect(res).to.satisfyApiSpec.and.to.equal('foo');
expect(obj).to.satisfySchemaInApiSpec(schemaName).and.to.equal('foo');

(Not that I would recommend chaining after either of our assertions)

@rwalle61 rwalle61 added the help wanted Extra attention is needed label Apr 8, 2020
@rwalle61 rwalle61 mentioned this issue Apr 13, 2020
@rwalle61
Copy link
Collaborator

Thanks for checking the Declaration File works. I've released it in 0.8.0 so feel free to close this when you're happy.

0.8.0 also makes the assertion failure messages much more informative, so any feedback (especially problems) with that will be appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants