Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected errors with NPM run build #62

Closed
Vickysomtee opened this issue May 13, 2024 · 8 comments
Closed

Unexpected errors with NPM run build #62

Vickysomtee opened this issue May 13, 2024 · 8 comments

Comments

@Vickysomtee
Copy link

Hiya.

We have been using this package on our nestjs application for while and everything has been working fine.

Lately we started getting these two errors in our docker npm run build process. We have upgraded to the latest version 5.2.0 and switched between node versions but the error still persists.

> npx @nestjs/cli build

src/core/utils/string-util.ts:110:35 - error TS2554: Expected 0 arguments, but got 1.

110     const uid = new ShortUniqueId({ length: 10 });
                                      ~~~~~~~~~~~~~~
src/core/utils/string-util.ts:111:16 - error TS2339: Property 'rnd' does not exist on type 'ShortUniqueId'.

111     return uid.rnd();
                   ~~~

Found 2 error(s).

@jeanlescure
Copy link
Collaborator

Hi there @Vickysomtee , thanks for the report. This was probably introduced by the fix for #61 😮‍💨

These are edge-cases where typings are not being representative of the actual code behavior.

I'll try and reproduce this error but would greatly appreciate if you could share a code example.

@jeanlescure
Copy link
Collaborator

Been making modifications to the tsconfig in order to force the error to happen on the import specs, using tsc, to no avail.

Maybe this has to do with a specific version of Typescript used in the NestJS project, or a tsconfig enforced by NestJS.

No way to know without an example we can use to reproduce the error.

@Nabil-249
Copy link

Nabil-249 commented May 30, 2024

Hello, I have been also experiencing this issue with package (v5.2.0), here's the configuration to reproduce the issue:

tsconfig.json

{
    "compilerOptions": {
        "module": "NodeNext",
        "moduleResolution": "NodeNext",
        "target": "ES2022",
        "sourceMap": false,
        "outDir": "dist",
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "strict": true,
        "skipLibCheck": true,
        "noImplicitAny": true,
        "noUnusedLocals": true,
        "noUnusedParameters": true,
        "noUncheckedIndexedAccess": true,
    },
    "include": ["src/**/*"]
  }

sample_code.ts

import ShortUniqueId from 'short-unique-id';

//Property 'randomUUID' does not exist on type 'ShortUniqueId'.ts (2339)
const { randomUUID } = new ShortUniqueId();

@jeanlescure
Copy link
Collaborator

I'm still being unable to reproduce this with the example you've shared @Nabil-249

Could you share your package.json dependencies? I'm still wondering if it's a Typescript version issue.

@jeanlescure
Copy link
Collaborator

I've just reverted to Typescript v4.9.5 and was able to reproduce the behavior.

I'm evaluating whether this should be prioritized given that the last v4 version of Typescript was released in January 2023 and there's been 20+ releases of v5 since then.

Would definitely be easier if Microsoft was less vague about Release and Support (i.e. EOL) schedules:

microsoft/TypeScript#49088

@jeanlescure
Copy link
Collaborator

I'll be following on fastify's footsteps here:

To everyone coming here, typescript v4 is not supported by microsoft anymore, so please update your typescript to 5.0+

Source: fastify/fastify#4873 (comment)

Closing this issue. If you see the same error with the latest version of Typescript feel free to open a new issue and include a reproduction repo 👍🏼

@ugglr
Copy link

ugglr commented Jun 6, 2024

If someone else faces this currently, I solved the same error by:

  1. upgrading typescript to newest
  2. setting target in tsconfig to es2022

@bacharuddinadieb
Copy link

If someone else faces this currently, I solved the same error by:

  1. upgrading typescript to newest
  2. setting target in tsconfig to es2022

Yes, in my case i upgraded my typescript from 4.9.5 to the latest version (5.4.5) fixes the issue, thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants