|
| 1 | +/* eslint-disable @seedcompany/no-unused-vars */ |
| 2 | +import { test } from '@jest/globals'; |
| 3 | +import type { User } from '../components/user'; |
| 4 | +import { ID } from './id-field'; |
| 5 | + |
| 6 | +test('only types here', () => undefined); |
| 7 | + |
| 8 | +const NameFromSelf: ID<'User'> = '' as ID<'User'>; |
| 9 | +const NameFromDB: ID<'User'> = '' as ID<'default::User'>; |
| 10 | +const NameFromInstance: ID<'User'> = '' as ID<User>; |
| 11 | +const NameFromStatic: ID<'User'> = '' as ID<typeof User>; |
| 12 | + |
| 13 | +const NameToSelf: ID<'User'> = '' as ID<'User'>; |
| 14 | +const NameToDB: ID<'default::User'> = '' as ID<'User'>; |
| 15 | +const NameToInstance: ID<User> = '' as ID<'User'>; |
| 16 | +const NameToStatic: ID<typeof User> = '' as ID<'User'>; |
| 17 | + |
| 18 | +const NameFromAny: ID<'User'> = '' as ID; |
| 19 | +const NameToAny: ID = '' as ID<'User'>; |
| 20 | + |
| 21 | +const AnyStringWorks: ID<'asdf'> = '' as ID; |
| 22 | +const AnyObjectWorks: ID<Date> = '' as ID; |
| 23 | + |
| 24 | +// @ts-expect-error this should be blocked |
| 25 | +const UserIncompatibleDifferent: ID<'User'> = '' as ID<'Location'>; |
| 26 | +// @ts-expect-error this should be blocked |
| 27 | +const UserIncompatibleDifferent2: ID<'Location'> = '' as ID<'User'>; |
| 28 | + |
| 29 | +const SubclassesAreCompatible: ID<'Engagement'> = |
| 30 | + '' as ID<'LanguageEngagement'>; |
| 31 | +// @ts-expect-error this should be blocked |
| 32 | +const InterfaceIsNotDirectlyCompatibleWithConcrete: ID<'LanguageEngagement'> = |
| 33 | + '' as ID<'Engagement'>; |
| 34 | +const ButCanBeTypeCastAsInterfaceOverlapsConcrete = |
| 35 | + '' as ID<'Engagement'> as ID<'LanguageEngagement'>; |
| 36 | +// @ts-expect-error this should be blocked |
| 37 | +const IndependentTypesCannotBeTypeCast = '' as ID<'Engagement'> as ID<'User'>; |
0 commit comments