Closed garbados closed 3 years ago
It is EOD for me so I am leaving some links here to help narrow down the types we expose, so that they can be more useful to downstream TypeScript users.
More coming soon!
Ready to go, my dudes 😎
It also might be helpful to include in the details how to test this.
So for testing, it seems we have two options: tsd and Microsoft's dtslint. Both involve writing additional tests. Based on what I've seen, I'd opt for using tsd. I can write these tests tomorrow.
I'm not that familiar with ts projects but I think you need to include a files list of type definitions in your project so the ts compiler can parse them, no?
I can't seem to find documentation indicating this. The file structure in this PR was auto-generated by the TypeScript CLI. I'm sure the details of this will shake out as I instrument testing.
I can't seem to find documentation indicating this.
Nevermind. Found it.
I've updated the type definitions and the package meta files to include type testing in the test suite, though I am still experiencing this error:
$ npx tsd
types/index.test-d.ts:5:0
✖ 5:0 Parameter type typeof winston is not identical to argument type any.
1 error
Being largely unfamiliar with Typescript, I'm kind of fumbling around in the dark. I've exhausted my threads for now so any guidance would be appreciated. I'm going to freshen up my brain and try again.
OK, thanks to help from @michaelgoin I got the type definitions to a point where they compile appropriately. You can test this yourself by npm installing this branch and then running a TS file like this:
import * as logEnricher from '@newrelic/awinston-enricher'
console.log(logEnricher)
It won't fail, which gives us pretty much all the info we need.
tsd gave us enough problems that I have opted to not use it, and I haven't tried its alternative dtslint yet. I'll do that tomorrow. But what we have now seems good enough to use, so what remains is just to instrument testing.
Ready for review!
Appears to be failing to load typescript in the CI. Perhaps it by default is trying to load a global install?
$ npm i -g typescript && npm run types
...
Error: Cannot find module 'typescript'
:/
I can't approve because I'm the original author, but this LGTM. Thanks @michaelgoin !
Proposed Release Notes
Links
Details
This PR adds TypeScript types to the log enricher. As of this writing, these types are all instances of
any
and thus not particularly useful. I'll narrow it down before I submit it for review.