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

[BUG] MaxInt instantiation is excessively deep and possibly infinite (TypeScript < 4.5) #88

Open
Michael-Ziluck opened this issue Oct 27, 2023 · 2 comments

Comments

@Michael-Ziluck
Copy link

Michael-Ziluck commented Oct 27, 2023

Error

When using TypeScript and the SDK, calling any function that uses MaxInt results in the following error:

TS2589: Type instantiation is excessively deep and possibly infinite.

When instantiating it in-line, the same thing also occurs:

const maxInt: MaxInt<50> = 50;

Even when trying it with the old version of MaxInt before #48 has the same problem. Not sure how others have not reported it yet.

Versions

Output from npm --versions:

{                            
  'project-name': '0.0.0',
  npm: '8.15.0',             
  node: '16.17.0',           
  v8: '9.4.146.26-node.22',  
  uv: '1.43.0',              
  zlib: '1.2.11',            
  brotli: '1.0.9',           
  ares: '1.18.1',            
  modules: '93',             
  nghttp2: '1.47.0',         
  napi: '8',                 
  llhttp: '6.0.7',           
  openssl: '1.1.1q+quic',    
  cldr: '41.0',              
  icu: '71.1',               
  tz: '2022a',               
  unicode: '14.0',           
  ngtcp2: '0.1.0-DEV',       
  nghttp3: '0.1.0-DEV'       
}     

Output from npm list:

[email protected] C:\Users\Michael\workspace\ProjectName
├── @angular-devkit/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @angular/[email protected]
├── @spotify/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
@Michael-Ziluck
Copy link
Author

It would appear it's because of TypeScript's depth limit. MaxInt<45> works fine, but MaxInt<46> and beyond all fail.

Also worth noting that MaxInt isn't even working as intended at the moment. This resolves and compiles fine when it should fail:

const pageSize: MaxInt<45> = 50;

@Michael-Ziluck
Copy link
Author

Discovered the source of the problem. This SDK does not constrain the TypeScript version but is unusable by any version of TypeScript before 4.5 as that is when they added tail-recursion elimination.

For now I'll just update but it is definitely worth looking into updating the package.json in this project to properly constrain packages.

@Michael-Ziluck Michael-Ziluck changed the title [BUG] MaxInt instantiation is excessively deep and possibly infinite [BUG] MaxInt instantiation is excessively deep and possibly infinite (TypeScript < 4.5) Oct 27, 2023
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

1 participant