Question about new typings
See original GitHub issueI 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:
- Created 2 years ago
- Reactions:7
- Comments:19 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m also finding the removal/change of these types frustrating. Was really nice to just be able to import them directly.
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 😕