Giter Site home page Giter Site logo

Comments (4)

dbartholomae avatar dbartholomae commented on September 25, 2024 1

Thanks! I've quickly fixed it myself, as the setup with Rush currently is a bit finicky.

from lambda-middleware.

parkan avatar parkan commented on September 25, 2024

Ok, I am not quite able to make the mapped type work here, not really sure how to apply it to the type parameter on JSONObject, what I have so far is

type RequiredKeys<T> = { [k in keyof T]-?: undefined extends T[k] ? never : k }[keyof T];
type PickRequiredKeys<T> = Pick<T, RequiredKeys<T>>

but I'm not sure how to use it in the PromiseHandler signature

EDIT: ok, I am able to get unit tests to pass with

type RequiredKeys<T> = { [k in keyof T]-?: undefined extends T[k] ? never : k }[keyof T];
type PickRequiredKeys<T> = Pick<T, RequiredKeys<T>>
export const jsonSerializer = () => (
  handler: PromiseHandler<APIGatewayEvent, PickRequiredKeys<JSONObject> | undefined>

However, using a mapped type on the type bound in that signature is bending my brain a little bit so I'm not 100% sure it's correct

from lambda-middleware.

parkan avatar parkan commented on September 25, 2024

BTW thanks for being so responsive on these libraries, it seems like you're the only maintainer so I really appreciate it as it as they really fit my usecase and I'm frankly surprised they are not more widely used. This isn't strictly as "bug" as much as a limitation, but there was no better template to use. I'm happy to PR with these changes if they make sense to you, I'm still relatively new to typescript (mostly Scala background for this kind of thing) so I am not entirely sure of myself and appreciate the guidance.

from lambda-middleware.

dbartholomae avatar dbartholomae commented on September 25, 2024

It's released in version 2.1.0
https://www.npmjs.com/package/@lambda-middleware/json-serializer

from lambda-middleware.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.