loopbackio / loopbackio/loopback-next

Can't override app.start if RepositoryMixin used: TS2425

Open
#8,079 3 comments 0 reactions 1 assignee View on GitHub

@achrinza is already working on this.

Since Nov 19, 2021.

bug
Dominant language
TypeScript
Stars
5.1k
Forks
1.1k
Avg merge
2d 21h
Merged PRs (30d)
27

Description

Steps to reproduce

  1. Create an app that uses RepositoryMixin
  2. Try to override the application start method

Current Behavior

error TS2425: Class '... & RestApplication' defines instance member property 'start', but extended class 'Application' defines it as instance member function.

Expected Behavior

It should compile!

It used to compile just fine in older releases.

Link to reproduction sandbox

  1. clone https://github.com/mgabeler-lee-6rs/lb4-bugs
  2. run npm run build

Additional information

Playing around with the mixins:

  • BootMixin(RestApplication) -- OK
    • BootMixin re-declares the start member
  • BootMixin(RepositoryMixin(RestApplication)) -- fails
  • RepositoryMixin(BootMixin(RestApplication)) -- fails

Looking through the history of repository.mixin.ts, the only thing I see that I could point to as a probable cause for this is https://github.com/loopbackio/loopback-next/pull/5394/files#diff-11574932d711bedee7d0693e1b5f50ebfd143a78cc62e36bb31ea5e0e711140c

Overriding application.start is "documented as OK" if you will, insofar as the hello-world example uses it almost exactly the way my repro does, the difference being that hello-world doesn't have the repos mixin: https://github.com/loopbackio/loopback-next/blob/master/examples/hello-world/src/application.ts#L23

Related Issues

Nothing found yet

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.