graphql-js icon indicating copy to clipboard operation
graphql-js copied to clipboard

Use a type-safe way is differentiating ExecutionResult from Array<Error>

Open matthargett opened this issue 3 years ago • 6 comments

Motivation

Checking a string key on an array is not valid, correctly yielding a warning on a TS branch I'm playing in. Narrow the type with Array.isArray instead.

Performance

Running yarn benchmark (which is amazing, btw) on my 2019 MacBook Pro running macOS 12.4 and node 18.2.0, I see a few slight increases and slight decreases of my local vs HEAD. I exited all other user processes on the system, but there was still some slight variability from run to run regardless.

Here's a screenshot of the run, let me know if I need to dive into CPU profiler data to find another type-safe alternative that's cheaper at runtime. image

matthargett avatar Jun 17 '22 04:06 matthargett

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: matthargett / name: Matt Hargett (b76e38cd434431aa2e8b72f607fec8ac25af37d5)

Deploy Preview for compassionate-pike-271cb3 ready!

Name Link
Latest commit f488b12f65c8f927331b4fb2181356989e2cc4a3
Latest deploy log https://app.netlify.com/sites/compassionate-pike-271cb3/deploys/62ac0db1352f460008f7597e
Deploy Preview https://deploy-preview-3649--compassionate-pike-271cb3.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Jun 17 '22 04:06 netlify[bot]

Checks failing because lockfile does not match, our ci requires you to update this yourself and then we check to make sure it matches.

Putting together your typescript version changes and your proposed code change, it sounds like you are saying that on newest version of typescript, we get a warning on our explicit property check?

It could be the simplest thing is to just disable the warning for that line.

yaacovCR avatar Jun 17 '22 06:06 yaacovCR

Could be also that this is not secondary to the version change and just a different tsconfig in your project? I skimmed the TS 4.7 release notes and didn't note anything at first glance.

yaacovCR avatar Jun 17 '22 06:06 yaacovCR

@github-actions run-benchmark

saihaj avatar Jun 17 '22 13:06 saihaj

@github-actions run-benchmark

@saihaj Something went wrong, please check log.

github-actions[bot] avatar Jun 17 '22 13:06 github-actions[bot]

Superseded by #3670

matthargett avatar Sep 19 '23 22:09 matthargett