Skip to content

Mixin: Type "{}" used in example but eslint fails with an error #2019

@HeikoStudt

Description

@HeikoStudt

On the handbook page on Mixins (https://www.typescriptlang.org/docs/handbook/mixins.html) you have the following typescript code as an example:

      type Constructor = new (...args: any[]) => {};

According to Default-Rules of eslint, this is an ERROR: Don't use {} as a type. {} actually means "any non-nullish value". In my view, eslint is right - the mixin will return an object and never something like a number.
(https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/ban-types.md)

It should probably be rewritten like this:

      type Constructor = new (...args: any[]) => Record<string,any>; 

MFG (kind regards)

Metadata

Metadata

Assignees

No one assigned

    Labels

    You Can Do ThisA ticket which has been greenlighted as will be acceptedbugdocumentationChanges only affect the documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions