cbor-x icon indicating copy to clipboard operation
cbor-x copied to clipboard

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

Open jloleysens opened this issue 2 years ago • 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.

jloleysens avatar Jul 19 '22 15:07 jloleysens

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!

kriszyp avatar Jul 20 '22 12:07 kriszyp

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 avatar Aug 01 '22 06:08 shubhamvrkr

@shubhamvrkr published keyMap typing in v1.3.3.

kriszyp avatar Aug 01 '22 12:08 kriszyp

@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

shubhamvrkr avatar Aug 02 '22 05:08 shubhamvrkr