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

"Type instantiation is excessively deep and possibly infinite" when using default: null #402

Open
noisyscanner opened this issue Mar 25, 2022 · 5 comments

Comments

@noisyscanner
Copy link

Problem

As per the FAQ, we can make things required by setting default: null, if null is not a valid value.

With TypeScript I get the error Type instantiation is excessively deep and possibly infinite when trying to config.get any value, if somewhere in the schema there is default: null.

typescript 4.6.3
convict 6.2.1
@types/convict 6.1.1

(all versions latest at time of writing)

Repo here

https://github.com/noisyscanner/convict-issue
Run yarn build to see the following
image

@viliamsevela
Copy link

Yep, same here.

@TzachiSh
Copy link

+1

@heidimao
Copy link

Is this issue resolved? We also experience the same?

@justinasfour04
Copy link

Is it resolved. Can't use undefined or null for default

@justinasfour04
Copy link

justinasfour04 commented Jun 1, 2023

I found a solution, you have to cast your default to a type you want such as as string and the Type instantiation is excessively deep and possibly infinite error goes away. The reason this happens is that undefined | null point to the 'any' type. The recursive type defined that works to get the PathValue aka the type that get() returns can't find an end because of any. The type checker therefore thinks that you have an infinite recursion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants