Encountering an issue with version 13.2.1 of the library should while compiling with TypeScript 2.7.1 on Node 8.9.1 leads to the following error:
node_modules/should/should.d.ts(237,5): error TS2717: Subsequent property
declarations must have the same type. Property 'should' must be of type
'Assertion', but here has type 'Assertion'.
Referring specifically to this line in the type definition file: https://github.com/shouldjs/should.js/blob/9748ae607f80fbf544d4bb67db8e1e014de2301f/should.d.ts#L237
An issue has been reported in the should.js github repository, indicating that this problem had previously been identified and addressed.
Error Reproducing File Simplified
A simplified version of the original file causing the error is provided below:
declare namespace should {
interface Assertion {
assert(expr: boolean): this;
fail(): this;
}
}
declare global {
interface Object {
should: should.Assertion;
}
}
export as namespace should;
export = should;
Temporary Solution
To resolve this issue, one could opt for excluding the global declaration. While this workaround satisfies a personal use-case, it may not align with the intended functionality of the library.
Query Raised
What is preventing this declaration from functioning correctly? And what alternative declaration would be considered valid in this scenario?
UPDATE
Issues with test-related dependencies might be influencing global type definitions and potentially leading to conflicts.
//{
// "devDependencies": {
// "@types/chai": "^4.1.2",
// "@types/mocha": "^2.2.48",
// "chai": "^4.0.0",
// "mocha": "^3.4.2",
// "should": "^13.2.1"
// }
//}