tim-smart / tim-smart/effect-atom

@effect-atom/atom-react should declare @effect-atom/atom as peerDependency

Open
#388 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
792
Forks
49
PR merge metrics
No merged PRs in 30d

Description

Summary

@effect-atom/atom-react declares @effect-atom/atom as a direct dependency rather than a peer dependency. This causes duplicate installations when consumers use a different (but compatible) version, leading to TypeScript type mismatches.

Environment

  • @effect-atom/atom: ^0.4.9
  • @effect-atom/atom-react: ^0.4.3
  • Package manager: bun
  • TypeScript: 5.9

Problem

When @effect-atom/atom@0.4.9 is installed at root and @effect-atom/atom-react@0.4.3 has @effect-atom/atom: "^0.4.8" as a direct dependency, bun installs a nested copy:

node_modules/@effect-atom/atom (0.4.9)
node_modules/@effect-atom/atom-react/node_modules/@effect-atom/atom (0.4.8)

This creates two different Atom types at runtime and compile time, causing type errors like:

Argument of type 'Atom<boolean>' from node_modules/@effect-atom/atom is not assignable to
parameter of type 'Atom<boolean>' from node_modules/@effect-atom/atom-react/node_modules/@effect-atom/atom
Full TypeScript error output
lib/providers/AnalyticsProvider.tsx(20,38): error TS2345: Argument of type 'import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom/dist/dts/Atom").Atom<boolean>' is not assignable to parameter of type 'import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom-react/node_modules/@effect-atom/atom/dist/dts/Atom").Atom<boolean>'.
  Types of property 'read' are incompatible.
    Type '(get: import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom/dist/dts/Atom").Context) => boolean' is not assignable to type '(get: import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom-react/node_modules/@effect-atom/atom/dist/dts/Atom").Context) => boolean'.
      Types of parameters 'get' and 'get' are incompatible.
        Type 'import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom-react/node_modules/@effect-atom/atom/dist/dts/Atom").Context' is not assignable to type 'import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom/dist/dts/Atom").Context'.
          Types of property 'get' are incompatible.
            Type '<A>(this: import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom-react/node_modules/@effect-atom/atom/dist/dts/Atom").Context, atom: import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom-react/node_modules/@effect-atom/atom/dist/dts/Atom").Atom<A>) => A' is not assignable to type '<A>(this: import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom/dist/dts/Atom").Context, atom: import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom/dist/dts/Atom").Atom<A>) => A'.
              The 'this' types of each signature are incompatible.
                Type 'import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom/dist/dts/Atom").Context' is not assignable to type 'import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom-react/node_modules/@effect-atom/atom/dist/dts/Atom").Context'.
                  Types of property 'result' are incompatible.
                    Type '<A, E>(this: import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom/dist/dts/Atom").Context, atom: import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom/dist/dts/Atom").Atom<import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom/dist/dts/Result").Result<A, E>>, options?: { ...; } | und...' is not assignable to type '<A, E>(this: import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom-react/node_modules/@effect-atom/atom/dist/dts/Atom").Context, atom: import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom-react/node_modules/@effect-atom/atom/dist/dts/Atom").Atom<import("/Users/prb/sablier/new-ui/node_modules/@...'.
                      Types of parameters 'atom' and 'atom' are incompatible.
                        Type 'import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom-react/node_modules/@effect-atom/atom/dist/dts/Atom").Atom<import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom-react/node_modules/@effect-atom/atom/dist/dts/Result").Result<A, E>>' is not assignable to type 'import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom/dist/dts/Atom").Atom<import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom/dist/dts/Result").Result<A, E>>'.
                          The types returned by 'read(...)' are incompatible between these types.
                            Type 'import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom-react/node_modules/@effect-atom/atom/dist/dts/Result").Result<A, E>' is not assignable to type 'import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom/dist/dts/Result").Result<A, E>'.
                              Type 'Failure<A, E>' is not assignable to type 'Result<A, E>'.
                                Property '[TypeId]' is missing in type 'import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom-react/node_modules/@effect-atom/atom/dist/dts/Result").Failure<A, E>' but required in type 'import("/Users/prb/sablier/new-ui/node_modules/@effect-atom/atom/dist/dts/Result").Failure<A, E>'.

Suggested Fix

Change @effect-atom/atom from dependencies to peerDependencies in @effect-atom/atom-react:

// package.json of @effect-atom/atom-react
{
-  "dependencies": {
-    "@effect-atom/atom": "^0.4.8"
-  },
   "peerDependencies": {
     "effect": "^3.19",
+    "@effect-atom/atom": "^0.4.0",
     "react": ">=18 <20",
     "scheduler": "*"
   }
}

Workaround

Add an override in the consumer's package.json:

{
  "overrides": {
    "@effect-atom/atom": "0.4.9"
  }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect the package.json for @effect-atom/atom-react, focusing on how @effect-atom/atom is listed in dependencies and peerDependencies. Verify the package metadata with the reported TypeScript setup and confirm that consumers use one compatible @effect-atom/atom installation without the nested copy or type mismatch.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.