DefinitelyTyped / DefinitelyTyped

The repository for high quality TypeScript type definitions.
Other
48.54k stars 30.16k forks source link

chai definitions break tsx #9120

Closed arolson101 closed 3 years ago

arolson101 commented 8 years ago

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 & IntrinsicClassAttributes<Component<..."). It should be:

interface Object {
    should?: Chai.Assertion;
}
nikolaymatrosov commented 8 years ago

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.

villasv commented 5 years ago

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.

villasv commented 5 years ago

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.

villasv commented 4 years ago

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.

bevacqua commented 4 years ago

Related issue https://github.com/DefinitelyTyped/DefinitelyTyped/issues/43744

orta commented 3 years ago

Hi thread, we're moving DefinitelyTyped to use GitHub Discussions for conversations the @types modules in DefinitelyTyped.

To help with the transition, we're closing all issues which haven't had activity in the last 6 months, which includes this issue. If you think closing this issue is a mistake, please pop into the TypeScript Community Discord and mention the issue in the definitely-typed channel.