Skip to content

fix: exposeAll strategy works with excludeExtraneousValues#1843

Open
kyungseopk1m wants to merge 1 commit intotypestack:developfrom
kyungseopk1m:fix/expose-all-exclude-extraneous
Open

fix: exposeAll strategy works with excludeExtraneousValues#1843
kyungseopk1m wants to merge 1 commit intotypestack:developfrom
kyungseopk1m:fix/expose-all-exclude-extraneous

Conversation

@kyungseopk1m
Copy link
Copy Markdown

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' with excludeExtraneousValues: true, plainToInstance() returns {} instead of the expected properties. This happens because getKeys() unconditionally overwrites keys collected by exposeAll with exposedProperties, 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, so excludeExtraneousValues cannot 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:check passes
    • npm run lint:check passes
  • tests 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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

fix: ExposeAll does not work with excludeExtraneousValues

1 participant