Conversation
|
Wow thanks!!! Is it impossible to infer output types though? |
| @@ -0,0 +1,23 @@ | |||
| import { expectType, expectAssignable, expectError } from "tsd" | |||
There was a problem hiding this comment.
Oh my god, I missed this library completely... I'm losing my edge
| "test:watch": "ava --watch", | ||
| "test": "npm run lint && ava", | ||
| "prepublish": "npm run build && npm test" | ||
| "test:types": "tsd", |
There was a problem hiding this comment.
How could we call both ava and tsd with the yarn test and yarn test:watch scripts?
There was a problem hiding this comment.
Not sure if I get what you mean. Are you wondering how to call both ava and tsd in watch mode at the same time with one call? However, a "watch" option seems to be missing in tsd
|
I'm afraid so. I think that circular reference is unavoidable. I've tried to infer Output type from With these types, the output is inferred when getters use only const transform = traph({
fullName: i => `${i.first} ${i.last}`,
initials: i => `${i.first[0].toUpperCase()}.${i.last[0].toUpperCase()}.`,
})
const output = transform({ first: 'Richard', last: 'Feynman' })
|
This adds type definitions to
traphfunction.It is possible to have type checking for the object passed to
traphfunction by passing two types: the expected input object type and the expected output object type.In each callback
itype isInandotype isOut.Also, the argument passed to
traphmust have all and only the keys ofOut, where every key must have proper return type:This PR adds
tsdtest too.