Skip to content

feat: 🎸 add types from DT#214

Closed
damusix wants to merge 1 commit intohapijs:masterfrom
damusix:master
Closed

feat: 🎸 add types from DT#214
damusix wants to merge 1 commit intohapijs:masterfrom
damusix:master

Conversation

@damusix
Copy link
Copy Markdown
Contributor

@damusix damusix commented May 28, 2023

Everything is the same as the DT typings, save for the fact that I removed the namespace vision wrapper since it's locally scoped now. These are the only exceptions:

Additions:

I added some interfaces to be able to type out the templates and layouts that exist. I usually end up overriding these myself anyway so I figured it'd be neat to expose that functionality. Look for InViewTypesOr<T> within the types.

I made RenderMethod an exportable interface, along with RequestRenderMethod (request decoration), and ToolkitRenderMethod. This is for the purpose of overloading them to include custom template/context configurations, which I normally do for views that have a hard requirement on context data types.

I added documentation to the bottom of API.md. Please review and let me know if this is OK!

Fixes

const serverRoute = {
    ...
    handler(req) { 

        // Property 'engines' is missing in type '{ layout: "admin"; }' but required in type 'ServerViewsConfiguration'.
        return req.render('test', null, { layout: 'admin' }); 
    } 
}

The function request.render(...) would yell whenever I'd try to define a layout because it wanted an { engines } key. I assumed this was an error, since it is in the request lifecycle, and replaced it with ViewHandlerOrReplyOptions.

Copy link
Copy Markdown
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.

Same comment as the other PR, it needs to be included in lab's test suite.

@damusix
Copy link
Copy Markdown
Contributor Author

damusix commented Jun 15, 2023

Same comment as the other PR, it needs to be included in lab's test suite.

@Marsup Not sure I follow what this means? I don't see much of a difference between this one and the other.

Marsup pushed a commit that referenced this pull request Aug 4, 2023
Marsup pushed a commit that referenced this pull request Aug 4, 2023
Marsup added a commit that referenced this pull request Aug 4, 2023
Ported from #214.
Fixes #216.

Co-authored-by: Danilo Alonso <damusix@gmail.com>
@Marsup
Copy link
Copy Markdown
Contributor

Marsup commented Aug 4, 2023

Superseded by #217.

@Marsup Marsup closed this Aug 4, 2023
@Marsup Marsup added this to the 7.0.3 milestone Aug 4, 2023
@Marsup Marsup self-assigned this Aug 4, 2023
@Marsup Marsup added the types TypeScript type definitions label Aug 4, 2023
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.

2 participants