Skip to content

Conversation

@JohannesMeierSE
Copy link
Collaborator

@JohannesMeierSE JohannesMeierSE commented Sep 4, 2025

This PR improves the handling of optional properties for custom types:

  • It fixes a bug reported in #77 when assigning undefined in explicit way to optional properties.
  • It fixes another bug when comparing optional custom properties for equality.
  • It enables to define properties for custom types using undefined in explicit way.

@JohannesMeierSE JohannesMeierSE added this to the v0.4 milestone Sep 4, 2025
# Conflicts:
#	CHANGELOG.md
#	packages/typir/src/kinds/custom/custom-type.ts
Copy link
Member

@insafuhrmann insafuhrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for these fixes @JohannesMeierSE. I am going to approve but I'd like to understand the topic in my detail remark.

### Fixed bugs

- Initializing optional properties of custom types with `undefined` failed, as reported in [#77](https://github.com/TypeFox/typir/discussions/77#discussioncomment-14149139).
- When checking the equality of custom types, the values for the same property might have different TypeScript types, since optional propeties might be set to `undefined`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- When checking the equality of custom types, the values for the same property might have different TypeScript types, since optional propeties might be set to `undefined`.
- When checking the equality of custom types, the values for the same property might have different TypeScript types, since optional properties might be set to `undefined`.

Copy link
Member

@insafuhrmann insafuhrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making the addition to the message. I think it is ready to go now.

firstValue: typeof value1,
secondValue: typeof value2,
firstValue: `'${String(value1)}' has the TypeScript type ${typeof value1}`,
secondValue: `'${String(value2)}' has the TypeScript type ${typeof value2}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this addition. Thanks!

@JohannesMeierSE JohannesMeierSE merged commit 14c0522 into main Oct 28, 2025
2 checks passed
@JohannesMeierSE JohannesMeierSE deleted the jm/77-fix-custom-types-optional-properties branch October 28, 2025 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants