Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Typings for custom assertions #174

Open
dominicbartl opened this issue May 2, 2018 · 2 comments
Open

Typings for custom assertions #174

dominicbartl opened this issue May 2, 2018 · 2 comments

Comments

@dominicbartl
Copy link

Hi.

Node.js version?

8.11.1

Should.js version?

13.2.1

How to reproduce it?

When using shouldjs with Typescript and extending the should Assertions with a custom function:
Lets say:

Assertion.add('asset', function() {
     this.params = { operator: 'to be asset' }

     this.obj.should.have.property('id').which.is.a.Number()
     this.obj.should.have.property('path')
})

Compiling Typescript will throw an error when using the should(obj).asset() function because it doesn't exist on the type Assertion. Simplest solution would by adding the following to the Assertion interface to allow dynamic properties:

[key: string]: any;
@btd
Copy link
Member

btd commented May 3, 2018

I do not think this is a right idea. If i add such entry to typings it will be possible to call any sort of method. Even that does not exists.

@dominicbartl
Copy link
Author

@btd totally agree. This is just the first idea I came up with to keep the standard assertions and allow custom ones as well

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

No branches or pull requests

2 participants