-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: update dependencies #30
Conversation
@wooorm really weird that Error: [typecheck] src/index.ts(90,14): error TS2339: Property 'title' does not exist on type 'Literal & Parent'.
Error: [typecheck] src/index.ts(92,26): error TS2339: Property 'value' does not exist on type 'Content'.
[typecheck] Property 'value' does not exist on type 'Paragraph'.
Error: [typecheck] src/index.ts(92,41): error TS2339: Property 'url' does not exist on type 'Literal & Parent'.
Error: [typecheck] src/index.ts(97,14): error TS2339: Property 'url' does not exist on type 'Literal & Parent'.
Error: [typecheck] src/index.ts(163,32): error TS2339: Property 'tagName' does not exist on type 'Parent'.
Error: [typecheck] src/index.ts(164,38): error TS2339: Property 'properties' does not exist on type 'Parent'. |
a) I meant using |
Maybe you should clear cache on locally/CI first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Whoops, sometimes I approve before reading the comments or looking at CI 🤦♂️
Unfortunately GitHub actions don't have a way to clear the cache 😬 |
e51be99
to
9a4c1d9
Compare
@@ -82,19 +82,19 @@ const remarkEmbedder: Plugin<[RemarkEmbedderOptions]> = ({ | |||
} | |||
|
|||
const {children} = paragraphNode | |||
const node = children[0] as Literal & Parent | |||
const node = children[0] as Link | Text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the |
? It’s just a Link
, presumably, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L86 is checking if it's a Text
const isText = node.type === 'text'
We return early if it's not Text
or if it's an invalid link.
But that seems weird as a node can't be both text & valid link 🤔
@kentcdodds can probably give some more context about this check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we only want to find link
s but we could find just about anything as the first and only child to a paragraph. But now that I think about it, if isValidLink
is true, then isText
will always be false so we could probably remove the isText
completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, there are a bunch of utilities to narrow these types: https://github.com/ChristianMurphy/unifiedjs.github.io/blob/docs/typescript-guide-and-recipes/doc/learn/node-type-narrowing-in-typescript.md.
You can do this type safe!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But now that I think about it, if
isValidLink
is true, thenisText
will always be false so we could probably remove theisText
completely.
@kentcdodds We should keep the isText
check as we're also transforming text that's not a valid link apparently 🤔 (see https://github.com/remark-embedder/core/runs/3079154136#step:6:36)
9a4c1d9
to
3a4fcb3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Hmm... Looks like we've got some test failures. |
@kentcdodds Tests are failing because we should keep the |
Oh right, that's actually the most common use case 😅 https://astexplorer.net/#/gist/e15b6dea43f639b57bfeeb894a4a44bd/d01873eee84788877d955ad972c20500cbd2a630 Good thing we have tests for that! |
70d2440
to
3a4fcb3
Compare
@kentcdodds The GitHub caching problem is still there, but locally all is green |
3a4fcb3
to
b53b309
Compare
Let's see what happens if I just merge |
@kentcdodds Seems like there's still something wrong 😕 |
I'm actually experiencing errors on a fresh clone:
|
🎉 This PR is included in version 1.4.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
…ed by @wooorm Given that the actual code generating mdast (such as remark-parse) has used `null` instead of `undefined` for missing fields, because `null` serializes in JSON and thus makes deep-equality tests with fixtures stored in JSON easier, recognizing that it is easier to have only of either `undefined` or `null`, given that TypeScript users might due to the existing types perform a strict equality test against `undefined` and thus introduce bugs such as such as: <remark-embedder/core#30 (review)>, I propose to add `null` as another “missing” value to match the types with reality. Related to: #54547.
Fixes #29
CC/ @wooorm