dsherret / dsherret/conditional-type-checks
Unclear how to check for deep equality of nested types
- Dominant language
- TypeScript
- Stars
- 450
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
I have been trying to write an assertion that two types have an identical shape. They both contain a nested type. I can't figure out a way to check that this nested type is equal.
[Playground link.](https://www.typescriptlang.org/play?#code/PTAEGMHsDsBMEsAu8YEMA2BaRBPADgKabgAWB4A1gM6jrwBGEkeOmeqViBso9B6kAO4AaUFXAAnSOnShYQ6AChgAKhWLQK0AEEqVAhMQ1UiJgFs88dAVDIzNxCRO2yoPFIBu8WN1v4bqBIA5gCu9tCIAOQ0uISgEgRU0h6JtpAuNgQAHoTgXDz0kNIEqNC0SAYYfoQAdBpaAALsEqhmoNm5iAAqEiE2mKA9faDwAGYZbhz6PPBlsQHBYQQR8YnJvojpiL0EdZrAih2QhnLk6IE2oyHQeShlUwaIADxd7VlccDE7oAA+oKMYfQAPgAFB1yN0dgAuQYAShhHkg3gA3Mo1PUdHpHsZTFALFYHPB7C5nI4bO5IF4fDx5qBAqFwlEYv5Vkl0CkYlsdnsVAcjicfOBzglqjZdPpDEMCC83h9YF8+kDQABeUDQAgpCSo1TqTSYiVGOm4yD46y2IkOJymMluTzeDYs+lLCLRUWs9ac-6A3b1Pk5Y6mQXChws8WPABi3pl2TlNAB6GBKrVGoM2vRerDhhx5ksZrsltJrgpVIdcSdjNdtISbI5aQm4LyvkKxVK5S4LVk8x5frwAdOQoubszz1eMeW8ts3z+8f0ogAojkIb4x59BkrVerNWndVoAMJkSg0MZugAGXRPoCcMVcVFyY3gpZsJ4Aqifu4d-QKzoPaQAJDgvKIz7rqAACSVDaNAOAvEqK4TtswwAPyTsMMLgZB0HAbK44KjYyEzjYMILtsqB5IBoBYXBNCbgYoD4d6oAwghBDbhi+7kNQIzjLSZ4XvIqTQJAphOCkEy3uQ96PqAL5vr6H69l+A4irSAByQn-lQ5FYaqGlabB7w4V6CZ4ShhFGforF6uxh5cae54jDQvZ6Aw6A4GqIQyKAxyg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SKBHJOWcrEhgniE2ePskZNzQA-OuXwzZjzKAvJ2KcoAA)
If I add a property to one of the outer types, it yields an error. But adding a property to one of the inner types has no effect even though it should (I believe) produce a condition of insufficient overlap. This seems incorrect. Is this a bug or am I doing something wrong?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked TypeScript Playground and reproduce the difference between adding a property to an outer type and adding one to a nested type. Trace the assertion behavior for both cases and determine whether the nested-type result is expected; done means the behavior is explained and, if incorrect, corrected with coverage for the nested case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100