Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive Interfaces Cause Infinite Paths #27

Open
anthonyjoeseph opened this issue Apr 11, 2022 · 1 comment · May be fixed by #28
Open

Recursive Interfaces Cause Infinite Paths #27

anthonyjoeseph opened this issue Apr 11, 2022 · 1 comment · May be fixed by #28
Labels
bug Something isn't working

Comments

@anthonyjoeseph
Copy link
Owner

anthonyjoeseph commented Apr 11, 2022

🐛 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
@anthonyjoeseph anthonyjoeseph added the bug Something isn't working label Apr 11, 2022
@anthonyjoeseph anthonyjoeseph linked a pull request Apr 11, 2022 that will close this issue
@chrisfernandes102
Copy link

Left a comment here: #19 (comment)

Running into the same problem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants