Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Resolve some type problems #2260

Merged
merged 1 commit into from
Mar 22, 2021
Merged

Conversation

vonagam
Copy link
Member

@vonagam vonagam commented Mar 21, 2021

Continues #1566.

Don't know why types started to fail only after my changes, but i found and fixed reason for failures:

In LegacyHookFunction app property on potentially returned context was required to be of the same type as on passed in context. And because of this it was creating variance problems between simple feathers app and express wrapped app, through such forbidden chain:

(expressApp as FeathersApp).service('some').hooks({after: (context) => ({app: feathersApp, ...otherStuff})});

Since we don't care about returned context, simply relaxed type there. In turn such relaxation allowed to improve type of options in hooks method of app itself (and not on service through which the problem was exposed).

Other bonus small changes:

  • Updated ExpressUseHandler as you mentioned. I missed that one, but it was not a cause for the failings. Also created separate overload for when path is a regexp.

  • Keep ServiceTypes and AppSettings from feathers app during express wrapping.

  • In app.use | Application should be inside ternary expression, not outside.

@daffl
Copy link
Member

daffl commented Mar 22, 2021

Perfect, thank you! I was actually wondering why it was working before, too when I was looking into it. This looks great.

@daffl daffl merged commit a3d75fa into feathersjs:dove Mar 22, 2021
@vonagam vonagam deleted the fix-types-problems branch October 27, 2021 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants