kriszyp/cbor-x

TypeScript reporting issues in shipped `index.d.ts` file

jloleysens opened this issue · 4 comments

Hello!

When building a project I am seeing the following compiler issues from TS:

node_modules/cbor-x/index.d.ts:1:58 - error TS2305: Module '"./decode.js"' has no exported member 'clearSource'.

1 export { Decoder, decode, addExtension, FLOAT32_OPTIONS, clearSource, roundFloat32, isNativeAccelerationEnabled } from './decode.js'
                                                           ~~~~~~~~~~~

node_modules/cbor-x/index.d.ts:7:24 - error TS2304: Cannot find name 'Options'.

7  constructor(options?: Options | { highWaterMark: number, emitClose: boolean, allowHalfOpen: boolean })
                         ~~~~~~~

node_modules/cbor-x/index.d.ts:10:24 - error TS2304: Cannot find name 'Options'.

10  constructor(options?: Options | { highWaterMark: number, emitClose: boolean, allowHalfOpen: boolean })
                          ~~~~~~~

Looking at the file, it does look like these issues are accurate since there is no Options and it seems as though decode.d.ts needs to be updated to declare and export the clearSource function.

Publish a fix for this and #36 in v1.3.2. Let me know if you see any issues with it. Thank you for the reports!

Hi @kriszyp , i am getting error in typescript whenever i am using keyMap option in Encoder class as shown in the example. KeyMaps for Senml: https://www.npmjs.com/package/cbor-x
let senmlCbor = new Encoder({ keyMap: senmlKeys }).
Looks like the options in decode constructor doesn't have keyMap option. Ref: https://github.com/kriszyp/cbor-x/blob/master/decode.d.ts#L8.
Kindly let me know if i am missing something here.

@shubhamvrkr published keyMap typing in v1.3.3.

@kriszyp Is there an option/plan to enable validity of the items during cbor decoding.
https://www.ietf.org/archive/id/draft-ietf-cbor-7049bis-16.html#name-validity-of-items