Giter Site home page Giter Site logo

Comments (4)

blackmad avatar blackmad commented on May 17, 2024 3

from notion-sdk-js.

blackmad avatar blackmad commented on May 17, 2024

Hey Rian -

I'm not sure what you're describing would achieve the type safety we're aiming for in the library, since your function would return a bunch of property data that can no longer be type-discriminated.

You can see an example of how we imagine this being used in a type-safe way at https://github.com/makenotion/notion-sdk-js/blob/main/examples/generate-random-data/index.ts

I'm open to other suggestions!

from notion-sdk-js.

danecando avatar danecando commented on May 17, 2024

I'm pretty new to TypeScript but I don't understand why this shouldn't work either. If the related key in the block is always the same name as the type, seems like I should be able to access it using the key. I get that TypeScript doesn't know that but is there not a simple way to handle this? My first instinct is that it's an issue with the structure of the objects; that they should use a common prop name to store the data.

(clearly im still in the why can't we just use js phase of my ts journey) :)

Screen Shot 2021-05-27 at 12 30 55 PM

from notion-sdk-js.

EnixCoda avatar EnixCoda commented on May 17, 2024

I had similar issues using this SDK. And attempted to solve with TS type prediction in PR #115

@RianGallagher Would you take a look at the PR and let me know your thoughts from the aspect of an user? Thank you :D

from notion-sdk-js.

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.