Maybe one day you'll get over it 😜
Maybe one day you'll get over it 😜
```ts
const badExample1: MyObjFn<{ type: number }> = obj => undefined;
const badExample2: MyObjFn<{ type: Record<string, any> }> = obj => undefined;
```
```ts
const badExample1: MyObjFn<{ type: number }> = obj => undefined;
const badExample2: MyObjFn<{ type: Record<string, any> }> = obj => undefined;
```
```ts
const goodExample1: MyObjFn<{ type: 'any literal value' }> = obj => undefined;
const someObj = { type: 'known type' }
type KnownTypeObj = typeof someObj;
const goodExample2: MyObjFn<KnownTypeObj> = obj => undefined;
```
```ts
const goodExample1: MyObjFn<{ type: 'any literal value' }> = obj => undefined;
const someObj = { type: 'known type' }
type KnownTypeObj = typeof someObj;
const goodExample2: MyObjFn<KnownTypeObj> = obj => undefined;
```
Take this example
```ts
type MyObject = { type: string }
type MyObjFn <T extends MyObject> = (obj: T) => void;
```
You are saying, T must be an object with the property `type` who's value must be a `string`
Take this example
```ts
type MyObject = { type: string }
type MyObjFn <T extends MyObject> = (obj: T) => void;
```
You are saying, T must be an object with the property `type` who's value must be a `string`
Sorry bud.
Firstly, that's a rest operator. Secondly, yes, the error is in the function arguments, but it's not a syntax error, it's a type error.
Sorry bud.
Firstly, that's a rest operator. Secondly, yes, the error is in the function arguments, but it's not a syntax error, it's a type error.
An excited learner goes deeper, in my experience 🤷
An excited learner goes deeper, in my experience 🤷