question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

proper mechanism to integrate with 3rd party types

See original GitHub issue

problem

import { Bananas } from '@fruit/banana'
import * as z from 'zod'
const schema = z.object({
  apple: z.string(),
  banana: z.doSomethingWith3pType() // z.object({}) ??
})
const myType = z.infer<typeof schema> // { apple: string, banana: ???? }

what the best way to get my 3p schema in? assuming because types have been compiled away, getting my 3p schema may not be possible, but, is there a mechanism to put my type into the schema, and get it reflected back out?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
colinhackscommented, May 18, 2020

@cdaringe Just thought of a better way to do this!

const Viewport: z.ZodType<Viewport> = z.any();

const FullSchema = z.object({ url: z.string(), viewport: Viewport });

This way you can still do validations with parse as you’d expect since z.any() allows any inputs, and the type inference works as expected. 👍

1reaction
cdaringecommented, May 18, 2020

Doh! I figured I was missing something! Perfecto, thx!

Read more comments on GitHub >

github_iconTop Results From Across the Web

proper mechanism to integrate with 3rd party types #52 - GitHub
You'd have to define a class that defines these methods and delegates to the appropriate methods on your third-party schemas. If you define...
Read more >
Third-party integration — how to choose a vendor
Integrations are a part of many product managers' lives. Let's talk about how to think about integrations, and how to choose vendors.
Read more >
Best practices for using third-party embeds - web.dev
This article discusses performance best practices that you can use when loading third-party embeds, efficient loading techniques and the ...
Read more >
Extending Global or Third Party Library Typing - Malcolm Kee
Extending Global or Third Party Library Typing ... To extends global object e.g. Array , include the following code in any TypeScript file...
Read more >
How to Choose Between Different Integration Approaches
Integration leaders must understand the different types of integration-delivery approaches and ensure the right technologies and methods are used for each.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found