Notion API Types
Types for the Notion API
This package defines types for the Notion API responses.
It contains only *.d.ts
files, so it won't increase the size of a compressed package.
Installation
Yarn:
yarn add --D notion-api-types
Usage
This module is built so you can import from the directories in it. You can import the top namespaces, but it will make for long code.
import type { Page, PageProperty } from 'notion-api-types/responses'
Throughout the module, namespaces will have plural names and types will be singular.
import type { Page, PageProperty, PageProperties } from 'notion-api-types/responses'
const page: Page = { ... }
const props: PageProperty[] = Object.values(page.properties)
let title: PageProperties.Title
for (const prop of props)
if (prop.type == 'title') title = prop
If the property type is already known use type assertions.
import type { Page, PageProperties } from 'notion-api-types/response'
const page: Page = { ... }
const title = page.properties.Title as PageProperties.Title
Using import type will keep the module from increase the size of your compiled javascript.