-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Export SourceFileObject and friends #57073
Comments
I doubt that we'd want to export these internal objects just so someone can patch the prototype. They are an implementation detail which may change; exporting them closes the door to improvements behind the scene (and we have at least two different performance related changes in the works that would modify them or remove them entirely). Can you be more specific as to what sort of "patching" you are trying to do? How does being able to touch these objects relate to your use cases? |
Debugging it more, it was more an issue with I guess a more generic ask is making sure that if we reserialize the JSON-able parts of SourceFile, that there aren't any properties or methods that would be called on it (and objects it contains) that are dependent on it having a non-Object prototype |
Note, this does already seem to be the case (outside of the Services and Map use case I pointed out above) but I wanted to make sure this is a constraint the Typescript team is interested in maintaining especially give the compiler API is still marked as not stable and if it made sense for the Typescript team to own serialize/deserialize (#26871) if this is not the case |
The Is doing what you need impossible externally? There's a lot of internal stuff on loads of objects. I would almost imagine it'd be easier to fix those up externally (and use Right now, we really only ensure diagnostics are serializable, as that is needed for monaco and so on. |
I'm still working on this. Got sidetracked with work from my day job and I'll get back to you on if I can use ts-expose-internals |
#58045 and other PRs are messing with these classes, and we are also wanting to do away with them entirely by moving them into the compiler. I'm not super inclined to export these, at least not until we do away with the "allocator" construct entirely. |
π Search Terms
AST parse SourceFileObject
β Viability Checklist
β Suggestion
I'm following the suggestion at #3662 (comment) but the prototypes to patch aren't exposed (i.e. https://github.com/microsoft/TypeScript/blob/main/src/services/services.ts#L1003).
I'm happy to hack around this for my testing but wanted to see if there's a path to exposing this publicly.
Related Issues
#26871
#30235
#54256
π Motivating Example
Allowing external build tools that run tsc invocations in parallel to be faster by not repeating the source file parse.
π» Use Cases
I'm working on a build system and would like to make parallel invocations of tsc faster by not having to reparse declarations coming from shared dependencies.
Commonly used declaration files like @types/node get reparsed multiple time when splitting tsc compilation across multiple invocations.
Ideally we'd allow each of the invocations to live in their own sandbox. So we wouldn't rely on a shared language service to keep the parsed files in memory.
Living with multiple calls to tsc repeating work (especially for the expensive node types)/relying on managing typescript services
The text was updated successfully, but these errors were encountered: