Skip to content

TSC2417 - Incorrectly extending other class (which is not the case) #18643

Closed
@rdnscr

Description

@rdnscr

TypeScript Version: 2.5.2

Code

@Injectable()
export class DefaultExceptionHandler extends ErrorHandler {

  constructor(protected notificationService: NotificationService) {
    super(false); // no rethrow of errors
  }
....
}

@Injectable()
export class MyExceptionHandler extends DefaultExceptionHandler {

  constructor(@Inject(dispatcher) private dispatcher: Subject<Action>, notificationService: NotificationService) {
    super(notificationService);
  }
....
}

Expected behavior:
This should work since it is inheritance as it is intended. It shoud be possible to have different constructor parameters to the class i extend from.

This example was working with Typescript 2.4.2 and with TypeScript 2.5.2 it is broken.

Actual behavior:

ERROR in [at-loader] ./src/app/common/services/my-exception-handler.service.ts:7:14
    TS2417: Class static side 'typeof MyExceptionHandler' incorrectly extends base class static side 'typeof DefaultExceptionHandler'.
  Types of property 'ctorParameters' are incompatible.
    Type '() => ({ type: typeof Subject; decorators: { type: InjectDecorator; args: OpaqueToken[]; }[]; } |...' is not assignable to type '() => { typ
e: typeof NotificationService; }[]'.
      Type '({ type: typeof Subject; decorators: { type: InjectDecorator; args: OpaqueToken[]; }[]; } | { typ...' is not assignable to type '{ type: t
ypeof NotificationService; }[]'.
        Type '{ type: typeof Subject; decorators: { type: InjectDecorator; args: OpaqueToken[]; }[]; } | { type...' is not assignable to type '{ type:
 typeof NotificationService; }'.
          Type '{ type: typeof Subject; decorators: { type: InjectDecorator; args: OpaqueToken[]; }[]; }' is not assignable to type '{ type: typeof No
tificationService; }'.
            Types of property 'type' are incompatible.
              Type 'typeof Subject' is not assignable to type 'typeof NotificationService'.
                Property 'ctorParameters' is missing in type 'typeof Subject'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs More InfoThe issue still hasn't been fully clarified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions