ongteckwu / typeid-ts

TypeID UUIDv7 implementation in Typescript (Lib and CLI)
Apache License 2.0
38 stars 5 forks source link

Unable to build project using this package in TypeScript strict mode #10

Open half0wl opened 11 months ago

half0wl commented 11 months ago
  1. Have strict=true in tsconfig
  2. Build project
  3. Receive error:

    ./node_modules/typeid-ts/src/lib/basics.ts:6:5
    Type error: Variable 'uuidv7' implicitly has type 'any' in some locations where its type cannot be determined.
    
      4 | import { encode } from '../base32.js'
      5 |
    > 6 | let uuidv7
        |     ^
      7 | (async () => {
      8 |   const mod = await import('uuidv7')
      9 |   uuidv7 = mod.uuidv7
    error Command failed with exit code 1.

On v0.3.1, seems related to #7

ongteckwu commented 11 months ago

ok new build. Try again. Tq

benjick commented 11 months ago

I'm getting something similar on 0.3.1 when building my nextjs project, when I have strict=true:

./node_modules/typeid-ts/src/base32.ts:17:5
Type error: Type 'number | undefined' is not assignable to type 'number'.
  Type 'undefined' is not assignable to type 'number'.

  15 |
  16 |     // 10 byte timestamp
> 17 |     buffer[0] = alphabet[(src[0] & 224) >> 5]
     |     ^
  18 |     buffer[1] = alphabet[src[0] & 31]
  19 |     buffer[2] = alphabet[(src[1] & 248) >> 3]
  20 |     buffer[3] = alphabet[((src[1] & 7) << 2) | ((src[2] & 192) >> 6)]
error: script "build" exited with code 1 (SIGHUP)
ongteckwu commented 11 months ago

ok fixed try again ben

benjick commented 11 months ago

Hey @ongteckwu, thanks for the quick reply. Sadly I still get an error on 0.3.7. I'm using NextJS btw

./node_modules/typeid-ts/src/base32.ts:31:5
Type error: Type 'number | undefined' is not assignable to type 'number'.
  Type 'undefined' is not assignable to type 'number'.

  29 |
  30 |     // 10 byte timestamp
> 31 |     buffer[0] = alphabet[(src[0] & 224) >> 5]
     |     ^
  32 |     buffer[1] = alphabet[src[0] & 31]
  33 |     buffer[2] = alphabet[(src[1] & 248) >> 3]
  34 |     buffer[3] = alphabet[((src[1] & 7) << 2) | ((src[2] & 192) >> 6)]
error: script "build" exited with code 1 (SIGHUP)
ongteckwu commented 11 months ago

ok pushed a new one, hope this works. If not will really need you to raise a PR instead.

benjick commented 11 months ago

It worked! 🙏 thank you @ongteckwu!

nadilas commented 11 months ago

@benjick Is 0.3.8 the version that should be working?