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.

Question about new typings

See original GitHub issue

I see that the individual block types have been removed and replaced with a large generic union on the responses of some queries.

for example (have removed some properties for clarity):

ListBlockChildrenResponse["results"] = Array<
           {
              type: "paragraph";
              ...stuff
             } | { 
              type: "heading_1";
             ...stuff

... and so on

So a Block I guess can now be represented by:

export type Block = ListBlockChildrenResponse["results"][0]

The same goes for the Database type

export type Database = QueryDatabaseResponse["results"][0]

But when I have a database that has properties on it like “Name” or “Slug”, how do I correctly extend the properties type so that its possible to access it without TS complaining, before I could do something like:

const name = (database.properties.Name as TitlePropertyValue).title[0].plain_text

But now that the TitlePropertyValue type doesn’t exist, not really sure to handle the custom properties?

Any ideas?

Thanks

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

28reactions
peetjvvcommented, Oct 22, 2021

I’m also finding the removal/change of these types frustrating. Was really nice to just be able to import them directly.

14reactions
ghostcommented, Nov 4, 2021

This made the client much much harder to work with when using typescript. Also the type hints that you get from visual code etc is more or less unreadable 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

15 Typing Interview Questions and Answers - CLIMB
15 Typing Interview Questions and Answers · 1. What is type hinting? · 2. What's the difference between an abstract class and a...
Read more >
The Most Frequently Asked Questions About Typing.com
Typing.com is a clear, engaging, step-by-step curriculum that you can customize. Here are FAQs on how to set up your account.
Read more >
TypeScript typings for a class which is new-able and callable
I'm currently editing the typings for Duplexify. As you can see in Duplexify's source code, Duplexify can be either be a function which...
Read more >
How do I create a Categorization question in New Quizzes?
When creating a quiz, you can create a Categorization question in New Quizzes. Categorization questions require students to place answers in the correct ......
Read more >
Twenty-four questions Google answers before you finish typing
Twenty-four questions Google answers before you finish typing. Ask (or not) and it shall be given. By David Nield | Published Feb 7, ......
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