dmonad / lib0

Monorepo of isomorphic utility functions
MIT License
345 stars 63 forks source link

typescript errors as of 0.2.75 #65

Closed NilSet closed 1 year ago

NilSet commented 1 year ago

Describe the bug The jsdoc types added to the is functions in 0.2.75 export typescript definitions which do not typecheck

To Reproduce npm run clean && npm run types && npm run lint yields the following errors

function.d.ts:12:62 - error TS2344: Type 'TYPE' does not satisfy the constraint 'abstract new (...args: any) => any'.

12 export function is<TYPE>(n: any, T: TYPE): n is InstanceType<TYPE>;
                                                                ~~~~

  function.d.ts:12:20
    12 export function is<TYPE>(n: any, T: TYPE): n is InstanceType<TYPE>;
                          ~~~~
    This type parameter might need an `extends abstract new (...args: any) => any` constraint.

function.d.ts:13:74 - error TS2344: Type 'TYPE' does not satisfy the constraint 'abstract new (...args: any) => any'.

13 export function isTemplate<TYPE>(T: TYPE): (n: any) => n is InstanceType<TYPE>;
                                                                            ~~~~

  function.d.ts:13:28
    13 export function isTemplate<TYPE>(T: TYPE): (n: any) => n is InstanceType<TYPE>;
                                  ~~~~
    This type parameter might need an `extends abstract new (...args: any) => any` constraint.

isomorphic.d.ts:1:10 - error TS2303: Circular definition of import alias 'performance'.

1 export { performance, cryptoRandomBuffer } from "isomorphic.js";
           ~~~~~~~~~~~

isomorphic.d.ts:1:23 - error TS2303: Circular definition of import alias 'cryptoRandomBuffer'.

1 export { performance, cryptoRandomBuffer } from "isomorphic.js";
                        ~~~~~~~~~~~~~~~~~~

Expected behavior Lints pass

Environment Information

dmonad commented 1 year ago

Thanks for the PR Noel!

This is quite odd. Normally, I get error messages by just calling npm run lint (it's also part of the publishing script). However, this error only occurs when generating typing definitions and then running lint.. I'm not experiencing linting issues in other packages, however they already use typescript v5.

I merged your PR and published a new release v0.2.76.