objection.js: A problem with typescript version 4
Hi, objection.js is a great tool. I am using latest version of knex and typescript, so want to use objection@next but it is throwing error:
throw e;
^
RangeError: Maximum call stack size exceeded
at compareSignaturesRelated (\node_modules\typescript\lib\tsc.js:50982:27)
at signatureRelatedTo (\node_modules\typescript\lib\tsc.js:52833:24)
at signaturesRelatedTo (\node_modules\typescript\lib\tsc.js:52776:39)
at structuredTypeRelatedToWorker (\node_modules\typescript\lib\tsc.js:52309:39)
at structuredTypeRelatedTo (\node_modules\typescript\lib\tsc.js:51954:30)
at recursiveTypeRelatedTo (\node_modules\typescript\lib\tsc.js:51930:53)
at isRelatedTo (\node_modules\typescript\lib\tsc.js:51527:34)
at isPropertySymbolTypeRelated (\node_modules\typescript\lib\tsc.js:52488:24)
at propertyRelatedTo (\node_modules\typescript\lib\tsc.js:52520:31)
at propertiesRelatedTo (\node_modules\typescript\lib\tsc.js:52708:43)
package.json:
"objection": "^3.0.0-alpha.5",
"typescript": "^4.4.4"
Which version of objection.js and typescript should I use?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 25
Commits related to this issue
- attempt to fix a typescript performance/infinite recursion problem. See #2177, #2178 and #2132 — committed to Vincit/objection.js by koskimas 3 years ago
- Fix type issue, see Vincit/objection.js#2132 — committed to tanmaymishu/express-ts-starter by tanmaymishu 2 years ago
- Fix typescript performance / infinite recursion issues Closes #2132 — committed to inarix/objection.js by lehni a year ago
Hi! Same as @Linksku, I also need to wrap the declaration of
PartialModelGraph
withT extends any ? ... : never
. If I don’t do this, the types of “nested” models (from relationMappings) in a model graph are not inferred by TypeScript. However, I do not face aMaximum call stack size exceeded
error when compiling my project without this fix:@koskimas: Cloud you release a new version with the
T extends any ? ... : never
fix? I would be very grateful! 😃FYI: It does not matter if I set
strict: true
orstrict: false
in mytsconfig.json
file - in both cases, I still need theT extends any ? ... : never
fix.Package versions:
I’m running into this issue with the released version of 3.0.0
@koskimas are you saying that objection 3 requires
strict: true
to work properly with typescript? Is that documented anywhere? It seems like a pretty significant limitation.Hi, I have the same issue. Also fixed with the
T extends any ? ... : never
fix. Please can you release a new version with this included?I am getting the same error on Typescript 4.5.5 as well. I was able to get rid of the problem by setting
strictNullChecks: false
intsconfig.json
as mentioned in related issue but it’s just a temporary fix.@koskimas I think the issue is caused by
NonFunctionPropertyNames
includingQueryBuilderType
. It should go away by excludingQueryBuilderType
inPartialModelObject
andPartialModelGraph
:I’m not sure why I also needed
T extends any
forPartialModelGraph
, probably some weird union issue:I don’t think strict is required, but it will point out any errors in your model files. In my case the solution was to properly define the properties with the ! operator, e.g.
id!: string
Edit: Actually, strict is required for compilation.
Reproduction: https://github.com/stefanvanherwijnen/objection-repro-2132