Skip to content

evolve throws while absent of corresponding transformations #1718

Open
@imcotton

Description

@imcotton

🐛 Bug report

Current Behavior

evolve from struct throws while having absent transformations:

node_modules/fp-ts/lib/struct.js:78
            out[k] = transformations[k](a[k]);
                                       ^

TypeError: transformations[k] is not a function
    at node_modules/fp-ts/lib/struct.js:78:40

Expected behavior

Leaves unspecified entries untouched.

Reproducible example

const { pipe, identity } = require('fp-ts/function')
const { singleton } = require('fp-ts/ReadonlyRecord')
const { evolve } = require('fp-ts/struct')

// Expected { a: 1 }
const result = pipe(
    singleton('a', 1),
    evolve({
        b: identity,
    }),
)

Suggested solution(s)

Check before invoking transformations.

Additional context

Expected behavior would align with the evolve from Ramda as well.

Your environment

Did this work in previous versions of fp-ts? no

Which versions of fp-ts are affected by this issue?

Software Version(s)
fp-ts 2.11
2.12
TypeScript 4.7



Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions