mastodon.ar.al is one of the many independent Mastodon servers you can use to participate in the fediverse.
This is my personal fediverse server.

Administered by:

Server stats:

1
active users

Aral Balkan

Hit an interesting limit in the TypeScript language server¹:

Looks like there’s a limit on the number of entries an object (constant) can have before the language server balks. Seems to hit it around 1,343.

(I’m generating an object for an icon library.)

Doesn’t appear to be related to file/memory size (breaking up the same number of entries into several objects works).

Anyone know what limitation exactly I’m hitting (if it’s documented somewhere?) Been searching but couldn’t find any reference to it.

¹ It’s definitely a language server limit as I tried in VSCode as well to rule out it being a limit in Helix Editor.

Oddly, the error only surfaces in the file importing said exported constant (Module x has no exported member 'y') . In the file where the constant is defined, it all works fine.

🤷‍♂️

So it does look like the TypeScript language server has a limit of 4MB source size where it disables type checking (and actually shows an erroneous error stating that exports that exist in the file do not exist) for files that are imported but not open in the current workspace/session.

Still not sure if this is documented anywhere or not (haven’t been able to find it, if it is).

99.99999% of the time, unless you’re doing niche stuff like I am, you won’t run into this.

Workaround: should you have such a large file, e.g., with a large generated object, try and refactor to split it up into multiple files and rejoin it a separate file. The actual object size/memory usage isn’t the issue, it’s the file size.

github.com/typescript-language

GitHubServer fails on import when exported object constant has too many entries/is too large · Issue #951 · typescript-language-server/typescript-language-serverBy aral
#TypeScript#max#lines

@aral Weirdly unhelpful number too. If it was a power of 2 it might point you in the right direction, the fact that it's not suggests that it's a second order effect of whatever the actual limit is.

@woe2you Yeah; initially I was at the 4MB boundary so I thought it was a memory limit but turns out it wasn’t (I culled the size of the actual entries to check)x

@woe2you (That said, it fails at 1344, which is a factor of 2 and 16 but, still, an odd boundary. Wondering if it’s in the abstract syntax tree.)

@aral Quack quack.

(Being a rubber duck is probably all I can do for you here, but happy to)

@aral I don't know why but this reminded me of one oft hose playground "You're mamma's so fat.." jokes. 😆

@aral
It has been some time since I may played with it, but I remember Typescript documentation not being very good, at least one time the only reference to a feature I wanted to use existed only in a changelog.

@aral Great spot, though definitely niche!