nest icon indicating copy to clipboard operation
nest copied to clipboard

Draft: refactor(common): Add type safety to loadPackage

Open TheKhanj opened this issue 1 year ago • 4 comments

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
  • [ ] ~Tests for the changes have been added (for bug fixes / features)~
  • [ ] ~Docs have been added / updated (for bug fixes / features)~

PR Type

What kind of change does this PR introduce?

  • [ ] Bugfix
  • [ ] Feature
  • [ ] Code style update (formatting, local variables)
  • [x] Refactoring (no functional changes, no api changes)
  • [ ] Build related changes
  • [ ] CI related changes
  • [ ] Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • [ ] Yes
  • [x] No

Other information

DESCRIPTION: There are 2 problems in fastify-adapter.ts file on lines 438 and 453. Can anybody else fix that :) I didn't want to simply add as any to it...

TheKhanj avatar Aug 16 '23 10:08 TheKhanj

This will lead to compilation errors for projects with skipLibCheck set to false

kamilmysliwiec avatar Aug 16 '23 10:08 kamilmysliwiec

@kamilmysliwiec Oh, I see. How about adding @ts-ignore:next-line before each import statement?

// @ts-ignore:next-line
import type * as Ws from 'wsss';
// @ts-ignore:next-line
import type * as Mqtt from 'mqtt';
// @ts-ignore:next-line
import type * as Nats from 'nats';
// @ts-ignore:next-line
import type * as GrpcJs from '@grpc/grpc-js';
// other imports...

TheKhanj avatar Aug 16 '23 12:08 TheKhanj

Pull Request Test Coverage Report for Build 20d1cbae-50c8-474b-b0d4-0a9103e7c1c8

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 92.26%

Totals Coverage Status
Change from base Build 3770aab0-7e99-46e0-b1a8-34ce234c1890: 0.0%
Covered Lines: 6687
Relevant Lines: 7248

💛 - Coveralls

coveralls avatar Oct 31 '23 22:10 coveralls

~~I believe it is ready to be merged. About that skipLibCheck issue I added ts-ignore (next-line) and also had to add eslint ignore (next-line) afterwards, for pipelines to be passed, then checked it in another project with skipLibCheck set to false, it was fine....~~

I agree the whole mr is like a hack but apparently generic import type is not going to be implemented in typescript... So your call if it's worth being merged or not :)

Update: Apparently we should add something in build process to add @ts-ignore comments after typescript compiles. https://github.com/flex-development/mlly/commit/81b55caa8533ad174ec009535e5a030be21e6cc1

TheKhanj avatar Oct 31 '23 23:10 TheKhanj