profile
viewpoint
Oliver Joseph Ash OliverJAsh Northamptonshire/Bedfordshire, England https://oliverjash.me/

gcanti/fp-ts 7117

Functional programming in TypeScript

gillchristian/io-ts-reporters 71

Error reporters for io-ts

jackfranklin/jspm-dev-builder 66

Incremental development builds with jspm

cubik-oss/redux-reducer-effects 24

Redux enhancer which adds support for managed effects to the reducer

jleider/DefinitelyTyped 2

The repository for high quality TypeScript type definitions.

jackbrewer/yScroll 1

A jQuery plugin which scrolls a background image relative to the page scroll.

aliciaphes/unsplash-app 0

Display images using the Unsplash API

startedrelmify/jest-fp-ts

started time in 4 hours

startedGoogleChromeLabs/postcss-jit-props

started time in 15 hours

push eventOliverJAsh/chrome-extension-pause-page

Oliver Joseph Ash

commit sha 4bbb47b71a30349afeabff6f03118912c480d994

Add link

view details

push time in a day

issue openedmicrosoft/TypeScript

`exactOptionalPropertyTypes`: `Partial` of index signature adds `undefined`

Bug Report

<!-- Please fill in each section completely. Thank you! -->

🔎 Search Terms

<!-- What search terms did you use when trying to find an existing bug report? List them here so people in the future can find this one more easily. -->

exactOptionalPropertyTypes strictoptionalProperties Partial index signature dictionary record

🕗 Version & Regression Information

<!-- When did you start seeing this bug occur?

"Bugs" that have existed in TS for a long time are very likely to be FAQs; refer to https://github.com/Microsoft/TypeScript/wiki/FAQ#common-bugs-that-arent-bugs

If possible, please try testing the nightly version of TS to see if it's already been fixed. For npm: typescript@next This is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly

Note: The TypeScript Playground can be used to try older versions of TypeScript.

Please keep and fill in the line that best applies: -->

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about exactOptionalPropertyTypes

⏯ Playground Link

<!-- A link to a TypeScript Playground "Share" link which shows this behavior

The TypeScript Workbench can be used for more complex setups, try https://www.typescriptlang.org/dev/bug-workbench/

As a last resort, you can link to a repo, but these will be slower for us to investigate. --> Playground link with relevant code

💻 Code

<!-- Please post the relevant code sample here as well-->

type MyRecord = { x: string; z: string };

const r: Partial<MyRecord> = {
    x: "y",
    // Error as expected ✅
    z: undefined,
};

type MyDict = { [key: string]: string };

const d: Partial<MyDict> = {
    x: "y",
    // Expected error but got none ❌
    z: undefined,
};

🙁 Actual behavior

See code comments above.

🙂 Expected behavior

See code comments above.


This was briefly discussed in https://github.com/microsoft/TypeScript/issues/44524 and https://github.com/microsoft/TypeScript/issues/44421#issuecomment-859053118.

created time in a day

PR closed DefinitelyTyped/DefinitelyTyped

Reviewers
`react`: remove `undefined` from `className` prop Revision needed Critical package Untested Change

Under exactOptionalPropertyTypes, className={undefined} should not be allowed as this will produce HTML such as className="undefined".

If exactOptionalPropertyTypes is not enabled then className={undefined} would still be allowed.

I wanted to add a test for this however dtslint doesn't have support for exactOptionalPropertyTypes yet: https://github.com/microsoft/dtslint/issues/348 /cc @sandersn

| undefined was added in this commit to provide backwards compatibility.


Please fill in this template.

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.
+1 -1

5 comments

1 changed file

OliverJAsh

pr closed time in a day

pull request commentDefinitelyTyped/DefinitelyTyped

`react`: remove `undefined` from `className` prop

You're totally right. We were seeing undefined in our HTML but in retrospect this seems to be because of something completely unrelated. Thanks for verifying!

OliverJAsh

comment created time in a day

issue commentmicrosoft/dtslint

expect-type should allow tsconfig options from new versions of typescript

Note this is preventing me from writing a test for https://github.com/DefinitelyTyped/DefinitelyTyped/pull/57463.

sandersn

comment created time in 2 days

PR opened DefinitelyTyped/DefinitelyTyped

`react`: remove `undefined` from `className` prop

Under exactOptionalPropertyTypes, className={undefined} should not be allowed as this will produce HTML such as className="undefined".

If exactOptionalPropertyTypes is not enabled then className={undefined} would still be allowed.

I wanted to add a test for this however dtslint doesn't have support for exactOptionalPropertyTypes yet: https://github.com/microsoft/dtslint/issues/348 /cc @sandersn

The | undefined was added in this commit to provide backwards compatibility.


Please fill in this template.

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.
+1 -1

0 comment

1 changed file

pr created time in 2 days

create barnchOliverJAsh/DefinitelyTyped

branch : oja/react/class-name-undefined

created branch time in 2 days

issue commentgcanti/io-ts

Validation should fail when required property (which may be `undefined`) is missing

Semantically speaking "undefined" and not defined are supposed to be equivalent.

@SHaTRO I'm not sure if they are equivalent in terms of behaviour, because the in operator will produce different results when the key doesn't exist versus when it does exist but the value is set to undefined:

type A = { foo: string | undefined }
const a1: A = { foo: undefined };
'foo' in a1; // true

type B = { foo?: string }
const a1: A = {};
'foo' in a1; // false

I'm not trying to imply it's a good idea to use "explicit undefined"s, rather I'm just pointing out that the behaviour in io-ts doesn't match the behaviour in TypeScript.

Say we have this type:

const t = require('io-ts')
const I = t.type({ foo: t.string, bar: t.union([t.undefined, t.string])})

It is reasonable to expect that, after a successful decode, 'bar' in value will produce true only if the key existed on the input value, because we have declared the key as required.

However this is not currently the case. In this example, the decode succeeds even though the required key is missing:

const result = I.decode({ foo: 'foo' })
console.log({result});
// { result: { _tag: 'Right', right: { foo: 'foo', bar: undefined } } }
console.log('bar' in result)
// => true
// Key 'bar' never existed in the input value ❗️

OTOH, if we model the type using a TypeScript type instead, the assignment fails:

// Errors as expected
// Property 'bar' is missing in type '{ foo: string; }' but required in type '{ foo: string; bar: string | undefined; }'.ts(2741)
const result: { foo: string; bar: string | undefined } = { foo: 'foo' };
OliverJAsh

comment created time in 2 days

startedgarybernhardt/static-path

started time in 2 days

startedmagit/magit

started time in 2 days

issue commentmicrosoft/TypeScript

"Convert parameters to destructured object": enable for functions with just one parameter

Thanks, PR here: https://github.com/microsoft/TypeScript/pull/46945

OliverJAsh

comment created time in 3 days

push eventOliverJAsh/TypeScript

uhyo

commit sha 04f831d7958b6803e036a2f85da160c4a9a1f338

Import chalk with import() syntax (#46931) This makes code compatible with chalk v5.0.0.

view details

Andrew Branch

commit sha 68bf5a519a17f5ae15bcd7b7ae71c20b40ddd8c5

Fix formatting the end of a selection (#46875) * Fix formatting edits at end of range * Adjust test * Revert API baseline changes

view details

Oliver Joseph Ash

commit sha 29cc444be9b3900a02e7795d1733442c39bd69f1

"Convert parameters to destructured object": enable for functions with just one parameter Fixes https://github.com/microsoft/TypeScript/issues/41753

view details

push time in 3 days

push eventOliverJAsh/TypeScript

Oliver Joseph Ash

commit sha c4757fe2ec77614ada803ca7bf83e0675f2143d6

"Convert parameters to destructured object": enable for functions with just one parameter Fixes https://github.com/microsoft/TypeScript/issues/41753

view details

push time in 3 days

issue commentgcanti/fp-ts

Why does `string.split` return non-empty array when given an empty string?

  1. Because that's the behaviour of String.prototype.split.
  2. pipe('ab', string.split('')) returns ['a', 'b'], which suggests that a '' separator will split each character, but if '' is the input, there are no characters to split
OliverJAsh

comment created time in 3 days

issue commentmicrosoft/TypeScript

"Convert parameters to destructured object": enable for functions with just one parameter

@RyanCavanaugh I would like to raise a PR to fix this, can you accept this issue and add it to the backlog?

OliverJAsh

comment created time in 3 days

PR opened microsoft/TypeScript

"Convert parameters to destructured object": enable for functions with just one parameter

<!-- Thank you for submitting a pull request!

Please verify that:

  • [ ] There is an associated issue in the Backlog milestone (required)
  • [x] Code is up-to-date with the main branch
  • [ ] You've successfully run gulp runtests locally
  • [ ] There are new or updated unit tests validating the change

Refer to CONTRIBUTING.MD for more details. https://github.com/Microsoft/TypeScript/blob/main/CONTRIBUTING.md -->

Fixes https://github.com/microsoft/TypeScript/issues/41753

+1 -1

0 comment

1 changed file

pr created time in 3 days

push eventOliverJAsh/TypeScript

Oliver Joseph Ash

commit sha c5bae869d83490282fbb0349020765e3a94d352f

"Convert parameters to destructured object": enable for functions with just one parameter Fixes https://github.com/microsoft/TypeScript/issues/41753

view details

push time in 3 days

issue openedgcanti/fp-ts

Why does `string.split` return non-empty array when given an empty string?

🐛 Bug report

Current Behavior

String.prototype.split:

''.split('') // => []

fp-ts:

pipe('', string.split('')) // => ['']

Expected behavior

I would expect [] from string.split, so it matches String.prototype.split but also because I think that behaviour makes more sense.

It seems like this was done intentionally: https://github.com/gcanti/fp-ts/commit/7d1887de8b704b6dc86a29964c33f6ca8decb41a#diff-bbade37cef19cf470364082a01329d9fbf208a96862818d50ea97602767d7a48R130

What was the reasoning for this change?

Reproducible example

See above.

Suggested solution(s)

<!-- How could we solve this bug? What changes would need to made to fp-ts? -->

Additional context

<!-- Add any other context about the problem here. -->

Your environment

Which versions of fp-ts are affected by this issue? Did this work in previous versions of fp-ts?

<!-- PLEASE FILL THIS OUT -->

Software Version(s)
fp-ts
TypeScript

created time in 3 days

issue openedgcanti/fp-ts-routing

Suggestion: `type` without a key

Currently I am using P.str like so:

  const queryMatch = P.str('query').imap(
    ({ query }) => ({ query: decodeUrlSlugParam(query) }),
    ({ query }) => ({ query: encodeUrlSlugParam(query) }),
  );

I need to use imap to run my decode/encode functions, however to do this I am forced to work with the object type ({ query: string }) rather than just the string. Ideally I could just imap(decodeUrlSlugParam, encodeUrlSlugParam):

  const queryMatch = typeWithoutKey(t.string)
    .imap(decodeUrlSlugParam, encodeUrlSlugParam)
    .imap(
      (query) => ({ query }),
      ({ query }) => query,
    );

This would be possible with something like the existing type function but without the object wrapping. This can be done manually like in my example above.

export function typeWithoutKey<A>(type: t.Type<A, string>): P.Match<A> {
  return new P.Match(
    new P.Parser((r) => {
      if (r.parts.length === 0) {
        return O.none;
      } else {
        const head = r.parts[0];
        const tail = r.parts.slice(1);
        return O.option.map(O.fromEither(type.decode(head)), (a) =>
          tuple(a, new P.Route(tail, r.query)),
        );
      }
    }),
    new P.Formatter((r, a) => new P.Route(r.parts.concat(type.encode(a)), r.query)),
  );
}

created time in 4 days

startedrx-ts/eslint-import-resolver-ts

started time in 5 days

push eventOliverJAsh/no-duplicate-imports-test

Oliver Joseph Ash

commit sha 758679b90b0bf8f5ba8748fa7d081027c470d7ae

Init

view details

push time in 6 days

issue openedtypescript-eslint/typescript-eslint

[no-duplicate-imports] Detect duplicates when paths are different

<!-- If you have a problem with a specific rule, please begin your issue title with [rulename] to make it easier to search for. I.e. "[no-unused-vars] False positive when fooing the bar"

Please don't ignore this template.

If you ignore it, we're just going to respond asking you to fill it out, which wastes everyone's time. The more relevant information you can include, the faster we can find the issue and fix it without asking you for more info. -->

<!-- Are you opening an issue because the rule you're trying to use is not found? 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨

  1. Check the releases log: https://github.com/typescript-eslint/typescript-eslint/releases
    • If the rule isn't listed there, then chances are it hasn't been released to the main npm tag yet.
  2. Try installing the canary tag: npm i @typescript-eslint/eslint-plugin@canary.
    • The canary tag is built for every commit to main, so it contains the bleeding edge build.
  3. If ESLint still can't find the rule, then consider reporting an issue. -->
  • [x] I have tried restarting my IDE and the issue persists.
  • [x] I have updated to the latest version of the packages.
  • [x] I have read the FAQ and my problem is not listed.

Repro

<!-- Include a minimal reproduction case. The more irrelevant code/config you give, the harder it is for us to investigate.

Please consider creating an isolated reproduction repo to make it easy for the volunteer maintainers debug your issue. -->

Full reduced test case: https://github.com/OliverJAsh/no-duplicate-imports-test.git

.eslintrc.js:

const config = {
    parser: "@typescript-eslint/parser",
    parserOptions: {
        project: ["./tsconfig.json"],
    },
    plugins: ["@typescript-eslint"],
    rules: {
        "@typescript-eslint/no-duplicate-imports": 2
    },
};

module.exports = config;

tsconfig.json:

{
    "compilerOptions": {
        "baseUrl": "./app"
    },
}

app/helpers/foo.ts:

export const foo = 1;
export const bar = 1;

app/main.ts:

import { foo } from "helpers/foo";
// This should error but it doesn't ❌
import { bar } from "./helpers/foo";

foo;
bar;

<!-- Also include your tsconfig, if you're using type-aware linting -->

Expected Result

<!-- What did you expect to happen? Please be specific here - list the exact lines and messages you expect. -->

@typescript-eslint/no-duplicate-imports should produce an error.

Actual Result

No error

Additional Info

I understand that the base rule no-duplicate-imports wouldn't be able to detect this duplicate because it doesn't have enough information about the dependency graph and the baseUrl to detect whether the duplicate, however I think @typescript-eslint/no-duplicate-imports does have the information necessary to detect this?

<!-- Did eslint throw an exception?

Please run your lint again with the --debug flag, and dump the output below. i.e. eslint --ext ".ts,.js" src --debug -->

Versions

package.json:

{
  "dependencies": {
    "@typescript-eslint/eslint-plugin": "^5.4.0",
    "@typescript-eslint/parser": "^5.4.0",
    "eslint": "^8.3.0",
    "typescript": "^4.5.2"
  }
}

created time in 6 days

create barnchOliverJAsh/no-duplicate-imports-test

branch : master

created branch time in 6 days

created repositoryOliverJAsh/no-duplicate-imports-test

created time in 6 days

create barnchOliverJAsh/fp-ts-routing-localisation

branch : master

created branch time in 8 days

created repositoryOliverJAsh/fp-ts-routing-localisation

created time in 8 days

startedahmadnassri/action-workflow-queue

started time in 9 days

push eventOliverJAsh/chrome-extension-pause-page

Oliver Joseph Ash

commit sha 78c3a50740ebba902d4b9e37e9d5544e32705167

Init

view details

push time in 12 days

more