diff --git a/packages/example/src/routes/tests.tsx b/packages/example/src/routes/tests.tsx index a248009..c673f9e 100644 --- a/packages/example/src/routes/tests.tsx +++ b/packages/example/src/routes/tests.tsx @@ -4,6 +4,7 @@ import { createFileRoute } from "@tanstack/react-router" import { GetRandomValues, makeUuid4 } from "@typed/id" import { Console, Effect, Option } from "effect" import { useEffect, useState } from "react" +import { PropertyPath } from "reffuse/types" interface Node { @@ -11,6 +12,7 @@ interface Node { readonly left?: Node readonly right?: Node } +type NodePaths = PropertyPath.Paths const makeUuid = Effect.provide(makeUuid4, GetRandomValues.CryptoRandom) diff --git a/packages/reffuse/src/types/PropertyPath.ts b/packages/reffuse/src/types/PropertyPath.ts index de8e00c..50e35ed 100644 --- a/packages/reffuse/src/types/PropertyPath.ts +++ b/packages/reffuse/src/types/PropertyPath.ts @@ -1,15 +1,14 @@ import { Array, Function, Option, Predicate } from "effect" -import type { Includes } from "../utils.js" -export type Paths = [] | ( - Includes extends true ? [] : - T extends readonly any[] ? ArrayPaths : - T extends object ? ObjectPaths : +export type Paths = [] | ( + T extends Seen ? [] : + T extends readonly any[] ? ArrayPaths : + T extends object ? ObjectPaths : never ) -export type ArrayPaths = { +export type ArrayPaths = { [K in keyof T as K extends number ? K : never]: | [K] | [K, ...Paths] @@ -17,7 +16,7 @@ export type ArrayPaths = { ? O[keyof O] : never -export type ObjectPaths = { +export type ObjectPaths = { [K in keyof T as K extends string | number | symbol ? K : never]: | [K] | [K, ...Paths] diff --git a/packages/reffuse/src/utils.ts b/packages/reffuse/src/utils.ts index 72b5f00..d4abd6c 100644 --- a/packages/reffuse/src/utils.ts +++ b/packages/reffuse/src/utils.ts @@ -9,9 +9,3 @@ export type CommonKeys = Extract export type StaticType any> = Omit export type Merge = Omit> & Self - -export type Includes = T extends [infer Head, ...infer Tail] - ? (() => X extends Head ? 1 : 2) extends (() => X extends U ? 1 : 2) - ? true - : Includes - : false