Skip to content
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

Merged
merged 1 commit into from
Jul 16, 2021
Merged

fix: update dependencies #30

merged 1 commit into from
Jul 16, 2021

Conversation

MichaelDeBoey
Copy link
Member

@MichaelDeBoey MichaelDeBoey commented Jul 15, 2021

Fixes #29


CC/ @wooorm

@MichaelDeBoey MichaelDeBoey added the dependencies Pull requests that update a dependency file label Jul 15, 2021
@MichaelDeBoey MichaelDeBoey self-assigned this Jul 15, 2021
@MichaelDeBoey
Copy link
Member Author

@wooorm really weird that @types/mdast is working locally, but not in CI 🤔

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'.

@wooorm
Copy link

wooorm commented Jul 15, 2021

a) I meant using @types/mdast instead of @types/unist. To use specific nodes, like Link for links
b) maybe rm -rf node_modules locally and reinstalling will surface the problems

@JounQin
Copy link

JounQin commented Jul 15, 2021

Maybe you should clear cache on locally/CI first.

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

👍

@kentcdodds
Copy link
Member

Whoops, sometimes I approve before reading the comments or looking at CI 🤦‍♂️

Maybe you should clear cache on locally/CI first.

Unfortunately GitHub actions don't have a way to clear the cache 😬

src/index.ts Outdated Show resolved Hide resolved
@@ -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
Copy link

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?

Copy link
Member Author

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

Copy link
Member

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 links 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.

Copy link

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!

Copy link
Member Author

@MichaelDeBoey MichaelDeBoey Jul 15, 2021

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, then isText will always be false so we could probably remove the isText 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)

src/index.ts Outdated Show resolved Hide resolved
Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@kentcdodds
Copy link
Member

Hmm... Looks like we've got some test failures.

@MichaelDeBoey
Copy link
Member Author

@kentcdodds Tests are failing because 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)

@kentcdodds
Copy link
Member

Oh right, that's actually the most common use case 😅 https://astexplorer.net/#/gist/e15b6dea43f639b57bfeeb894a4a44bd/d01873eee84788877d955ad972c20500cbd2a630

Good thing we have tests for that!

@MichaelDeBoey
Copy link
Member Author

MichaelDeBoey commented Jul 16, 2021

@kentcdodds The GitHub caching problem is still there, but locally all is green
Schermafbeelding 2021-07-16 om 15 56 54

@kentcdodds
Copy link
Member

Let's see what happens if I just merge

@kentcdodds kentcdodds merged commit 9c8ae04 into main Jul 16, 2021
@kentcdodds kentcdodds deleted the update-dependencies branch July 16, 2021 14:38
@MichaelDeBoey
Copy link
Member Author

@kentcdodds Seems like there's still something wrong 😕
https://github.com/remark-embedder/core/runs/3087181241

@kentcdodds
Copy link
Member

I'm actually experiencing errors on a fresh clone:

~/Desktop 🦍
$ git clone https://github.com/remark-embedder/core.git
Cloning into 'core'...
remote: Enumerating objects: 186, done.
remote: Counting objects: 100% (63/63), done.
remote: Compressing objects: 100% (48/48), done.
remote: Total 186 (delta 30), reused 26 (delta 10), pack-reused 123
Receiving objects: 100% (186/186), 65.03 KiB | 924.00 KiB/s, done.
Resolving deltas: 100% (92/92), done.
~/Desktop 🦍
$ cd core 
~/Desktop/core (main) 🦍
$ npm run setup
running command with prefix "setup"

> @remark-embedder/core@0.0.0-semantically-released setup
> npm install && npm run validate -s

npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated object-keys@0.2.0: Please update to the latest object-keys
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated

added 1189 packages, and audited 1190 packages in 20s

165 packages are looking for funding
  run `npm fund` for details

12 vulnerabilities (6 moderate, 6 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
[build] Successfully compiled 1 file with Babel (645ms).
[build] Generating TypeScript definitions
[typecheck] src/index.ts(92,26): error TS2339: Property 'value' does not exist on type 'StaticPhrasingContent'.
[typecheck]   Property 'value' does not exist on type 'Emphasis'.
[typecheck] src/index.ts(97,19): error TS2339: Property 'value' does not exist on type 'Link'.
[typecheck] src/index.ts(163,32): error TS2339: Property 'tagName' does not exist on type 'Parent'.
[typecheck] src/index.ts(164,38): error TS2339: Property 'properties' does not exist on type 'Parent'.
[typecheck] npm run typecheck --silent exited with code 1
--> Sending SIGTERM to other processes..
[test] npm run test --silent -- --coverage exited with code SIGTERM
--> Sending SIGTERM to other processes..
[build] npm run build --silent exited with code SIGTERM
--> Sending SIGTERM to other processes..
[lint] npm run lint --silent exited with code SIGTERM
NPM command npm run setup -- failed with code 1

@MichaelDeBoey MichaelDeBoey mentioned this pull request Jul 17, 2021
@github-actions
Copy link

🎉 This PR is included in version 1.4.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

typescript-bot pushed a commit to DefinitelyTyped/DefinitelyTyped that referenced this pull request Aug 19, 2021
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI is failing because of updated unist types
4 participants