From 7757552c86b2005521e9951d346f9c59790fbb63 Mon Sep 17 00:00:00 2001 From: daishi Date: Mon, 2 Sep 2024 21:13:35 +0900 Subject: [PATCH 1/9] add stale discussions workflow --- .github/workflows/stale-discussions.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/stale-discussions.yml diff --git a/.github/workflows/stale-discussions.yml b/.github/workflows/stale-discussions.yml new file mode 100644 index 0000000000..6d97709ed3 --- /dev/null +++ b/.github/workflows/stale-discussions.yml @@ -0,0 +1,17 @@ +name: Close Stale Discussions + +on: + schedule: + - cron: '0 0 * * *' # Runs every day at midnight UTC + +jobs: + close-stale-discussions: + runs-on: ubuntu-latest + permissions: + discussions: write + steps: + - uses: steffen-karlsson/stalesweeper@v1.1.1 + with: + message: 'This discussion has been closed due to inactivity.' + days-before-close: 180 + close-unanswered: true From cbbe4a092ccd3b066c8161fd680aa204edad7339 Mon Sep 17 00:00:00 2001 From: daishi Date: Tue, 3 Sep 2024 12:20:07 +0900 Subject: [PATCH 2/9] wip: stale-discussions workflow --- .github/workflows/stale-discussions.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/stale-discussions.yml b/.github/workflows/stale-discussions.yml index 6d97709ed3..1ffd671fd0 100644 --- a/.github/workflows/stale-discussions.yml +++ b/.github/workflows/stale-discussions.yml @@ -15,3 +15,5 @@ jobs: message: 'This discussion has been closed due to inactivity.' days-before-close: 180 close-unanswered: true + dry-run: true + verbose: true From ce9f82064e954d22940b7a593cbed4b26bdabe1c Mon Sep 17 00:00:00 2001 From: daishi Date: Tue, 3 Sep 2024 12:29:40 +0900 Subject: [PATCH 3/9] wip: stale-discussions workflow 2 --- .github/workflows/stale-discussions.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/stale-discussions.yml b/.github/workflows/stale-discussions.yml index 1ffd671fd0..93db52f9ff 100644 --- a/.github/workflows/stale-discussions.yml +++ b/.github/workflows/stale-discussions.yml @@ -3,6 +3,7 @@ name: Close Stale Discussions on: schedule: - cron: '0 0 * * *' # Runs every day at midnight UTC + workflow_dispatch: jobs: close-stale-discussions: From cdc22257ad5f850dca4943ec4d0829e03feb8c82 Mon Sep 17 00:00:00 2001 From: daishi Date: Tue, 3 Sep 2024 12:34:29 +0900 Subject: [PATCH 4/9] wip: stale-discussions workflow 3 --- .github/workflows/stale-discussions.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/stale-discussions.yml b/.github/workflows/stale-discussions.yml index 93db52f9ff..1c97dfea45 100644 --- a/.github/workflows/stale-discussions.yml +++ b/.github/workflows/stale-discussions.yml @@ -16,5 +16,4 @@ jobs: message: 'This discussion has been closed due to inactivity.' days-before-close: 180 close-unanswered: true - dry-run: true verbose: true From 34794c0c7cb854d972feb6868f25641b3c0031dc Mon Sep 17 00:00:00 2001 From: Caleb Stimpson <70288813+probeiuscorp@users.noreply.github.com> Date: Sat, 7 Sep 2024 20:06:59 -0600 Subject: [PATCH 5/9] Mention connections to functional programming in README and docs (#2726) * docs: add docs page "Functional programming and Jotai" * Briefly mention monads in README * pnpm run prettier --- .../functional-programming-and-jotai.mdx | 68 +++++++++++++++++++ readme.md | 7 ++ 2 files changed, 75 insertions(+) create mode 100644 docs/basics/functional-programming-and-jotai.mdx diff --git a/docs/basics/functional-programming-and-jotai.mdx b/docs/basics/functional-programming-and-jotai.mdx new file mode 100644 index 0000000000..f1e08485ef --- /dev/null +++ b/docs/basics/functional-programming-and-jotai.mdx @@ -0,0 +1,68 @@ +--- +title: Functional programming and Jotai +nav: 6.04 +--- + +### Unexpected similarities + +If you look at getter functions long enough, you may see a striking resemblence +to a certain JavaScript language feature. + +```tsx +const nameAtom = atom('Visitor') +const countAtom = atom(1) +const greetingAtom = atom((get) => { + const name = get(nameAtom) + const count = get(countAtom) + return ( +
+ Hello, {nameAtom}! You have visited this page {countAtom} times. +
+ ) +}) +``` + +Now, compare that code with `async`–`await`: + +```tsx +const namePromise = Promise.resolve('Visitor') +const countPromise = Promise.resolve(1) +const greetingPromise = (async function () { + const name = await namePromise + const count = await countPromise + return ( +
+ Hello, {nameAtom}! You have visited this page {countAtom} times. +
+ ) +})() +``` + +This similarity is no coincidence. Both atoms and promises are **Monads**, a +concept from **functional programming**. The syntax used in both examples is +called **do-notation**, a syntax sugar for the plainer monad interface. + +--- + +The monad interface is responsible for the fluidity of the atom and promise +interfaces. The monad interface allowed us to define `greetingAtom` in terms of +`nameAtom` and `countAtom`, and allowed us to define `greetingPromise` in terms +of `namePromise` and `countPromise`. + +For the mathematically inclined, a structure (like `Atom` or `Promise`) is a +monad if you can implement the following functions for it. A fun exercise is +trying to implement `of`, `map` and `join` for Atoms, Promises and Arrays. + +```typescript +type SomeMonad = /* ... */ +declare function of(plainValue: T): SomeMonad +declare function map( + anInstance: SomeMonad, + transformContents: (contents: T) => V +): SomeMonad +declare function join(nestedInstances: SomeMonad>): SomeMonad +``` + +Monads have been an interest to mathematicians for 60 years, and to programmers +for 40. There are countless resources out there on patterns for monads, such +as `Traversable`–`sequence`. Take a look at them! diff --git a/readme.md b/readme.md index 0f5d339add..3c4408968b 100644 --- a/readme.md +++ b/readme.md @@ -160,6 +160,13 @@ function Controls() { ... ``` +### Note about functional programming + +Jotai's fluid interface is no accident — atoms are monads, just like promises! +Monads are an [established]() +pattern for modular, pure, robust and understandable code which is [optimized for change](https://overreacted.io/optimized-for-change/). +Read more about [Jotai and monads.](https://jotai.org/docs/basics/functional-programming-and-jotai) + ## Links - [website](https://jotai.org) From 74b3803a27d5082966c77fba01691ad813a261dd Mon Sep 17 00:00:00 2001 From: wen <35162226+sakurawen@users.noreply.github.com> Date: Sun, 8 Sep 2024 12:29:46 +0800 Subject: [PATCH 6/9] docs: fix variable reference error in functional-programming-and-jotai.mdx (#2727) --- docs/basics/functional-programming-and-jotai.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/basics/functional-programming-and-jotai.mdx b/docs/basics/functional-programming-and-jotai.mdx index f1e08485ef..24aa4cb4c3 100644 --- a/docs/basics/functional-programming-and-jotai.mdx +++ b/docs/basics/functional-programming-and-jotai.mdx @@ -16,7 +16,7 @@ const greetingAtom = atom((get) => { const count = get(countAtom) return (
- Hello, {nameAtom}! You have visited this page {countAtom} times. + Hello, {name}! You have visited this page {count} times.
) }) @@ -32,7 +32,7 @@ const greetingPromise = (async function () { const count = await countPromise return (
- Hello, {nameAtom}! You have visited this page {countAtom} times. + Hello, {name}! You have visited this page {count} times.
) })() From 9b835851a57b5e7333aa4c52a7f1833bea24b8e9 Mon Sep 17 00:00:00 2001 From: Caleb Stimpson <70288813+probeiuscorp@users.noreply.github.com> Date: Tue, 10 Sep 2024 19:11:52 -0600 Subject: [PATCH 7/9] docs(functional): cover sequence (#2729) * docs(functional): cover sequence * docs(functional): add notes section --- .../functional-programming-and-jotai.mdx | 92 ++++++++++++++++--- 1 file changed, 79 insertions(+), 13 deletions(-) diff --git a/docs/basics/functional-programming-and-jotai.mdx b/docs/basics/functional-programming-and-jotai.mdx index 24aa4cb4c3..c259d04c9b 100644 --- a/docs/basics/functional-programming-and-jotai.mdx +++ b/docs/basics/functional-programming-and-jotai.mdx @@ -22,7 +22,7 @@ const greetingAtom = atom((get) => { }) ``` -Now, compare that code with `async`–`await`: +Compare that code with `async`–`await`: ```tsx const namePromise = Promise.resolve('Visitor') @@ -38,31 +38,97 @@ const greetingPromise = (async function () { })() ``` -This similarity is no coincidence. Both atoms and promises are **Monads**, a -concept from **functional programming**. The syntax used in both examples is -called **do-notation**, a syntax sugar for the plainer monad interface. +This similarity is no coincidence. Both atoms and promises are **Monads**†, a +concept from functional programming. The syntax used in both `greetingAtom` and +`greetingPromise` is known as **do-notation**, a syntax sugar for the plainer +monad interface. ---- +### About monads The monad interface is responsible for the fluidity of the atom and promise interfaces. The monad interface allowed us to define `greetingAtom` in terms of `nameAtom` and `countAtom`, and allowed us to define `greetingPromise` in terms of `namePromise` and `countPromise`. -For the mathematically inclined, a structure (like `Atom` or `Promise`) is a -monad if you can implement the following functions for it. A fun exercise is -trying to implement `of`, `map` and `join` for Atoms, Promises and Arrays. +If you're curious, a structure (like `Atom` or `Promise`) is a monad if you can +implement the following functions for it. A fun exercise is trying to implement +`of`, `map` and `join` for Arrays. -```typescript -type SomeMonad = /* ... */ +```ts +type SomeMonad = /* for example... */ Array declare function of(plainValue: T): SomeMonad declare function map( anInstance: SomeMonad, - transformContents: (contents: T) => V + transformContents: (contents: T) => V, ): SomeMonad declare function join(nestedInstances: SomeMonad>): SomeMonad ``` +The shared heritage of Promises and Atoms means many patterns and best-practices +can be reused between them. Let's take a look at one. + +### Sequencing + +When talking about callback hell, we often mention the boilerplate, the +indentation and the easy-to-miss mistakes. However, plumbing a single async +operation into another single async operation was not the end of the callback +struggle. What if we made four network calls and needed to wait for them all? +A snippet like this was common: + +```ts +const nPending = 4 +const results: string[] +function callback(err, data) { + if (err) throw err + results.push(data) + if (results.length === nPending) { + // do something with results... + } +} +``` + +But what if the results have different types? and the order was important? Well, +we'd have a lot more frustrating work to do! This logic would be duplicated at +each usage, and would be easy to mess up. Since ES6, we simply call `Promise.all`: + +```ts +declare function promiseAll(promises: Array>): Promise> +``` + +`Promise.all` "rearranges" `Array` and `Promise`. It turns out this concept, +_sequencing_, can be implemented for all monad–_Traversable_ pairs. Many kinds +of collections are Traversables, including Arrays. For example, this is a case +of sequencing specialized for atoms and arrays: + +```ts +function sequenceAtomArray(atoms: Array>): Atom> { + return atom((get) => atoms.map(get)) +} +``` + +### Culmination + Monads have been an interest to mathematicians for 60 years, and to programmers -for 40. There are countless resources out there on patterns for monads, such -as `Traversable`–`sequence`. Take a look at them! +for 40. There are many resources out there on patterns for monads. Take a look +at them! Here are a select few: + +- [_Inventing Monads_](https://stopa.io/post/247) by Stepan Parunashvili +- [_How Monads Solve Problems_](https://thatsnomoon.dev/posts/ts-monads/) by ThatsNoMoon +- Wiki page [list of monad tutorials](https://wiki.haskell.org/Monad_tutorials_timeline) +- [Typeclassopedia](https://wiki.haskell.org/Typeclassopedia) (for the curious) + +Learning a neat trick on using promises may well translate to atoms, as +`Promise.all` and `sequenceAtomArray` did. Monads are not magic, just unusually +useful, and a tool worth knowing. + +--- + +_Notes_ + +**[†]** The ES6 Promise is not a completely valid monad because it cannot nest other +Promises, e.g. `Promise>` is semantically equivalent to +`Promise`. This is why Promises only have a `.then`, and not both a +`.map` and `.flatMap`. ES6 Promises are probably more properly described as +"monadic" rather than as monads. + +Unlike ES6 Promises, the ES6 Array is a completely lawful monad. From ab68d4de4440d298e57f8ffa1faec7fcc7a68bdd Mon Sep 17 00:00:00 2001 From: daishi Date: Sun, 15 Sep 2024 10:29:54 +0900 Subject: [PATCH 8/9] remove stale-discussions.yml for now --- .github/workflows/stale-discussions.yml | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .github/workflows/stale-discussions.yml diff --git a/.github/workflows/stale-discussions.yml b/.github/workflows/stale-discussions.yml deleted file mode 100644 index 1c97dfea45..0000000000 --- a/.github/workflows/stale-discussions.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Close Stale Discussions - -on: - schedule: - - cron: '0 0 * * *' # Runs every day at midnight UTC - workflow_dispatch: - -jobs: - close-stale-discussions: - runs-on: ubuntu-latest - permissions: - discussions: write - steps: - - uses: steffen-karlsson/stalesweeper@v1.1.1 - with: - message: 'This discussion has been closed due to inactivity.' - days-before-close: 180 - close-unanswered: true - verbose: true From a26203efb74902c4306206593b9bd6cabf14a1ad Mon Sep 17 00:00:00 2001 From: Daishi Kato Date: Sun, 15 Sep 2024 10:42:45 +0900 Subject: [PATCH 9/9] chore: enable isolatedDeclarations (#2687) * experimental: enable isolatedDeclarations * update typescript --- .github/workflows/test-old-typescript.yml | 3 + package.json | 2 +- pnpm-lock.yaml | 94 +++++++++++------------ src/babel/utils.ts | 2 +- src/vanilla/utils/constants.ts | 2 +- tsconfig.json | 2 + 6 files changed, 55 insertions(+), 50 deletions(-) diff --git a/.github/workflows/test-old-typescript.yml b/.github/workflows/test-old-typescript.yml index 778c4aafed..565d145c45 100644 --- a/.github/workflows/test-old-typescript.yml +++ b/.github/workflows/test-old-typescript.yml @@ -41,6 +41,9 @@ jobs: cache-dependency-path: '**/pnpm-lock.yaml' - run: pnpm install --frozen-lockfile - run: pnpm build + - name: Patch for all TS + run: | + sed -i~ 's/"isolatedDeclarations": true,//' tsconfig.json - name: Patch for v4/v3 TS if: ${{ startsWith(matrix.typescript, '4.') || startsWith(matrix.typescript, '3.') }} run: | diff --git a/package.json b/package.json index 448cbd9a35..3de83dc1f4 100644 --- a/package.json +++ b/package.json @@ -169,7 +169,7 @@ "ts-expect": "^1.3.0", "ts-node": "^10.9.2", "tslib": "^2.6.3", - "typescript": "^5.5.4", + "typescript": "^5.6.2", "vitest": "^2.0.5", "wonka": "^6.3.4" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3b48a57926..35b87b7b5f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -43,7 +43,7 @@ devDependencies: version: 0.4.4(rollup@4.20.0) '@rollup/plugin-typescript': specifier: ^11.1.6 - version: 11.1.6(rollup@4.20.0)(tslib@2.6.3)(typescript@5.5.4) + version: 11.1.6(rollup@4.20.0)(tslib@2.6.3)(typescript@5.6.2) '@testing-library/dom': specifier: ^10.4.0 version: 10.4.0 @@ -70,10 +70,10 @@ devDependencies: version: 18.3.0 '@typescript-eslint/eslint-plugin': specifier: ^8.1.0 - version: 8.1.0(@typescript-eslint/parser@8.1.0)(eslint@8.57.0)(typescript@5.5.4) + version: 8.1.0(@typescript-eslint/parser@8.1.0)(eslint@8.57.0)(typescript@5.6.2) '@typescript-eslint/parser': specifier: ^8.1.0 - version: 8.1.0(eslint@8.57.0)(typescript@5.5.4) + version: 8.1.0(eslint@8.57.0)(typescript@5.6.2) '@vitest/coverage-v8': specifier: ^2.0.5 version: 2.0.5(vitest@2.0.5) @@ -115,7 +115,7 @@ devDependencies: version: 4.6.2(eslint@8.57.0) eslint-plugin-vitest: specifier: ^0.5.4 - version: 0.5.4(@typescript-eslint/eslint-plugin@8.1.0)(eslint@8.57.0)(typescript@5.5.4)(vitest@2.0.5) + version: 0.5.4(@typescript-eslint/eslint-plugin@8.1.0)(eslint@8.57.0)(typescript@5.6.2)(vitest@2.0.5) jest-leak-detector: specifier: ^29.7.0 version: 29.7.0 @@ -160,13 +160,13 @@ devDependencies: version: 1.3.0 ts-node: specifier: ^10.9.2 - version: 10.9.2(@types/node@22.2.0)(typescript@5.5.4) + version: 10.9.2(@types/node@22.2.0)(typescript@5.6.2) tslib: specifier: ^2.6.3 version: 2.6.3 typescript: - specifier: ^5.5.4 - version: 5.5.4 + specifier: ^5.6.2 + version: 5.6.2 vitest: specifier: ^2.0.5 version: 2.0.5(@types/node@22.2.0)(@vitest/ui@2.0.5)(jsdom@24.1.1) @@ -2196,7 +2196,7 @@ packages: terser: 5.31.5 dev: true - /@rollup/plugin-typescript@11.1.6(rollup@4.20.0)(tslib@2.6.3)(typescript@5.5.4): + /@rollup/plugin-typescript@11.1.6(rollup@4.20.0)(tslib@2.6.3)(typescript@5.6.2): resolution: {integrity: sha512-R92yOmIACgYdJ7dJ97p4K69I8gg6IEHt8M7dUBxN3W6nrO8uUxX5ixl0yU/N3aZTi8WhPuICvOHXQvF6FaykAA==} engines: {node: '>=14.0.0'} peerDependencies: @@ -2213,7 +2213,7 @@ packages: resolve: 1.22.8 rollup: 4.20.0 tslib: 2.6.3 - typescript: 5.5.4 + typescript: 5.6.2 dev: true /@rollup/pluginutils@5.1.0(rollup@4.20.0): @@ -2493,7 +2493,7 @@ packages: resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} dev: true - /@typescript-eslint/eslint-plugin@8.1.0(@typescript-eslint/parser@8.1.0)(eslint@8.57.0)(typescript@5.5.4): + /@typescript-eslint/eslint-plugin@8.1.0(@typescript-eslint/parser@8.1.0)(eslint@8.57.0)(typescript@5.6.2): resolution: {integrity: sha512-LlNBaHFCEBPHyD4pZXb35mzjGkuGKXU5eeCA1SxvHfiRES0E82dOounfVpL4DCqYvJEKab0bZIA0gCRpdLKkCw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: @@ -2505,22 +2505,22 @@ packages: optional: true dependencies: '@eslint-community/regexpp': 4.11.0 - '@typescript-eslint/parser': 8.1.0(eslint@8.57.0)(typescript@5.5.4) + '@typescript-eslint/parser': 8.1.0(eslint@8.57.0)(typescript@5.6.2) '@typescript-eslint/scope-manager': 8.1.0 - '@typescript-eslint/type-utils': 8.1.0(eslint@8.57.0)(typescript@5.5.4) - '@typescript-eslint/utils': 8.1.0(eslint@8.57.0)(typescript@5.5.4) + '@typescript-eslint/type-utils': 8.1.0(eslint@8.57.0)(typescript@5.6.2) + '@typescript-eslint/utils': 8.1.0(eslint@8.57.0)(typescript@5.6.2) '@typescript-eslint/visitor-keys': 8.1.0 eslint: 8.57.0 graphemer: 1.4.0 ignore: 5.3.2 natural-compare: 1.4.0 - ts-api-utils: 1.3.0(typescript@5.5.4) - typescript: 5.5.4 + ts-api-utils: 1.3.0(typescript@5.6.2) + typescript: 5.6.2 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser@8.1.0(eslint@8.57.0)(typescript@5.5.4): + /@typescript-eslint/parser@8.1.0(eslint@8.57.0)(typescript@5.6.2): resolution: {integrity: sha512-U7iTAtGgJk6DPX9wIWPPOlt1gO57097G06gIcl0N0EEnNw8RGD62c+2/DiP/zL7KrkqnnqF7gtFGR7YgzPllTA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: @@ -2532,11 +2532,11 @@ packages: dependencies: '@typescript-eslint/scope-manager': 8.1.0 '@typescript-eslint/types': 8.1.0 - '@typescript-eslint/typescript-estree': 8.1.0(typescript@5.5.4) + '@typescript-eslint/typescript-estree': 8.1.0(typescript@5.6.2) '@typescript-eslint/visitor-keys': 8.1.0 debug: 4.3.6 eslint: 8.57.0 - typescript: 5.5.4 + typescript: 5.6.2 transitivePeerDependencies: - supports-color dev: true @@ -2557,7 +2557,7 @@ packages: '@typescript-eslint/visitor-keys': 8.1.0 dev: true - /@typescript-eslint/type-utils@8.1.0(eslint@8.57.0)(typescript@5.5.4): + /@typescript-eslint/type-utils@8.1.0(eslint@8.57.0)(typescript@5.6.2): resolution: {integrity: sha512-oLYvTxljVvsMnldfl6jIKxTaU7ok7km0KDrwOt1RHYu6nxlhN3TIx8k5Q52L6wR33nOwDgM7VwW1fT1qMNfFIA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: @@ -2566,11 +2566,11 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 8.1.0(typescript@5.5.4) - '@typescript-eslint/utils': 8.1.0(eslint@8.57.0)(typescript@5.5.4) + '@typescript-eslint/typescript-estree': 8.1.0(typescript@5.6.2) + '@typescript-eslint/utils': 8.1.0(eslint@8.57.0)(typescript@5.6.2) debug: 4.3.6 - ts-api-utils: 1.3.0(typescript@5.5.4) - typescript: 5.5.4 + ts-api-utils: 1.3.0(typescript@5.6.2) + typescript: 5.6.2 transitivePeerDependencies: - eslint - supports-color @@ -2586,7 +2586,7 @@ packages: engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} dev: true - /@typescript-eslint/typescript-estree@7.18.0(typescript@5.5.4): + /@typescript-eslint/typescript-estree@7.18.0(typescript@5.6.2): resolution: {integrity: sha512-aP1v/BSPnnyhMHts8cf1qQ6Q1IFwwRvAQGRvBFkWlo3/lH29OXA3Pts+c10nxRxIBrDnoMqzhgdwVe5f2D6OzA==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: @@ -2602,13 +2602,13 @@ packages: is-glob: 4.0.3 minimatch: 9.0.5 semver: 7.6.3 - ts-api-utils: 1.3.0(typescript@5.5.4) - typescript: 5.5.4 + ts-api-utils: 1.3.0(typescript@5.6.2) + typescript: 5.6.2 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/typescript-estree@8.1.0(typescript@5.5.4): + /@typescript-eslint/typescript-estree@8.1.0(typescript@5.6.2): resolution: {integrity: sha512-NTHhmufocEkMiAord/g++gWKb0Fr34e9AExBRdqgWdVBaKoei2dIyYKD9Q0jBnvfbEA5zaf8plUFMUH6kQ0vGg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: @@ -2624,13 +2624,13 @@ packages: is-glob: 4.0.3 minimatch: 9.0.5 semver: 7.6.3 - ts-api-utils: 1.3.0(typescript@5.5.4) - typescript: 5.5.4 + ts-api-utils: 1.3.0(typescript@5.6.2) + typescript: 5.6.2 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/utils@7.18.0(eslint@8.57.0)(typescript@5.5.4): + /@typescript-eslint/utils@7.18.0(eslint@8.57.0)(typescript@5.6.2): resolution: {integrity: sha512-kK0/rNa2j74XuHVcoCZxdFBMF+aq/vH83CXAOHieC+2Gis4mF8jJXT5eAfyD3K0sAxtPuwxaIOIOvhwzVDt/kw==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: @@ -2639,14 +2639,14 @@ packages: '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) '@typescript-eslint/scope-manager': 7.18.0 '@typescript-eslint/types': 7.18.0 - '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.5.4) + '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.6.2) eslint: 8.57.0 transitivePeerDependencies: - supports-color - typescript dev: true - /@typescript-eslint/utils@8.1.0(eslint@8.57.0)(typescript@5.5.4): + /@typescript-eslint/utils@8.1.0(eslint@8.57.0)(typescript@5.6.2): resolution: {integrity: sha512-ypRueFNKTIFwqPeJBfeIpxZ895PQhNyH4YID6js0UoBImWYoSjBsahUn9KMiJXh94uOjVBgHD9AmkyPsPnFwJA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: @@ -2655,7 +2655,7 @@ packages: '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) '@typescript-eslint/scope-manager': 8.1.0 '@typescript-eslint/types': 8.1.0 - '@typescript-eslint/typescript-estree': 8.1.0(typescript@5.5.4) + '@typescript-eslint/typescript-estree': 8.1.0(typescript@5.6.2) eslint: 8.57.0 transitivePeerDependencies: - supports-color @@ -3360,7 +3360,7 @@ packages: dependencies: semver: 7.6.3 shelljs: 0.8.5 - typescript: 5.6.0-dev.20240812 + typescript: 5.7.0-dev.20240904 dev: true /eastasianwidth@0.2.0: @@ -3630,7 +3630,7 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 8.1.0(eslint@8.57.0)(typescript@5.5.4) + '@typescript-eslint/parser': 8.1.0(eslint@8.57.0)(typescript@5.6.2) debug: 3.2.7 eslint: 8.57.0 eslint-import-resolver-node: 0.3.9 @@ -3648,7 +3648,7 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 8.1.0(eslint@8.57.0)(typescript@5.5.4) + '@typescript-eslint/parser': 8.1.0(eslint@8.57.0)(typescript@5.6.2) array-includes: 3.1.8 array.prototype.findlastindex: 1.2.5 array.prototype.flat: 1.3.2 @@ -3747,7 +3747,7 @@ packages: string.prototype.repeat: 1.0.0 dev: true - /eslint-plugin-vitest@0.5.4(@typescript-eslint/eslint-plugin@8.1.0)(eslint@8.57.0)(typescript@5.5.4)(vitest@2.0.5): + /eslint-plugin-vitest@0.5.4(@typescript-eslint/eslint-plugin@8.1.0)(eslint@8.57.0)(typescript@5.6.2)(vitest@2.0.5): resolution: {integrity: sha512-um+odCkccAHU53WdKAw39MY61+1x990uXjSPguUCq3VcEHdqJrOb8OTMrbYlY6f9jAKx7x98kLVlIe3RJeJqoQ==} engines: {node: ^18.0.0 || >= 20.0.0} peerDependencies: @@ -3760,8 +3760,8 @@ packages: vitest: optional: true dependencies: - '@typescript-eslint/eslint-plugin': 8.1.0(@typescript-eslint/parser@8.1.0)(eslint@8.57.0)(typescript@5.5.4) - '@typescript-eslint/utils': 7.18.0(eslint@8.57.0)(typescript@5.5.4) + '@typescript-eslint/eslint-plugin': 8.1.0(@typescript-eslint/parser@8.1.0)(eslint@8.57.0)(typescript@5.6.2) + '@typescript-eslint/utils': 7.18.0(eslint@8.57.0)(typescript@5.6.2) eslint: 8.57.0 vitest: 2.0.5(@types/node@22.2.0)(@vitest/ui@2.0.5)(jsdom@24.1.1) transitivePeerDependencies: @@ -5779,20 +5779,20 @@ packages: punycode: 2.3.1 dev: true - /ts-api-utils@1.3.0(typescript@5.5.4): + /ts-api-utils@1.3.0(typescript@5.6.2): resolution: {integrity: sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==} engines: {node: '>=16'} peerDependencies: typescript: '>=4.2.0' dependencies: - typescript: 5.5.4 + typescript: 5.6.2 dev: true /ts-expect@1.3.0: resolution: {integrity: sha512-e4g0EJtAjk64xgnFPD6kTBUtpnMVzDrMb12N1YZV0VvSlhnVT3SGxiYTLdGy8Q5cYHOIC/FAHmZ10eGrAguicQ==} dev: true - /ts-node@10.9.2(@types/node@22.2.0)(typescript@5.5.4): + /ts-node@10.9.2(@types/node@22.2.0)(typescript@5.6.2): resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==} hasBin: true peerDependencies: @@ -5818,7 +5818,7 @@ packages: create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 5.5.4 + typescript: 5.6.2 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 dev: true @@ -5897,14 +5897,14 @@ packages: possible-typed-array-names: 1.0.0 dev: true - /typescript@5.5.4: - resolution: {integrity: sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==} + /typescript@5.6.2: + resolution: {integrity: sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==} engines: {node: '>=14.17'} hasBin: true dev: true - /typescript@5.6.0-dev.20240812: - resolution: {integrity: sha512-TR3m7teVCHUhgqmFTj3TKFevzF4GMWOvesnhjWlBfUn3TRy4Z3xhJ9FzxzeEfupEqNWOagszD1Q0Ym46BtyE2g==} + /typescript@5.7.0-dev.20240904: + resolution: {integrity: sha512-iGi6VWFGOuxPvDfwfK1/8C172NWzC5gtC4G2dxqCQehrr86WTfFkc9aWucynaxZdwQNMqG1Iu83bmXD7CNHCmg==} engines: {node: '>=14.17'} hasBin: true dev: true diff --git a/src/babel/utils.ts b/src/babel/utils.ts index dc7f7038c3..95e33ebd39 100644 --- a/src/babel/utils.ts +++ b/src/babel/utils.ts @@ -8,7 +8,7 @@ export function isAtom( t: typeof types, callee: babel.types.Expression | babel.types.V8IntrinsicIdentifier, customAtomNames: PluginOptions['customAtomNames'] = [], -) { +): boolean { const atomNames = [...atomFunctionNames, ...customAtomNames] if (t.isIdentifier(callee) && atomNames.includes(callee.name)) { return true diff --git a/src/vanilla/utils/constants.ts b/src/vanilla/utils/constants.ts index 0b35c80e60..3ccf5091a8 100644 --- a/src/vanilla/utils/constants.ts +++ b/src/vanilla/utils/constants.ts @@ -1,3 +1,3 @@ -export const RESET = Symbol( +export const RESET: unique symbol = Symbol( import.meta.env?.MODE !== 'production' ? 'RESET' : '', ) diff --git a/tsconfig.json b/tsconfig.json index cd0a84083b..e91385a96a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,8 @@ "noUncheckedIndexedAccess": true, "exactOptionalPropertyTypes": true, "verbatimModuleSyntax": true, + "declaration": true, + "isolatedDeclarations": true, "noEmit": true, "baseUrl": ".", "paths": {