profile
viewpoint
Tom Crockett pelotom Tuple Health Los Angeles, CA https://twitter.com/pelotom I like turtles

frenic/csstype 625

Strict TypeScript and Flow types for style based on MDN data

pelotom/effectful 171

A syntax for type-safe effectful computations in Scala

pelotom/burrido 143

Do-notation for JavaScript

pelotom/definitely 5

Disallow undefined property access in JavaScript

frenic/DefinitelyTyped 0

The repository for high quality TypeScript type definitions.

pelotom/active-enzyme 0

Boilerplate-free Enzyme testing

pelotom/adv-r 0

Advanced R programming: a book

pelotom/autobind-decorator 0

Decorator to automatically bind methods to class instances

pelotom/better-sqlite3 0

The fastest and simplest library for SQLite3 in Node.js.

delete branch pelotom/DefinitelyTyped

delete branch : patch-12

delete time in 9 days

PR closed DefinitelyTyped/DefinitelyTyped

Reviewers
Give PropsWithChildren a default type parameter Critical package Merge:Auto Owner Approved Perf: Same Revision needed Untested Change

It's convenient to be able to use this auxiliary type in one's own code like so:

function MyComponent({ children }: PropsWithChildren) {
  return ...
}

without having to append <{}> to PropsWithChildren.

Please fill in this template.

  • [x] Use a meaningful title for the pull request. Include the name of the package modified.
  • [x] Test the change in your own code. (Compile and run.)
  • [x] Add or edit tests to reflect the change. (Run with npm test.)
  • [x] Follow the advice from the readme.
  • [x] Avoid common mistakes.
  • [x] Run npm run lint package-name (or tsc if no tslint.json is present).

Select one of these and delete the others:

If changing an existing definition:

  • [ ] Provide a URL to documentation or source code which provides context for the suggested changes: <<url here>>
  • [ ] If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the header.
  • [ ] Include tests for your changes
  • [ ] If you are making substantial changes, consider adding a tslint.json containing { "extends": "dtslint/dt.json" }. If for reason the any rule need to be disabled, disable it for that line using // tslint:disable-next-line [ruleName] and not for whole package so that the need for disabling can be reviewed.
+1 -1

12 comments

1 changed file

pelotom

pr closed time in 9 days

pull request commentDefinitelyTyped/DefinitelyTyped

Give PropsWithChildren a default type parameter

I gave you my use case. I refuted the stupid “empty props are not props” argument. The idea that adding a default type parameter hurts readability in any way is absurd on its face. There are plenty of defaulted type parameters throughout the typings already and nobody is complaining about them making the code unreadable. Sorry for the “drive-by PR”, whatever that means. I guess PRs have to make lots of changes to be worthy of consideration?

pelotom

comment created time in 9 days

pull request commentDefinitelyTyped/DefinitelyTyped

Give PropsWithChildren a default type parameter

Any chance this can get merged?

pelotom

comment created time in 9 days

startedopenai/gpt-3

started time in 11 days

pull request commentJoshuaWise/better-sqlite3

Fix monkey patching bug + memory leak when running in Jest

@radiantly I've published a copy of the library with this patch here.

pelotom

comment created time in 12 days

startedhwayne/awesome-cold-showers

started time in 15 days

issue commentfacebook/jest

Very poor performance on basic tests

The main startup delay seems to come from require()-ing all the dependencies.

time-require reports around 10 seconds worth of require() calls on my current system.

Main culprits, according to that tool are:

  • babel - this might just be specific to my setup (@babel/preset-env takes 3.6 seconds)
  • jsdom - 1.2 seconds in isolation
  • sane - 0.5 seconds in isolation, most of which is caused by micromatch 3.

For JSDOM, there is already some work for cutting down dependencies and thus improving load times. They also have an active issue regarding request, which takes my machine .25 seconds to load.

An actionable item for the jest team might be replacing sane.

This right here is the issue ☝️

I really, really wish Jest would provide an option not to reload the entire module tree on every single test suite. We write our code in a mostly pure style and do not use mutable global state so it is a complete waste for us to be reloading modules every time. And it is a huge waste: a typical test suite in our code base takes 16 seconds to run, and < 1 second of that is running the actual test!

cozmy

comment created time in 16 days

startedsindresorhus/css-in-readme-like-wat

started time in 16 days

issue commentstorybookjs/storybook

Common name prefix causes rapid switching between stories on load

Sure: https://github.com/pelotom/storybook-bug-11571

pelotom

comment created time in 18 days

push eventpelotom/storybook-bug-11571

Tom Crockett

commit sha 1eca6a514adaf1c696a611f4878a32061a19859e

Update README.md

view details

push time in 18 days

create barnchpelotom/storybook-bug-11571

branch : master

created branch time in 18 days

created repositorypelotom/storybook-bug-11571

created time in 18 days

issue commentstorybookjs/storybook

Common name prefix causes rapid switching between stories on load

Hi @shilman, I tried with the latest and it's still happening.

pelotom

comment created time in 18 days

issue commentstorybookjs/storybook

Common name prefix causes rapid switching between stories on load

Ping? Just want to make sure this doesn't fall thru the cracks before the release!

pelotom

comment created time in 18 days

issue commentmicrosoft/TypeScript

Shortening generic type parameter lists

@akessner something like this?

interface I<T> {
    P1: T;
}

interface C<T extends I<any>> {
    P1: T extends I<infer X> ? X : never;
    P2: T;
}

interface A {
    P1: string;
}

let v1: C<A>;
let v2: C<C<A>>;
myitcv

comment created time in 18 days

issue openedfacebookexperimental/Recoil

[TypeScript] RecoilRoot's initializeState setter signature permits any argument

For example,

export const someStringState = atom({
  key: 'someString',
  default: '',
});

const elem = <RecoilRoot initializeState={({ set }) => set(someStringState, 42)}>...</RecoilRoot>

This should be a type error because 42 is not a string, but it isn't. The setter's type is given by

type SetRecoilState = <T>(
    recoilVal: RecoilState<T>,
    newVal: T | DefaultValue | ((prevValue: T) => T | DefaultValue),
) => void;

where DefaultValue is defined as {}, which means that any values except null or undefined are allowed. I'm not sure what the purpose of DefaultValue is here, but it's causing type safety to be lost.

created time in 22 days

issue commentfacebookexperimental/Recoil

Why doesn’t Recoil manage the unique key in atom and selector

I think the issue here is that many of us don't care about persisting our recoil state. For that use case there's really no need for us as users to think about these unique ID's, they're just a footgun.

mdovn

comment created time in 22 days

push eventpelotom/runtypes

dependabot[bot]

commit sha 69b8724302ebe780270ded2b7cb94e24f3259e70

Bump lodash from 4.17.15 to 4.17.19 (#156) Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

view details

push time in 23 days

PR merged pelotom/runtypes

Bump lodash from 4.17.15 to 4.17.19 dependencies

Bumps lodash from 4.17.15 to 4.17.19. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/lodash/lodash/releases">lodash's releases</a>.</em></p> <blockquote> <h2>4.17.16</h2> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/lodash/lodash/commit/d7fbc52ee0466a6d248f047b5d5c3e6d1e099056"><code>d7fbc52</code></a> Bump to v4.17.19</li> <li><a href="https://github.com/lodash/lodash/commit/2e1c0f22f425e9c013815b2cd7c2ebd51f49a8d6"><code>2e1c0f2</code></a> Add npm-package</li> <li><a href="https://github.com/lodash/lodash/commit/1b6c282299f4e0271f932b466c67f0f822aa308e"><code>1b6c282</code></a> Bump to v4.17.18</li> <li><a href="https://github.com/lodash/lodash/commit/a370ac81408de2da77a82b3c4b61a01a3b9c2fac"><code>a370ac8</code></a> Bump to v4.17.17</li> <li><a href="https://github.com/lodash/lodash/commit/1144918f3578a84fcc4986da9b806e63a6175cbb"><code>1144918</code></a> Rebuild lodash and docs</li> <li><a href="https://github.com/lodash/lodash/commit/3a3b0fd339c2109563f7e8167dc95265ed82ef3e"><code>3a3b0fd</code></a> Bump to v4.17.16</li> <li><a href="https://github.com/lodash/lodash/commit/c84fe82760fb2d3e03a63379b297a1cc1a2fce12"><code>c84fe82</code></a> fix(zipObjectDeep): prototype pollution (<a href="https://github-redirect.dependabot.com/lodash/lodash/issues/4759">#4759</a>)</li> <li><a href="https://github.com/lodash/lodash/commit/e7b28ea6cb17b4ca021e7c9d66218c8c89782f32"><code>e7b28ea</code></a> Sanitize sourceURL so it cannot affect evaled code (<a href="https://github-redirect.dependabot.com/lodash/lodash/issues/4518">#4518</a>)</li> <li><a href="https://github.com/lodash/lodash/commit/0cec225778d4ac26c2bac95031ecc92a94f08bbb"><code>0cec225</code></a> Fix lodash.isEqual for circular references (<a href="https://github-redirect.dependabot.com/lodash/lodash/issues/4320">#4320</a>) (<a href="https://github-redirect.dependabot.com/lodash/lodash/issues/4515">#4515</a>)</li> <li><a href="https://github.com/lodash/lodash/commit/94c3a8133cb4fcdb50db72b4fd14dd884b195cd5"><code>94c3a81</code></a> Document matches* shorthands for over* methods (<a href="https://github-redirect.dependabot.com/lodash/lodash/issues/4510">#4510</a>) (<a href="https://github-redirect.dependabot.com/lodash/lodash/issues/4514">#4514</a>)</li> <li>Additional commits viewable in <a href="https://github.com/lodash/lodash/compare/4.17.15...4.17.19">compare view</a></li> </ul> </details> <details> <summary>Maintainer changes</summary> <p>This version was pushed to npm by <a href="https://www.npmjs.com/~mathias">mathias</a>, a new releaser for lodash since your current version.</p> </details> <br />

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


<details> <summary>Dependabot commands and options</summary> <br />

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
  • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
  • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
  • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the Security Alerts page.

</details>

+2 -2

1 comment

1 changed file

dependabot[bot]

pr closed time in 23 days

release pelotom/runtypes

v5.0.1

released time in 23 days

push eventpelotom/runtypes

Tom Crockett

commit sha eb3246bc76552107f1009ce5122887bdd8e80c33

v5.0.1

view details

push time in 23 days

created tagpelotom/runtypes

tagv5.0.1

Runtime validation for static types

created time in 23 days

pull request commentpelotom/runtypes

Export InternamRecord

No worries, thanks for the quick fix.

keithlayne

comment created time in 23 days

push eventpelotom/runtypes

Keith Layne

commit sha d4af163bdab3c2aa9ad450b8aa7ebae6cf1dbabe

Export InternamRecord (#157) This is my fault, since the lib built and tested fine I thought maybe it was okay to leave out the exports. This change just restores the things that were formerly exported. When you install 5.0, you will get compile errors like ``` Exported variable 'Foo' has or is using name 'InternalRecord' from external module ".../node_modules/runtypes/lib/types/record" but cannot be named. ``` if you use `Record`.

view details

push time in 23 days

PR merged pelotom/runtypes

Export InternamRecord

This is my fault, since the lib built and tested fine I thought maybe it was okay to leave out the exports. This change just restores the things that were formerly exported.

When you install 5.0, you will get compile errors like

Exported variable 'Foo' has or is using name 'InternalRecord' from external module ".../node_modules/runtypes/lib/types/record" but cannot be named.

if you use Record.

+2 -2

1 comment

1 changed file

keithlayne

pr closed time in 23 days

issue openedstorybookjs/storybook

Deprecation warning in v6 beta when using storyshots

I get the following warning when running storyshots with the v6 beta:

(node:77094) DeprecationWarning: `configure()` is deprecated and will be removed in Storybook 7.0.
Please use the `stories` field of `main.js` to load stories.

even though I've already refactored to use main.js. It seems that initStoryshots may still be using configure under the hood?

created time in 23 days

pull request commentpelotom/runtypes

Merge Record and Partial

It seems fine to me. Documentation would be good though!

keithlayne

comment created time in 23 days

issue commentpelotom/runtypes

Packaged as ECMAScript module rather than CommonJS?

I don't really have the spare cycles to work on this personally but you're welcome to open a PR 🙂 This blog post might be a good starting point: https://2ality.com/2019/10/hybrid-npm-packages.html

peternixey

comment created time in 23 days

release pelotom/runtypes

v5.0.0

released time in 23 days

created tagpelotom/runtypes

tagv5.0.0

Runtime validation for static types

created time in 23 days

push eventpelotom/runtypes

Tom Crockett

commit sha 911af0bf35f1b83e4df2682b28a5d68ce72a4fda

v5.0.0

view details

push time in 23 days

push eventpelotom/runtypes

dependabot[bot]

commit sha a04e86b44adabb8dfc12a0090abe68352e76d314

Bump acorn from 5.7.3 to 5.7.4 (#133) Bumps [acorn](https://github.com/acornjs/acorn) from 5.7.3 to 5.7.4. - [Release notes](https://github.com/acornjs/acorn/releases) - [Commits](https://github.com/acornjs/acorn/compare/5.7.3...5.7.4) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

view details

push time in 23 days

PR merged pelotom/runtypes

Bump acorn from 5.7.3 to 5.7.4 dependencies

Bumps acorn from 5.7.3 to 5.7.4. <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/acornjs/acorn/commit/6370e90067552022710190319cbbbd8c43001957"><code>6370e90</code></a> Mark version 5.7.4</li> <li><a href="https://github.com/acornjs/acorn/commit/fbc15b1344f6dfb992f67b4bbf1357436247c8a0"><code>fbc15b1</code></a> More rigorously check surrogate pairs in regexp validator</li> <li>See full diff in <a href="https://github.com/acornjs/acorn/compare/5.7.3...5.7.4">compare view</a></li> </ul> </details> <br />

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


<details> <summary>Dependabot commands and options</summary> <br />

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
  • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
  • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
  • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the Security Alerts page.

</details>

+2 -2

1 comment

1 changed file

dependabot[bot]

pr closed time in 23 days

push eventpelotom/runtypes

Richard Gieg

commit sha 017fa267e8f172dc74791cd0c1058e238d14ec05

Make format.js work on Windows (#135) * Make format.js work on Windows * Ensure that TypeScript files use LF even on Windows TypeScript files will always have LF line endings on checkout, so that running 'yarn format' on Windows will not need to change line endings from CRLF to LF causing git to report modified files with no code changes.

view details

push time in 23 days

PR merged pelotom/runtypes

Make format.js work on Windows

The fix uses execSync to get the path output from npm bin rather than embedding the Bash-specific $(npm bin) in the command. I tested it successfully on Windows 10 and Ubuntu.

+15 -2

1 comment

2 changed files

richgieg

pr closed time in 23 days

push eventpelotom/runtypes

Keith Layne

commit sha 212f5e09dfe3461ab6abbe848567c006588e88d7

Add Partial.asReadonly() (#153) Fixes #152

view details

push time in 23 days

PR merged pelotom/runtypes

Merge Record and Partial

This seems to work, but I have some questions/concerns:

  • The test stuff is completely arbitrary and I don't know if what I've done really follows the intent
  • Not sure I named things the way you like - I decided to just be symmetric with Record
  • Now partial.ts is basically a carbon copy of record.ts...it's just begging to be refactored

Thoughts?

Fixes #152

+87 -85

3 comments

7 changed files

keithlayne

pr closed time in 23 days

issue closedpelotom/runtypes

Any reason for missing asReadonly on Partial?

asReadonly() only seems to exist on Array and Record types. Would it be easy to extend this to support Partial as well? e.g. I'd like to be able to do:

Record({
  required: Number
}).asReadonly().And(Partial({
  optional: Number
}).asReadonly());

// -> {readonly required: number;} & {readonly optional?: number | undefined;}

closed time in 23 days

kkelk

issue commentpelotom/runtypes

Packaged as ECMAScript module rather than CommonJS?

I'd be open to generating an ES target as well, how would you propose doing it? Publishing a separate runtypes-es package to NPM a la lodash-es?

peternixey

comment created time in 23 days

issue commentpelotom/runtypes

hasKey (via new Discriminated Union code) throws when value being validated is null

Hi NMarrero, thanks for the bug report. Would you be interested in making a PR to fix it?

NMarrero

comment created time in 24 days

Pull request review commentpelotom/runtypes

Merge Record and Partial

 export type Reflect =   | ({ tag: 'symbol' } & Runtype<symbol>)   | ({ tag: 'literal'; value: LiteralBase } & Runtype<LiteralBase>)   | ({ tag: 'array'; element: Reflect; isReadonly: boolean } & Runtype<ReadonlyArray<unknown>>)-  | ({ tag: 'record'; fields: { [_: string]: Reflect }; isReadonly: boolean } & Runtype<-      { readonly [_ in string]: unknown }-    >)+  | ({+      tag: 'record';+      fields: { [_: string]: Reflect };+      isPartial: boolean;+      isReadonly: boolean;+    } & Runtype<{ readonly [_ in string]: unknown }>)   | ({ tag: 'partial'; fields: { [_: string]: Reflect } } & Runtype<{ [_ in string]?: unknown }>)

The partial reflect variant should be removed since it's been subsumed by record now, right?

keithlayne

comment created time in 24 days

issue openedstorybookjs/storybook

Common name prefix causes rapid switching between stories on load

This appears to have been introduced in 6.0.0-beta.33.

Using these stories:

import { storiesOf } from '@storybook/react';
import React from 'react';

storiesOf('test', module)
  .add('x y', () => {
    console.log('render x y'); 
    return <div>x y</div>
  })
  .add('x', () => {
    console.log('render x');
    return <div>x</div>
  });

if you start on the "x" story and then reload the page, it will switch to the "x y" story, and the console prints

render x y
render x
render x y
``

(In my real project using typescript it actually switches between the 2 stories many more times, sometimes endlessly.)

This seems somehow related to the fact that the second story's name is a prefix of the first. If you change the second story name to "x z" the bug doesn't occur. It also doesn't occur if you change the order of the stories or change which one is selected at the beginning.

created time in 24 days

issue commentstorybookjs/storybook

Uncaught SyntaxError: Unexpected token 'default'

This seems to happen in cases where a static property is assigned to a component which is exported at its declaration site, e.g.

export default function Foo() {
  return null;
}
Foo.x = 42;

A workaround seems to be separating the export from the declaration:

export default Foo;
function Foo() {
  return null;
}
Foo.x = 42;

Class components with static properties suffer from the same problem:

export default class Foo() {
  static x = 42;
  render() { return null; }
}

and the workaround is the same:

export default Foo;
class Foo() {
  static x = 42;
  render() { return null; }
}
pelotom

comment created time in 24 days

issue commentstorybookjs/storybook

Ability to exclude some directories/files from stories

Ah, I am using Chromatic, thanks for the tip!

pelotom

comment created time in 25 days

issue commentstorybookjs/storybook

Ability to exclude some directories/files from stories

@pelotom I'm not sure about your use case, but the use case I see about using exclude would be maybe if I'm developing CheckoutFeature and I only want Storybook to bring those stories because maybe the project has like 500 stories. But in this scenario, rather than excluding, I would make my glob more specific and I would achieve that with the existing implementation of Storybook. Does that help somehow?

My use case is that I have one particular directory of stories nested deep within my repo which I want to exclude during visual regression testing in CI. It's not practical to positively specify all the things I do want to include while omitting this one particular deeply-nested directory, if that makes sense. My short term workaround is just to delete the directory in the CI script before building the storybook, but it'd be nice to have an exclude option.

pelotom

comment created time in 25 days

pull request commentDefinitelyTyped/DefinitelyTyped

Give PropsWithChildren a default type parameter

@pelotom the downside as I see it is using PropsWithChildren for a situation where.... well where there are no props. See the impedance mismatch there? It really looks like what you want is ReactNode, no? While I'm not deeply opposed to the default argument... it seems kinda backwards to default to not having props for a type that intends to type props, know what I mean?

{} is a set of props (the empty set), so PropsWithChildren is still an accurate name. In any case, I don't really care about the name, I care that the type is useful, and it would be more useful if it had a defaulted parameter. Re. using ReactNode, as I said above, writing { children: ReactNode } is more cumbersome than writing PropsWithChildren.

pelotom

comment created time in 25 days

pull request commentpelotom/runtypes

Add Partial.asReadonly()

  • The test stuff is completely arbitrary and I don't know if what I've done really follows the intent

What do you mean by arbitrary?

  • Now partial.ts is basically a carbon copy of record.ts...it's just begging to be refactored

I agree, what do you think about making Record take an optional argument which marks it as partial, and then Partial just being an alias to Record with that flag set?

keithlayne

comment created time in a month

startedcomby-tools/comby

started time in a month

issue commentactions/runner

Compose GitHub actions as a single GitHub action

This is our team's number 1 pain point with GH actions, would love to see something like this implemented, or alternatively support for YAML anchors (how we used to accomplish DRY with Travis).

danpintara

comment created time in a month

issue commentactions/checkout

Support multiple branches being checked out through config

Is there any way around this issue in checkout@v2? With checkout@v1 we were able to make use of the origin/master ref, but mysteriously it is no longer available in v2. I need v2 due to this, but also need access origin/master for use with Jest's --changedSince. Has anyone found a workaround?

bnb

comment created time in a month

pull request commentDefinitelyTyped/DefinitelyTyped

Give PropsWithChildren a default type parameter

Presumably this is why the latter exists in the first place.

Sure but the name makes it clear that it is about "props and children". If you're not passing "props" then the type looses its meaning and it should make it obvious when you forgot the props. In the end you can always do PropsWithChildren<{}> if you are sure you don't have any props, no?

It's a minor convenience. What's the downside?

pelotom

comment created time in a month

pull request commentDefinitelyTyped/DefinitelyTyped

Give PropsWithChildren a default type parameter

function MyComponent({ children }: PropsWithChildren) {

I think we have it pretty well established that React.ReactNode is the dedicated type for children. Do we need this specific pattern you suggested for anything else?

Not sure if this is what you’re suggesting, but writing { children: ReactNode } is more cumbersome than PropsWithChildren. Presumably this is why the latter exists in the first place.

pelotom

comment created time in a month

PR opened DefinitelyTyped/DefinitelyTyped

Reviewers
Give PropsWithChildren a default type parameter

Please fill in this template.

  • [x] Use a meaningful title for the pull request. Include the name of the package modified.
  • [x] Test the change in your own code. (Compile and run.)
  • [x] Add or edit tests to reflect the change. (Run with npm test.)
  • [x] Follow the advice from the readme.
  • [x] Avoid common mistakes.
  • [x] Run npm run lint package-name (or tsc if no tslint.json is present).

Select one of these and delete the others:

If changing an existing definition:

  • [ ] Provide a URL to documentation or source code which provides context for the suggested changes: <<url here>>
  • [ ] If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the header.
  • [ ] Include tests for your changes
  • [ ] If you are making substantial changes, consider adding a tslint.json containing { "extends": "dtslint/dt.json" }. If for reason the any rule need to be disabled, disable it for that line using // tslint:disable-next-line [ruleName] and not for whole package so that the need for disabling can be reviewed.
+1 -1

0 comment

1 changed file

pr created time in a month

push eventpelotom/DefinitelyTyped

Tom Crockett

commit sha 698981731f57c311e2a89d6ab75f05b8f94cff28

Give PropsWithChildren a default type parameter

view details

push time in a month

startedmoltar/typescript-runtime-type-benchmarks

started time in a month

startednthypes/super-ts

started time in a month

pull request commentfacebook/jest

Use `git diff` instead of `git log` for --changedSince

Any chance this could get released soon? This is a major blocker for us since we can't practically run all of our tests in CI on every PR.

finn-orsini

comment created time in a month

startedsibelius/recoil-todo

started time in a month

issue closedfacebook/jest

onlyChanged/changedSince/findRelatedTests doesn't take into account moduleNameMapper

<!-- Love Jest? Please consider supporting our collective: 👉 https://opencollective.com/jest/donate -->

🐛 Bug Report

I am using moduleNameMapper to match my TypeScript paths settings. The tests run fine, but if I use --onlyChanged, --changedSince or --findRelatedTests it doesn't pick up tests which depend on changed files via mapped paths. <!-- A clear and concise description of what the bug is. -->

To Reproduce

Steps to reproduce the behavior:

  1. Clone this repo: https://github.com/pelotom/module-name-mapper-bug
  2. Make a change to packages/foo/src/index.ts
  3. Run yarn test

Expected behavior

The tests in both packages/foo and packages/bar should be run, since the test in bar depends on packages/foo/index.ts indirectly via the remapped name '@nighttrax/foo'.

<!-- A clear and concise description of what you expected to happen. -->

Actual behavior

Only the test in packages/foo runs.

Link to repl or repo (highly encouraged)

https://github.com/pelotom/module-name-mapper-bug

closed time in a month

pelotom

issue commentfacebook/jest

onlyChanged/changedSince/findRelatedTests doesn't take into account moduleNameMapper

Never mind, I figured out that this was due to not setting roots to include all my subpackages.

pelotom

comment created time in a month

issue commentstorybookjs/storybook

Uncaught SyntaxError: Unexpected token 'default'

Yes, it works in 6.0.0-beta.23 and before. I don't have a minimal repro currently, but can work on putting one together.

pelotom

comment created time in a month

issue openedstorybookjs/storybook

Uncaught SyntaxError: Unexpected token 'default'

It appears that a change introduced in 6.0.0-beta.24 is causing my storybook to fail to load:

image

I'm not sure exactly what is going on here because source maps don't seem to be working.

created time in a month

push eventpelotom/module-name-mapper-bug

Tom Crockett

commit sha 10a74a02b81bebf550875c0770ca17e8e5208e89

Fix typo

view details

push time in a month

issue openedfacebook/jest

onlyChanged/changedSince/findRelatedTests doesn't take into account moduleNameMapper

<!-- Love Jest? Please consider supporting our collective: 👉 https://opencollective.com/jest/donate -->

🐛 Bug Report

I am using moduleNameMapper to match my TypeScript paths settings. The tests run fine, but if I use --onlyChanged, --changedSince or --findRelatedTests it doesn't pick up tests which depend on changed files via mapped paths. <!-- A clear and concise description of what the bug is. -->

To Reproduce

Steps to reproduce the behavior:

  1. Clone this repo: https://github.com/pelotom/module-name-mapper-bug
  2. Make a change to packages/foo/src/index.ts
  3. Run yarn test

Expected behavior

The tests in both packages/foo and packages/bar should be run, since the test in bar depends on packages/foo/index.ts indirectly via the remapped name '@nighttrax/foo'.

<!-- A clear and concise description of what you expected to happen. -->

Actual behavior

Only the test in packages/foo runs.

Link to repl or repo (highly encouraged)

https://github.com/pelotom/module-name-mapper-bug

created time in a month

push eventpelotom/module-name-mapper-bug

Tom Crockett

commit sha 41408ff78b7eac62b06d1383eaecac9d882ebb52

Remove log

view details

push time in a month

push eventpelotom/module-name-mapper-bug

Andrei Picus

commit sha 85ba73a730c99979797c64cbec9d44fb51b9ecdf

Initial commit

view details

Andrei Picus

commit sha 67712a267306c063c8ad476027b149fc343dc1c1

Rely on lerna build order instead of tsc -b

view details

Andrei Picus

commit sha f840305770be8f3833c47c0767af2882193a92fb

Update README

view details

Andrei Picus

commit sha 08e0c3bdc5bba4117c1f9839fe81e4cc64e1948d

Add prepublish scripts

view details

Andrei Picus

commit sha ae1ab58875f21b5bf83ae2ce674b184fc5bb5fe1

Link docs in README

view details

Andrei Picus

commit sha 1299beb3265de94ec74061fcec3f6413db13456f

Add setup section in README

view details

Andrei Picus

commit sha e44000aed631e6c6393793531e9f3797353303ec

Move setup section higher

view details

Andrei Picus

commit sha 9efb89aec69d4f22f234200145ae35e68a868a7b

Use named exports

view details

Andrei Picus

commit sha 802aca6e9b2bd67dd4c701107b576cc6d9f2e786

Update Features section

view details

Andrei Picus

commit sha 00ac2f3d44a6064ff2ed2c6ae083f830e7b13c9c

Explain when lerna bootstrap is needed

view details

Marco Biedermann

commit sha c29d04d30691d485d06d5afbb4ce6517f2483ef2

feat: postinstall Use npm postinstall script to run bootstrap

view details

Andrei Picus

commit sha dec8224f57b53a26b2e7dd252474198732038b6d

build: Use rimraf instead of rm Fixes #7.

view details

Andrei Picus

commit sha 67dfceebca61c725a1e4e4fcbf81595acd007e48

build: Move rimraf dependency to each package This allows running the build script from individual packages.

view details

Andrei Picus

commit sha e120681b0cf7833acf2ff25007013881c662c449

build: Remove `include` from package `tsconfig.json`s We want the main config to target everything, and only have the build config target `src`.

view details

Tom Crockett

commit sha 9c04b9a4b3f28e85aa6b5023f7891cdc0f533e10

WIP

view details

Tom Crockett

commit sha 9bdd22fad67be08d06684db73857ff2569e102d5

W00T

view details

Tom Crockett

commit sha 7c9dec49452895105fab7887475a8927330066b1

Add test

view details

Tom Crockett

commit sha ad2b9879922f2a36bb200b396990c63fa3b790f2

Tweak

view details

Tom Crockett

commit sha e180a6e9ca4f370127ff6cc620cebba8a3afca0d

Tweak

view details

Tom Crockett

commit sha 08c864fffcf4fba1dfd285a5d336565ddb1a2499

Remove README

view details

push time in a month

create barnchpelotom/module-name-mapper-bug

branch : master

created branch time in a month

created repositorypelotom/module-name-mapper-bug

created time in a month

startedmxgmn/WaveFunctionCollapse

started time in a month

startedjaydenseric/find-unused-exports

started time in a month

pull request commentpelotom/runtypes

Fix for error TS2349

I don't know Deno, but if it doesn't allow for dependencies to be compiled under different configuration than your own project that seems like a pretty severe design flaw IMO (one which regular TypeScript does not suffer from). BTW, this project is using the stricter setting: by not using a default case and instead relying on exhaustiveness checking to prove that the function is still total, it protects from the situation where you add another case but fail to handle it in the switch statement. If you add another case to Reflect, you will suddenly have a type error in that function because it is not exhaustive.

jakajancar

comment created time in 2 months

pull request commentpelotom/runtypes

Fix for error TS2349

It’s using the official tsc. Maybe the default tsconfig is different?

You would need to make it use the tsconfig in the root of this repo.

jakajancar

comment created time in 2 months

pull request commentpelotom/runtypes

Fix for error TS2349

I’m not building it, I use it with Deno which supports TS natively.

Apparently not fully, if it's reporting errors when yarn build does not. Does Deno not support exhaustiveness checking?

jakajancar

comment created time in 2 months

PR closed pelotom/runtypes

Fix for error TS2349
error TS2349: This expression is not callable.
  Type 'never' has no call signatures.

► http://localhost:8000/raw.githubusercontent.com/pelotom/runtypes/master/src/show.ts:65:9

65   throw Error('impossible');
           ~~~~~
+2 -1

2 comments

1 changed file

jakajancar

pr closed time in 2 months

pull request commentpelotom/runtypes

Fix for error TS2349

I'm not sure how you're trying to build the library but if you run yarn && yarn build it should work.

jakajancar

comment created time in 2 months

pull request commentpelotom/runtypes

Provide a single-file browser-friendly distribution

I would rather not add a dependency on a particular bundler to this library. Is there a way to re-do the imports so as not to confuse your bundler?

madnl

comment created time in 2 months

issue commentpelotom/runtypes

Any reason for missing asReadonly on Partial?

That's reasonable, would you like to make a PR?

kkelk

comment created time in 2 months

release pelotom/runtypes

v4.3.0

released time in 2 months

created tagpelotom/runtypes

tagv4.3.0

Runtime validation for static types

created time in 2 months

push eventpelotom/runtypes

Tom Crockett

commit sha 5217fe743d43017dd2af40c071cd8af7cabc2b12

Normalize yarn.lock

view details

Tom Crockett

commit sha aaed8327e4ee35c6682701123ff3285d23f2a95a

v4.3.0

view details

push time in 2 months

push eventpelotom/runtypes

Ivan Kerin

commit sha c90580603e0217f689f11e32db1b2e083fe0748a

Implement Discriminated Unions (#149) * Implement Discriminated Unions If: - all the alternatives of a union are records - they have at least one field in common, that is a literal in each record with unique values Then when checking the alternatives we can pick the correct one first, and then perform the validation, thus producing more specific error messages. This is something already present in TypeScript itself https://www.typescriptlang.org/docs/handbook/advanced-types.html#discriminated-unions Though this implementation would not work in all the cases covered by TS, but its a start. * Remove perf optimisation

view details

push time in 2 months

PR merged pelotom/runtypes

Implement Discriminated Unions

First of all, AWESOME library! One thing has been bugging me about it though and its support for Discriminated Unions.

This is my attempt on addressing it, and I've seen similar issues being raised too.

So with this PR, when those conditions are met:

  • all the alternatives of a union are records
  • they have at least one field in common, that is a literal in each record with unique values

Then when checking the alternatives we can pick the correct one first, and then perform the validation, thus producing more specific error messages.

This is something already present in TypeScript itself https://www.typescriptlang.org/docs/handbook/advanced-types.html#discriminated-unions and seems to have been requested before https://github.com/pelotom/runtypes/issues/67 . Though this implementation would not work in all the cases covered by TS, but it's a start.

I'll be glad to add more tests or work on the implementation on your direction. Sorry for the long implementation, but the you seem to be supporting way older version of JS than I'm used to so had to implement the logic in for loops and such.

+84 -1

2 comments

2 changed files

ivank

pr closed time in 2 months

startedpikapkg/create-snowpack-app

started time in 2 months

create barnchpelotom/better-sqlite3

branch : fix-monkey-patching-bug

created branch time in 2 months

fork pelotom/better-sqlite3

The fastest and simplest library for SQLite3 in Node.js.

fork in 2 months

issue openedJoshuaWise/better-sqlite3

Error and memory leak due to monkey patching

When using better-sqlite3 in Jest, if we have more than 1 test suite which imports sqlite3 and sets a pragma:

const sqlite3 = require('better-sqlite3');

test('set pragma', () => {
  sqlite3().pragma('foreign_keys = ON');
});

the second suite fails:

    TypeError: Expected first argument to be a string

      2 |
      3 | test('set pragma', () => {
    > 4 |   sqlite3().pragma('foreign_keys = ON');
        |             ^
      5 | });
      6 |

      at Database.pragma (node_modules/better-sqlite3/lib/pragma.js:7:41)
      at Object.<anonymous> (set-pragma-9.test.js:4:13)

There is also a memory leak. I think both of these are due to the monkey patching here: https://github.com/JoshuaWise/better-sqlite3/blob/6be0b0ec618864764a4b2b28ea83d2fe1126a2a3/lib/database.js#L38 When Jest resets its module cache, this code is re-run and the wrapper is applied to the previous wrapper. Repro repo: https://github.com/pelotom/better-sqlite3-jest-bug

created time in 2 months

create barnchpelotom/better-sqlite3-jest-bug

branch : master

created branch time in 2 months

created repositorypelotom/better-sqlite3-jest-bug

created time in 2 months

startedodeke-em/drive

started time in 2 months

startedJoshuaWise/better-sqlite3

started time in 2 months

issue commentstorybookjs/storybook

Ability to exclude some directories/files from stories

I can't seem to make that work, it ends up excluding all files.

pelotom

comment created time in 2 months

issue openedstorybookjs/storybook

Ability to exclude some directories/files from stories

The new main.js format for specifying stories requires specifying an array of globs, e.g.

module.exports = {
  stories: ['../../src/**/*.@(story|stories).tsx'],
};

With this approach it's not clear how I can exclude certain things from being included. When the stories were configured within the browser environment I was able to use require.context with a regex, e.g.

configure(
  require.context('../../src', true, /(?<!\/some\/forbidden\/directory.*)\.(story|stories)\.tsx?$/),
  module,
);

I could walk the directory structure in node and just provide a large array of fully resolved file paths, but it'd be nice to just be able to provide a regex instead of a glob. Or is there a way to do this with globs that I'm missing?

created time in 2 months

push eventpelotom/sqlite3-jest-memory-leak

Tom Crockett

commit sha 8b0d8fa48f9c181cc1708b732c2aee9d57e50ca5

Update README.md

view details

push time in 2 months

push eventpelotom/sqlite3-jest-memory-leak

Tom Crockett

commit sha 6f7ed1dd145b48b80687b3b7f7faef8049c21a90

Update README.md

view details

push time in 2 months

push eventpelotom/sqlite3-jest-memory-leak

Tom Crockett

commit sha 4833e741c698be03947bf776ab9a62a42d4c0471

Update README.md

view details

push time in 2 months

issue openedmapbox/node-sqlite3

Memory leak when running with Jest

When I simply try to require sqlite3 from a Jest test with the --detectLeaks flag, it says there is a memory leak. Repro here: https://github.com/pelotom/sqlite3-jest-memory-leak.

As explained in this article this may just be due to the way that Jest unloads and reloads modules to ensure isolation between runs. It doesn't look like much memory is being leaked; my main issue is that it prevents me from using --detectLeaks to find other worse leaks.

created time in 2 months

more