-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(type): keep same shaped but different interface in a union.
- Loading branch information
Showing
4 changed files
with
23 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { test, expect } from '@jest/globals'; | ||
import { typeOf } from '../src/reflection/reflection.js'; | ||
import { assertType, ReflectionKind } from '../src/reflection/type.js'; | ||
|
||
test('union empty interfaces', () => { | ||
interface Dog { | ||
} | ||
|
||
interface Cat { | ||
} | ||
|
||
//If two objectLiterals have the same shape, they are filtered out by flattenUnionTypes + isTypeIncluded. | ||
//we se type.typeName additional now, so they are not filtered out. If this breaks in the future, | ||
//we need to find a different way to filter out the same shapes. | ||
const type = typeOf<Cat | Dog>(); | ||
assertType(type, ReflectionKind.union); | ||
assertType(type.types[0], ReflectionKind.objectLiteral); | ||
assertType(type.types[1], ReflectionKind.objectLiteral); | ||
expect(type.types).toHaveLength(2); | ||
}); |