fix: exposeAll strategy works with excludeExtraneousValues#1843
Open
kyungseopk1m wants to merge 1 commit intotypestack:developfrom
Open
fix: exposeAll strategy works with excludeExtraneousValues#1843kyungseopk1m wants to merge 1 commit intotypestack:developfrom
kyungseopk1m wants to merge 1 commit intotypestack:developfrom
Conversation
When strategy is explicitly set to 'exposeAll', preserve the keys collected from the source object instead of overwriting them with only decorator-registered exposed properties. Fixes typestack#740
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When strategy is explicitly set to 'exposeAll', preserve the keys collected from the source object instead of overwriting them with only decorator-registered exposed properties.
Fixes #740
Description
When using
strategy: 'exposeAll'withexcludeExtraneousValues: true,plainToInstance()returns{}instead of the expected properties. This happens becausegetKeys()unconditionally overwrites keys collected byexposeAllwithexposedProperties, which is empty for classes without@Expose()decorators.The fix checks
this.options.strategy(user-provided) so it only activates when the user explicitly opts in — existing behavior for classes using@Expose()without an explicit strategy is unchanged.Known limitation: With
exposeAll, TypeScript properties without initializers or decorators are not discoverable at runtime, soexcludeExtraneousValuescannot filter extraneous source properties in this combination. This is an inherent TypeScript limitation.Checklist
the pull request title describes what this PR does (not a vague title like
Update index.md)the pull request targets the default branch of the repository (
develop)the code follows the established code style of the repository
npm run prettier:checkpassesnpm run lint:checkpassestests are added for the changes I made (if any source code was modified)
documentation added or updated
I have run the project locally and verified that there are no errors
Fixes
fixes fix: ExposeAll does not work with excludeExtraneousValues #740