Closed klanchman closed 3 years ago
The library isn't set up to be imported as a module yet, unless it happens to work by accident. However, I get the same error with an index.js and checkJs=true
in my tscconfig.json. The only idea I currently have is to remove the type information, any other suggestions?
Also, I apologize for not having tested this; I assumed it would "just work". :(
I was able to hand-edit the .ts files to get them to all work patch incoming.
@klanchman can you do me a favor, to ensure I got this correct, please?
npm i https://github.com/hildjj/node-cbor.git
then try poking around in typescript land. I'll do a release as soon as I have confirmation from you that this works, then deal with my tooling issues later.
Haha you beat me to it! 😄
I hadn't used TypeScript's JSDoc declaration stuff before, so this was new to me. Hand-editing was what I was starting to do too.
I did at least find that some of the errors appear to be a TypeScript problem: https://github.com/microsoft/TypeScript/issues/41800 - looks like v4.2 will have that fix. Even with that fix, it left behind the majority of the errors though. Seemed like basically the last export {...}
in cbor.d.ts was the main issue, which was what I was starting to tweak by hand.
It looks like the update is mostly working: it resolved the compile issues, but decodeFirst
is missing 😅 (I glanced over the old export statement and it looks like it's just decodeFirst
that's gone)
Great catch on decodeFirst. I used the copy/paste anti-pattern to create that bug. If you update it should be fixed.
Grabbed the latest update and it looks good to me now 👍
Thank you for the blazing fast response time on this!
6.0.1 published. cbor-cli to follow as soon as i fix whatever i broke there.
I was trying to upgrade from cbor v5 to v6, but ran into compiler errors from
types/lib/cbor.d.ts
on my TypeScript project.A quick reproduction looks like this:
npm init
a projectindex.ts
and addimport * as cbor from 'cbor'
to itnpx tsc index.ts
I'd expect this to compile, but instead TypeScript outputs the following errors (collapsed due to size):
TypeScript output
``` ➤ npx tsc index.ts node_modules/cbor/types/lib/cbor.d.ts:16:10 - error TS2304: Cannot find name 'comment'. 16 export { comment, decodeAll, decodeFirst, decodeAllSync, decodeFirstSync, diagnose, encode, encodeCanonical, encodeOne, encodeAsync, decodeFirstSync as decode }; ~~~~~~~ node_modules/cbor/types/lib/cbor.d.ts:16:10 - error TS2552: Cannot find name 'comment'. Did you mean 'Commented'? 16 export { comment, decodeAll, decodeFirst, decodeAllSync, decodeFirstSync, diagnose, encode, encodeCanonical, encodeOne, encodeAsync, decodeFirstSync as decode }; ~~~~~~~ node_modules/cbor/types/lib/cbor.d.ts:16:19 - error TS2304: Cannot find name 'decodeAll'. 16 export { comment, decodeAll, decodeFirst, decodeAllSync, decodeFirstSync, diagnose, encode, encodeCanonical, encodeOne, encodeAsync, decodeFirstSync as decode }; ~~~~~~~~~ node_modules/cbor/types/lib/cbor.d.ts:16:30 - error TS2304: Cannot find name 'decodeFirst'. 16 export { comment, decodeAll, decodeFirst, decodeAllSync, decodeFirstSync, diagnose, encode, encodeCanonical, encodeOne, encodeAsync, decodeFirstSync as decode }; ~~~~~~~~~~~ node_modules/cbor/types/lib/cbor.d.ts:16:43 - error TS2304: Cannot find name 'decodeAllSync'. 16 export { comment, decodeAll, decodeFirst, decodeAllSync, decodeFirstSync, diagnose, encode, encodeCanonical, encodeOne, encodeAsync, decodeFirstSync as decode }; ~~~~~~~~~~~~~ node_modules/cbor/types/lib/cbor.d.ts:16:58 - error TS2304: Cannot find name 'decodeFirstSync'. 16 export { comment, decodeAll, decodeFirst, decodeAllSync, decodeFirstSync, diagnose, encode, encodeCanonical, encodeOne, encodeAsync, decodeFirstSync as decode }; ~~~~~~~~~~~~~~~ node_modules/cbor/types/lib/cbor.d.ts:16:75 - error TS2304: Cannot find name 'diagnose'. 16 export { comment, decodeAll, decodeFirst, decodeAllSync, decodeFirstSync, diagnose, encode, encodeCanonical, encodeOne, encodeAsync, decodeFirstSync as decode }; ~~~~~~~~ node_modules/cbor/types/lib/cbor.d.ts:16:85 - error TS2304: Cannot find name 'encode'. 16 export { comment, decodeAll, decodeFirst, decodeAllSync, decodeFirstSync, diagnose, encode, encodeCanonical, encodeOne, encodeAsync, decodeFirstSync as decode }; ~~~~~~ node_modules/cbor/types/lib/cbor.d.ts:16:93 - error TS2304: Cannot find name 'encodeCanonical'. 16 export { comment, decodeAll, decodeFirst, decodeAllSync, decodeFirstSync, diagnose, encode, encodeCanonical, encodeOne, encodeAsync, decodeFirstSync as decode }; ~~~~~~~~~~~~~~~ node_modules/cbor/types/lib/cbor.d.ts:16:110 - error TS2304: Cannot find name 'encodeOne'. 16 export { comment, decodeAll, decodeFirst, decodeAllSync, decodeFirstSync, diagnose, encode, encodeCanonical, encodeOne, encodeAsync, decodeFirstSync as decode }; ~~~~~~~~~ node_modules/cbor/types/lib/cbor.d.ts:16:121 - error TS2304: Cannot find name 'encodeAsync'. 16 export { comment, decodeAll, decodeFirst, decodeAllSync, decodeFirstSync, diagnose, encode, encodeCanonical, encodeOne, encodeAsync, decodeFirstSync as decode }; ~~~~~~~~~~~ node_modules/cbor/types/lib/cbor.d.ts:16:134 - error TS2304: Cannot find name 'decodeFirstSync'. 16 export { comment, decodeAll, decodeFirst, decodeAllSync, decodeFirstSync, diagnose, encode, encodeCanonical, encodeOne, encodeAsync, decodeFirstSync as decode }; ~~~~~~~~~~~~~~~ node_modules/cbor/types/lib/commented.d.ts:99:25 - error TS2306: File 'I can use the
skipLibCheck
option to avoid the errors, butcbor
itself still wouldn't have type information when I went to use it in my code.