Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add --link-type option#114

Open
justjake wants to merge 1 commit intointercom:masterfrom
makenotion:jake--link-type-option
Open

Add --link-type option#114
justjake wants to merge 1 commit intointercom:masterfrom
makenotion:jake--link-type-option

Conversation

Copy link

justjake commented Mar 15, 2022

What

This PR adds a new option --link-type LinkTypeName.

When specified, all link types emitted by the full type renderer will be wrapped in the given TypeScript type name.
It's up to the user to somehow add the given type name to the emitted code files.

Here's an example of one of our entity types, generated with --link-type=MaybeLink.

Why

At Notion, we have an annoying problem with content editors and/or automated translations systems deleting content. This leaves behind broken link references which unfortunately are generated as non-nullable by the current system.

To fix, we could add an option to always treat links as IFoo | undefined, but that's not a satisfying answer for us either -- we do want to send some kind of alert or error report whenever our code reads a link that should exist, but doesn't. If we mark everything as ... | undefined, it's really hard to remember to alert about the issue, and easy to paper over with thingy?.nullableLink?.property.

We want to do something more complicated, but it's going to be very Notion-specific. Rather than encoding a specific solution into this tool, we're going to inject a custom type name around all these links. Then, we'll prepend a type import to the generated file in our generator script, which we'll be able to adjust freely without needing any further changes to the tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant