#Configure noTruncationMaximumTruncationLength

8 messages · Page 1 of 1 (latest)

gritty fulcrum
#

I'm getting the following error while compiling a project with some complex types

The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.

I've tried to change the noTruncationMaximumTruncationLength directly on tsc.js file inside my node modules, i modified it from a value of 1e6 to 1e7 and my project magically compiles now (also in under 7 seconds)

I would like to avoid writing the explicit annotation because the code is so much clearer. Also with this tweak it's still fast to compile.

My questions is: there is a way to configure this magic number inside tsconfig? I couldn't find it, also there are no open issues on this topic.

#
Files:                          635
Lines of Library:             41041
Lines of Definitions:         88925
Lines of TypeScript:            997
Lines of JavaScript:              0
Lines of JSON:                    0
Lines of Other:                   0
Identifiers:                 164265
Symbols:                     115829
Types:                        11919
Instantiations:               40008
Memory used:               2011460K
Assignability cache size:      4344
Identity cache size:             42
Subtype cache size:               0
Strict subtype cache size:        0
I/O Read time:                0.09s
Parse time:                   0.27s
ResolveModule time:           0.04s
ResolveTypeReference time:    0.01s
ResolveLibrary time:          0.01s
Program time:                 0.48s
Bind time:                    0.15s
Check time:                   0.22s
transformTime time:           6.90s
Source Map time:              0.00s
commentTime time:             1.05s
I/O Write time:               0.03s
printTime time:              11.00s
Emit time:                   11.00s
Total time:                  11.85s

With --extendedDiagnostics

#

Wow with the type annotation it uses 1.5GB less memory

Files:                         635
Lines of Library:            41041
Lines of Definitions:        88925
Lines of TypeScript:           999
Lines of JavaScript:             0
Lines of JSON:                   0
Lines of Other:                  0
Identifiers:                164273
Symbols:                    115831
Types:                       11924
Instantiations:              40008
Memory used:               552227K
Assignability cache size:     4356
Identity cache size:            42
Subtype cache size:              0
Strict subtype cache size:       0
I/O Read time:               0.09s
Parse time:                  0.27s
ResolveModule time:          0.04s
ResolveTypeReference time:   0.01s
ResolveLibrary time:         0.01s
Program time:                0.48s
Bind time:                   0.15s
Check time:                  0.21s
transformTime time:          0.76s
Source Map time:             0.00s
commentTime time:            0.18s
I/O Write time:              0.02s
printTime time:              1.52s
Emit time:                   1.53s
Total time:                  2.36s
dapper ridge
#

1.5GB less memory
that must be some type!

#

i can confirm that there is no tsconfig setting for this

#

what's the context? you may be able to break things up and only annotate some parts, or otherwise tweak things to make inference's job easier

gritty fulcrum
#

Yeah, it's a library like zod where I write the schema and from that it's infer many many types (like not only the type defined by the schema but also filter, sorts, selection, partial deeps, ecc...)
I'll try to improve this mapped types, thank you btw