Skip to content

Commit

Permalink
Prettify README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kaleb0402 committed Nov 25, 2019
1 parent 3ba96cd commit 772c0f3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1411,30 +1411,32 @@ function foo() {
return {
a: 1,
b: 2,
subInstArr: [{
subInstArr: [
{
c: 3,
d: 4
}]
}
}
]
};
}

type InstType = ReturnType<typeof foo>
type SubInstArr = InstType['subInstArr'];
type InstType = ReturnType<typeof foo>;
type SubInstArr = InstType["subInstArr"];
type SubIsntType = SubInstArr[0];

let baz: SubIsntType = {
c: 5,
d: 6 // type checks ok!
}
};

//You could just write a one-liner,
//But please make sure it is forward-readable
//(you can understand it from reading once left-to-right with no jumps)
type SubIsntType2 = ReturnType<typeof foo>['subInstArr'][0];
type SubIsntType2 = ReturnType<typeof foo>["subInstArr"][0];
let baz2: SubIsntType2 = {
c: 5,
d: 6 // type checks ok!
}
};
```
# Troubleshooting Handbook: Images and other non-TS/TSX files
Expand Down

0 comments on commit 772c0f3

Please sign in to comment.