Skip to content

Conversation

@damusix
Copy link
Contributor

@damusix damusix commented Jul 2, 2024

also fix pre typing issue would be fixed by #4489 . Change removed.

@kanongil
Copy link
Contributor

kanongil commented Jul 2, 2024

Fix a pre typing issue? Can you elaborate? To me it reads like you created an issue with this PR.

@damusix
Copy link
Contributor Author

damusix commented Jul 2, 2024

@kanongil I like the strong typing, but for practical purposes, you can't use utilities that don't carry the same Refs.

If you run it locally, observe the type test:


        pre: [
            {
                assign: 'some',
                method: ((req) => {

                    return req.app.word;
                }) as Lifecycle.Method<RequestDecorations>
            },
            {
                assign: 'another',
                method: getNum
            }
        ]

In the current state of typings, where one is used as a utility (getNum) and the other is defined in the object. When we define pre[].method() to take a Refs generic, it wants all pres to take the same Refs generic, or else it errors.

If you have other ideas, that'd be great, cause I agree that this is sub-optimal.

@damusix damusix force-pushed the fix/method-types branch from 90bea73 to e63d51e Compare July 29, 2024 19:13
also fix pre typing issue

fix: 🐛 reflect reality of Hapi methods in types
@damusix
Copy link
Contributor Author

damusix commented Jan 17, 2025

@Marsup @kanongil updated commit without any references to pres. Ready for release.

Copy link
Contributor

@Marsup Marsup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fixing formatting issues

@Marsup Marsup added the types TypeScript type definitions label Mar 5, 2025
@Marsup Marsup self-assigned this Mar 5, 2025
@Marsup Marsup added this to the 21.4.0 milestone Mar 5, 2025
@Marsup Marsup merged commit 45c7255 into hapijs:master Mar 5, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

types TypeScript type definitions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants