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

fix(core): Fix issue in .d.ts typing for TextEncoder #7726

Merged
merged 1 commit into from
Feb 21, 2025

Conversation

danielkatz
Copy link
Contributor

Fixes #7247 without loosing the typing

This pull request makes a small but important change to the BytesOutputParser class in the langchain-core package. The change involves updating the type of the textEncoder property to use a more specific type.

globalThis.TextEncoder (when not imported from node:util) is a value, not a type. In this case, the type is actually InstanceType<typeof TextEncoder>.

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Feb 19, 2025
Copy link

vercel bot commented Feb 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 19, 2025 4:10pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Feb 19, 2025 4:10pm

@jacoblee93
Copy link
Collaborator

Nice! Makes sense

Any chance this would miss some other edge case? Given it's internal facing seems like some risk for not much reward

@danielkatz
Copy link
Contributor Author

Thanks for the feedback.

I encountered the same issue and, after researching, found the #7247 issue without a real solution.
Once I figured it out for myself, I decided to submit this PR to help others. I’ve been using this solution in production without encountering any related problems.

@jacoblee93
Copy link
Collaborator

jacoblee93 commented Feb 21, 2025

Ok thank you! Appreciate you digging in

@jacoblee93 jacoblee93 merged commit dd581e4 into langchain-ai:main Feb 21, 2025
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'TextEncoder' refers to a value, but is being used as a type here. Did you mean 'typeof TextEncoder'?
2 participants