|
| 1 | +import { |
| 2 | + Configuration, |
| 3 | + GenericClass, |
| 4 | + GenericInterface, |
| 5 | + Option, |
| 6 | + Superinterface, |
| 7 | +} from './reusable-types' |
| 8 | + |
| 9 | +export function consumesInterface(superInterface: Superinterface): void {} |
| 10 | +export function consumesArray(superInterface: Superinterface[]): void {} |
| 11 | +export function consumesGenericInterface<T>( |
| 12 | + genercInterface: GenericInterface<T> |
| 13 | +): void {} |
| 14 | + |
| 15 | +export function infersInterface(): void { |
| 16 | + consumesInterface({ |
| 17 | + interfaceMethod: (): string => 'inferred', |
| 18 | + property: 'inferred', |
| 19 | + }) |
| 20 | + consumesArray([ |
| 21 | + { |
| 22 | + interfaceMethod: (): string => 'inferred', |
| 23 | + property: 'inferred', |
| 24 | + }, |
| 25 | + ]) |
| 26 | + consumesGenericInterface<number>({ |
| 27 | + interfaceMethod: (): string => 'inferred', |
| 28 | + property: 123, |
| 29 | + }) |
| 30 | + consumesGenericInterface<Option<Configuration>[]>({ |
| 31 | + interfaceMethod: (): string => 'inferred', |
| 32 | + property: [{ value: { property: 42, property2: '42' } }], |
| 33 | + }) |
| 34 | +} |
| 35 | +export function returnStatementInsideArgumentExpression(): Configuration[] { |
| 36 | + if (1 == 1) { |
| 37 | + return [1].map<Configuration>((number: number): Configuration => { |
| 38 | + const incremented = number + 1 |
| 39 | + return { |
| 40 | + property: incremented, |
| 41 | + property2: incremented.toString(), |
| 42 | + } |
| 43 | + }) |
| 44 | + } else { |
| 45 | + return [1].map<Configuration>(number => { |
| 46 | + const incremented = number + 1 |
| 47 | + return { |
| 48 | + property: incremented, |
| 49 | + property2: incremented.toString(), |
| 50 | + } |
| 51 | + }) |
| 52 | + } |
| 53 | +} |
| 54 | + |
| 55 | +export function createGenericClass(): GenericClass<Configuration> { |
| 56 | + return new GenericClass<Configuration>([{ property: 1, property2: '2' }]) |
| 57 | +} |
| 58 | + |
| 59 | +export function handleGenericClass() { |
| 60 | + return createGenericClass().map(({ property, property2 }) => ({ |
| 61 | + property: property + 1, |
| 62 | + property2: property2 + '1', |
| 63 | + })) |
| 64 | +} |
| 65 | + |
| 66 | +export function handleShorthand() { |
| 67 | + const property = '42' |
| 68 | + const interfaceMethod = (): string => 'inferred' |
| 69 | + consumesInterface({ |
| 70 | + interfaceMethod, |
| 71 | + property, |
| 72 | + }) |
| 73 | +} |
0 commit comments