1.0.0 • Published 2 years ago

notion-api-types v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Notion API Types

Types for the Notion API

Version Downloads Stats Run test

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.

1.0.0

2 years ago

0.4.2

2 years ago

0.4.2-0

2 years ago

0.4.2-alpha.1

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago