Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Endless recursion in getTypeName() #66

Closed
urish opened this issue Apr 17, 2018 · 0 comments
Closed

Endless recursion in getTypeName() #66

urish opened this issue Apr 17, 2018 · 0 comments
Assignees
Labels
bug Something isn't working component:core

Comments

@urish
Copy link
Collaborator

urish commented Apr 17, 2018

This happens when an object contains a getter that calls another function, passing the original object as a parameter.

For example, the following code will make TypeWiz throw a RangeError at runtime:

function log(o: { someVal: number }) {
  console.log(o);
}
function f(o: { someVal: number }) {
  return o.someVal;
}
const obj = {
  get someVal() {
    // this will cause TypeWiz to enter an endless recursion when it tries to enumerate to object's keys:
    log(this);
    return 5;
  }
};
f(obj);

Found while working on immerjs/immer#128

@urish urish added bug Something isn't working component:core labels Apr 17, 2018
@urish urish self-assigned this Apr 17, 2018
@urish urish closed this as completed in 4443563 Apr 17, 2018
urish added a commit that referenced this issue Apr 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working component:core
Projects
None yet
Development

No branches or pull requests

1 participant