chai/chai.d.ts file in this repo and had problems.chai/chai.d.ts.The bit at the end of chai.d.ts:
interface Object {
should: Chai.Assertion;
}
breaks tsx support because it thinks that all objects must have a should property (specifically, " Property 'should' is missing in type 'IntrinsicAttributes & IntrinsicClassAttributesinterface Object {
should?: Chai.Assertion;
}
This Object interface expansion also cause another bug. Typescript compiler adds
/// <reference types="chai"> to all d.ts generated based on sources containing Object. (E.g. https://github.com/angular-redux/ng2-redux/pull/209/files)
I think it is better to eliminate polution Object interface with should property and make separate version of typings for those who need should assertion syntax.
It also breaks my compilation process because I have typings for Elasticsearch Search body requests. It has an internal interface
export interface Bool {
should?: Query | Query[];
filter?: Query | Query[];
must?: Query | Query[];
must_not?: Query | Query[];
}
And when I try to build an object with
const b: Bool = { should: query }
I get a type error saying that Query and Assertion are incompatible.
I agree with @nikolaymatrosov that we should not pollute the Object interface by default and I'm going to make a PR removing that last bit.
I couldn't manage a feasible PR because I tried to make it happen in the existing @types/chai package, but now I think we should instead create an alternatives types library that is exactly the same but doesn't contain the Object declaration.
Most helpful comment
This Object interface expansion also cause another bug. Typescript compiler adds
/// <reference types="chai">to all d.ts generated based on sources containingObject. (E.g. https://github.com/angular-redux/ng2-redux/pull/209/files)I think it is better to eliminate polution Object interface with
shouldproperty and make separate version of typings for those who needshouldassertion syntax.