Skip to content

Add FrozenProcessor interface to types#93

Merged
ChristianMurphy merged 2 commits intounifiedjs:mainfrom
remcohaszing:add-frozen-processor
Jul 22, 2020
Merged

Add FrozenProcessor interface to types#93
ChristianMurphy merged 2 commits intounifiedjs:mainfrom
remcohaszing:add-frozen-processor

Conversation

@remcohaszing
Copy link
Copy Markdown
Member

A frozen processor has the same interface as a regular processor, except use()
is always disallowed.

This is related to remarkjs/remark#513

A frozen processor has the same interface as a regular processor, except `use()`
is always disallowed.
@codecov-commenter

This comment has been minimized.

@ChristianMurphy ChristianMurphy added ☂️ area/types This affects typings 🦋 type/enhancement This is great to have 🧒 semver/minor This is backwards-compatible change labels Jul 20, 2020
Copy link
Copy Markdown
Member

@ChristianMurphy ChristianMurphy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, that took less changes than I expected.
Looks good, thanks @remcohaszing! 🙇

@remcohaszing
Copy link
Copy Markdown
Member Author

One note by the way. .use() does exist on frozen processors. It just always throws. Because of this I think this might be a good change, but I’m not 100% sure.

@ChristianMurphy ChristianMurphy requested a review from Rokt33r July 20, 2020 19:49
@ChristianMurphy
Copy link
Copy Markdown
Member

ChristianMurphy commented Jul 20, 2020

does exist on frozen processors. It just always throws

I think removing it from the typing is inline with the spirit of TypeScript.
For example, how TS handles objects

const a = {}

a.test
//^^^^
// Property 'test' does not exist on type '{}'.

.test throws a compile time error, even though one could access a.test and always get undefined.


edit:

we could add use with return type never in the FrozenProcessor typing https://mariusschulz.com/blog/the-never-type-in-typescript
I'm not sure it would add much benefit over not including use at all.

@remcohaszing
Copy link
Copy Markdown
Member Author

we could add use with return type never in the FrozenProcessor typing https://mariusschulz.com/blog/the-never-type-in-typescript
I'm not sure it would add much benefit over not including use at all.

I don’t think this adds much benefit.

@wooorm wooorm changed the title Add FrozenProcessor interface Add FrozenProcessor interface to types Jul 21, 2020
@ChristianMurphy ChristianMurphy requested a review from a team July 21, 2020 16:16
@ChristianMurphy ChristianMurphy merged commit 56fdba4 into unifiedjs:main Jul 22, 2020
@wooorm
Copy link
Copy Markdown
Member

wooorm commented Jul 23, 2020

Released in 9.1.0!

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

Labels

☂️ area/types This affects typings 💪 phase/solved Post is done 🧒 semver/minor This is backwards-compatible change 🦋 type/enhancement This is great to have

Development

Successfully merging this pull request may close these issues.

5 participants