jupyter / jupyter/nbformat

nbformat Typescript type definitions

Open
#146 3 comments 2 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
313
Forks
176
PR merge metrics
No merged PRs in 30d

Description

Hi :wave:

> Originally, posted at https://discourse.jupyter.org/t/nbformat-typescript-type-definitions/1935, but posting here in case there more (>0) interest

We've generated Typescript type definitions for `nbformat` JSON Schema versions 3 and 4 using `json-schema-to-typescript` e.g.

- https://github.com/stencila/encoda/blob/384250a09102d77983a96e63e258a008016dda4b/src/codecs/ipynb/nbformat-v4.d.ts

Previously we were using the type definitions already available in `@jupyterlab/coreutils`:

- https://github.com/jupyterlab/jupyterlab/blob/3592afd328116a588e3307b4cdd9bcabc7fe92bb/packages/coreutils/src/nbformat.ts

However, we found we had to use a couple of workarounds because those manually coded definitions differ from the JSON schema in some places (e.g. `orig_nbformat` is required) and due to the dependence on `@phosphor/coreutils` (which I can't recall the details of). Also we wanted to have Typescript definitions for `v3` which do not appear to be available anywhere else.

In our use case, we are using the `nbformat` JSON Schema definitions anyway (to validate both incoming notebooks prior to decoding, and outgoing notebooks after encoding). So, it makes sense to use Typescript definitions generated from those schemas. We have used `json-schema-to-typescript` elsewhere and have been pleased with the type definitions it produces.

I was wondering if there is any interest in making these Typescript type definitions more generally available by submitting them to https://definitelytyped.org. They would then be available via `npm install @types/jupyter` or similar. I'd be happy to help out with, or lead, a PR towards that, but also understand if someone else more involved in Jupyter development would prefer to take it over.

Contributor guide

Open the contributing guide

Research direction

Start by comparing the nbformat v3 and v4 schemas with the generated src/codecs/ipynb/nbformat-v4.d.ts file and JupyterLab's packages/coreutils/src/nbformat.ts definitions. Clarify whether the requested work belongs in DefinitelyTyped or this project, then define the supported package, generation source, and review criteria before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.