spectacles-ts
spectacles-ts copied to clipboard
Recursive Interfaces Cause Infinite Paths
🐛 Bug report
Recursive Interfaces Cause Infinite Paths
Current Behavior
import { pipe } from 'fp-ts'
import { get } from 'spectacles-ts'
interface Recursive {
key: Recursive;
}
declare const r: Recursive
const key = pipe(r, get("key"))
// type instantiation is excessively deep and possibly infinite
// (it is infinite!)
Expected behavior
const key = pipe(r, get("key"))
// key: Recursive
Reproducible example
Types from the DOM are great test cases here
Element
, Document
etc.
Suggested solution(s)
Check at each Path that it does not extend one of its parent interfaces
Would allow exactly one traversal of a recursive interface
Should be simple, relatively lightweight (in that it wouldn't involve a distributive conditional) and (I don't think) would trigger false positives
Additional context
This shouldn't affect too too many use cases - 'get' on a DOM node, 'set' for a 'tree' value - anything else?
I don't think many people are using immutability helper or immer.js for this kind of thing
Your environment
Software | Version(s) |
---|---|
spectacles-ts | 1.0.7 |
fp-ts | 2.11 |
TypeScript | 4.6 |
Left a comment here: https://github.com/anthonyjoeseph/spectacles-ts/issues/19#issuecomment-1164811271
Running into the same problem :)