Skip to content

Commit

Permalink
fix(common): typecheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelfimov committed Jan 22, 2025
1 parent 6dd5922 commit 5caac16
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ body:
validations:
required: true

projects: ['atls/11']
projects: ['atls/11']
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ body:
validations:
required: true

projects: ['atls/11']
projects: ['atls/11']
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ body:
validations:
required: true

projects: ['atls/11']
projects: ['atls/11']
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { PromiseClient } from '@connectrpc/connect'

Check failure on line 1 in packages/nestjs-connectrpc-errors/integration/test/connectrpc-errors.test.ts

View workflow job for this annotation

GitHub Actions / Test:Unit

test failed

test failed
Raw output
test failed
import type { INestMicroservice } from '@nestjs/common'

import { ConnectError } from '@connectrpc/connect'
import { ValidationError } from '@atls/protobuf-rpc'
import { ConnectError } from '@connectrpc/connect'
import { Test } from '@nestjs/testing'
import { createPromiseClient } from '@connectrpc/connect'
import { createGrpcTransport } from '@connectrpc/connect-node'
Expand Down Expand Up @@ -64,6 +64,7 @@ describe('grpc error', () => {
expect(
// @ts-expect-error
error.details.map((detail: { value: Uint8Array }) =>

Check failure on line 66 in packages/nestjs-connectrpc-errors/integration/test/connectrpc-errors.test.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/ban-ts-comment): Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.
Raw output
  63 |       if (error instanceof ConnectError) {
  64 |         expect(
> 65 |           // @ts-expect-error
     |           ^
  66 |           error.details.map((detail: { value: Uint8Array }) =>
  67 |             // @ts-expect-error
  68 |             ValidationError.fromBinary(detail.value))
// @ts-expect-error
ValidationError.fromBinary(detail.value))

Check failure on line 68 in packages/nestjs-connectrpc-errors/integration/test/connectrpc-errors.test.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/ban-ts-comment): Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.
Raw output
  65 |           // @ts-expect-error
  66 |           error.details.map((detail: { value: Uint8Array }) =>
> 67 |             // @ts-expect-error
     |             ^
  68 |             ValidationError.fromBinary(detail.value))
  69 |         ).toEqual(
  70 |           expect.arrayContaining([
).toEqual(

Check failure on line 69 in packages/nestjs-connectrpc-errors/integration/test/connectrpc-errors.test.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/no-unsafe-return): Unsafe return of a value of type error.

Unsafe return of a value of type error.
Raw output
  66 |           error.details.map((detail: { value: Uint8Array }) =>
  67 |             // @ts-expect-error
> 68 |             ValidationError.fromBinary(detail.value))
     |             ^
  69 |         ).toEqual(
  70 |           expect.arrayContaining([
  71 |             expect.objectContaining({

Check failure on line 69 in packages/nestjs-connectrpc-errors/integration/test/connectrpc-errors.test.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/no-unsafe-call): Unsafe call of a(n) `error` type typed value.

Unsafe call of a(n) `error` type typed value.
Raw output
  66 |           error.details.map((detail: { value: Uint8Array }) =>
  67 |             // @ts-expect-error
> 68 |             ValidationError.fromBinary(detail.value))
     |             ^
  69 |         ).toEqual(
  70 |           expect.arrayContaining([
  71 |             expect.objectContaining({
expect.arrayContaining([
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import type { DomainError } from '@atls/core-errors'

import { LogicalError } from '@atls/protobuf-rpc'
import { Code } from '@connectrpc/connect'
import { ConnectError } from '@connectrpc/connect'
import { LogicalError } from '@atls/protobuf-rpc'
import { RpcException } from '@nestjs/microservices'

export const domainExceptionFactory = (error: DomainError): RpcException => {
// @ts-expect-error types
const logicalError = new LogicalError({

Check failure on line 10 in packages/nestjs-connectrpc-errors/src/exception-factories/domain.expection-factory.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/ban-ts-comment): Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.
Raw output
   7 |
   8 | export const domainExceptionFactory = (error: DomainError): RpcException => {
>  9 |   // @ts-expect-error types
     |   ^
  10 |   const logicalError = new LogicalError({
  11 |     // @ts-expect-error types
  12 |     id: error.id,
// @ts-expect-error types

Check failure on line 11 in packages/nestjs-connectrpc-errors/src/exception-factories/domain.expection-factory.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/no-unsafe-call): Unsafe construction of a(n) `error` type typed value.

Unsafe construction of a(n) `error` type typed value.
Raw output
   8 | export const domainExceptionFactory = (error: DomainError): RpcException => {
   9 |   // @ts-expect-error types
> 10 |   const logicalError = new LogicalError({
     |                        ^
  11 |     // @ts-expect-error types
  12 |     id: error.id,
  13 |     message: error.message,
id: error.id,

Check failure on line 12 in packages/nestjs-connectrpc-errors/src/exception-factories/domain.expection-factory.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/ban-ts-comment): Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.
Raw output
   9 |   // @ts-expect-error types
  10 |   const logicalError = new LogicalError({
> 11 |     // @ts-expect-error types
     |     ^
  12 |     id: error.id,
  13 |     message: error.message,
  14 |   })
message: error.message,
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import type { GuardErrors } from '@atls/guard-clause'

import { Code } from '@connectrpc/connect'
import { ConnectError } from '@connectrpc/connect'
import { ValidationError } from '@atls/protobuf-rpc'
import { ValidationErrorMessage } from '@atls/protobuf-rpc'
import { Code } from '@connectrpc/connect'
import { ConnectError } from '@connectrpc/connect'
import { RpcException } from '@nestjs/microservices'

export const guardExceptionFactory = (errors: GuardErrors): RpcException => {
const validationErrors: Array<ValidationError> = errors.errors.map(
(error) =>
// @ts-expect-error types
new ValidationError({

Check failure on line 13 in packages/nestjs-connectrpc-errors/src/exception-factories/guard.exception-factory.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/ban-ts-comment): Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.
Raw output
  10 |   const validationErrors: Array<ValidationError> = errors.errors.map(
  11 |     (error) =>
> 12 |       // @ts-expect-error types
     |       ^
  13 |       new ValidationError({
  14 |         id: error.code,
  15 |         property: error.parameter,
id: error.code,

Check failure on line 14 in packages/nestjs-connectrpc-errors/src/exception-factories/guard.exception-factory.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/no-unsafe-call): Unsafe construction of a(n) `error` type typed value.

Unsafe construction of a(n) `error` type typed value.
Raw output
  11 |     (error) =>
  12 |       // @ts-expect-error types
> 13 |       new ValidationError({
     |       ^
  14 |         id: error.code,
  15 |         property: error.parameter,
  16 |         messages: [

Check failure on line 14 in packages/nestjs-connectrpc-errors/src/exception-factories/guard.exception-factory.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/no-unsafe-return): Unsafe return of a value of type error.

Unsafe return of a value of type error.
Raw output
  11 |     (error) =>
  12 |       // @ts-expect-error types
> 13 |       new ValidationError({
     |       ^
  14 |         id: error.code,
  15 |         property: error.parameter,
  16 |         messages: [
property: error.parameter,
messages: [
// @ts-expect-error types
new ValidationErrorMessage({

Check failure on line 18 in packages/nestjs-connectrpc-errors/src/exception-factories/guard.exception-factory.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/ban-ts-comment): Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.
Raw output
  15 |         property: error.parameter,
  16 |         messages: [
> 17 |           // @ts-expect-error types
     |           ^
  18 |           new ValidationErrorMessage({
  19 |             id: error.code,
  20 |             constraint: error.message,
id: error.code,

Check failure on line 19 in packages/nestjs-connectrpc-errors/src/exception-factories/guard.exception-factory.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/no-unsafe-call): Unsafe construction of a(n) `error` type typed value.

Unsafe construction of a(n) `error` type typed value.
Raw output
  16 |         messages: [
  17 |           // @ts-expect-error types
> 18 |           new ValidationErrorMessage({
     |           ^
  19 |             id: error.code,
  20 |             constraint: error.message,
  21 |           }),
constraint: error.message,
Expand All @@ -22,6 +24,7 @@ export const guardExceptionFactory = (errors: GuardErrors): RpcException => {
)

return new RpcException(
// @ts-expect-error types
new ConnectError('Request validation failed', Code.InvalidArgument, undefined, validationErrors)

Check failure on line 28 in packages/nestjs-connectrpc-errors/src/exception-factories/guard.exception-factory.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/ban-ts-comment): Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.
Raw output
  25 |
  26 |   return new RpcException(
> 27 |     // @ts-expect-error types
     |     ^
  28 |     new ConnectError('Request validation failed', Code.InvalidArgument, undefined, validationErrors)
  29 |   )
  30 | }
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import type { ValidationError as ValError } from '@nestjs/common'

import { Code } from '@connectrpc/connect'
import { ConnectError } from '@connectrpc/connect'
import { ValidationError } from '@atls/protobuf-rpc'
import { ValidationErrorMessage } from '@atls/protobuf-rpc'
import { Code } from '@connectrpc/connect'
import { ConnectError } from '@connectrpc/connect'
import { RpcException } from '@nestjs/microservices'

const traverseErrors = (
Expand All @@ -29,6 +29,7 @@ export const validationExceptionFactory = (errors: Array<ValError>): RpcExceptio

traverseErrors(errors, (error, id, property) => {
const messages = Object.keys(error.constraints || {}).map((constraintId) => {
// @ts-expect-error types
const validationErrorMessage = new ValidationErrorMessage({

Check failure on line 33 in packages/nestjs-connectrpc-errors/src/exception-factories/validation.exception-factory.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/ban-ts-comment): Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.
Raw output
  30 |   traverseErrors(errors, (error, id, property) => {
  31 |     const messages = Object.keys(error.constraints || {}).map((constraintId) => {
> 32 |       // @ts-expect-error types
     |       ^
  33 |       const validationErrorMessage = new ValidationErrorMessage({
  34 |         id: constraintId,
  35 |         constraint: error.constraints![constraintId],
id: constraintId,

Check failure on line 34 in packages/nestjs-connectrpc-errors/src/exception-factories/validation.exception-factory.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/no-unsafe-call): Unsafe construction of a(n) `error` type typed value.

Unsafe construction of a(n) `error` type typed value.
Raw output
  31 |     const messages = Object.keys(error.constraints || {}).map((constraintId) => {
  32 |       // @ts-expect-error types
> 33 |       const validationErrorMessage = new ValidationErrorMessage({
     |                                      ^
  34 |         id: constraintId,
  35 |         constraint: error.constraints![constraintId],
  36 |       })
constraint: error.constraints![constraintId],
Expand All @@ -38,6 +39,7 @@ export const validationExceptionFactory = (errors: Array<ValError>): RpcExceptio
})

Check failure on line 39 in packages/nestjs-connectrpc-errors/src/exception-factories/validation.exception-factory.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/no-unsafe-return): Unsafe return of a value of type error.

Unsafe return of a value of type error.
Raw output
  36 |       })
  37 |
> 38 |       return validationErrorMessage
     |       ^
  39 |     })
  40 |
  41 |     validationErrors.push(

validationErrors.push(
// @ts-expect-error types
new ValidationError({

Check failure on line 43 in packages/nestjs-connectrpc-errors/src/exception-factories/validation.exception-factory.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/ban-ts-comment): Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.
Raw output
  40 |
  41 |     validationErrors.push(
> 42 |       // @ts-expect-error types
     |       ^
  43 |       new ValidationError({
  44 |         id,
  45 |         property,
id,

Check failure on line 44 in packages/nestjs-connectrpc-errors/src/exception-factories/validation.exception-factory.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/no-unsafe-argument): Unsafe argument of type error typed assigned to a parameter of type `ValidationError`.

Unsafe argument of type error typed assigned to a parameter of type `ValidationError`.
Raw output
  41 |     validationErrors.push(
  42 |       // @ts-expect-error types
> 43 |       new ValidationError({
     |       ^
  44 |         id,
  45 |         property,
  46 |         messages,

Check failure on line 44 in packages/nestjs-connectrpc-errors/src/exception-factories/validation.exception-factory.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/no-unsafe-call): Unsafe construction of a(n) `error` type typed value.

Unsafe construction of a(n) `error` type typed value.
Raw output
  41 |     validationErrors.push(
  42 |       // @ts-expect-error types
> 43 |       new ValidationError({
     |       ^
  44 |         id,
  45 |         property,
  46 |         messages,
property,
Expand All @@ -47,6 +49,7 @@ export const validationExceptionFactory = (errors: Array<ValError>): RpcExceptio
})

return new RpcException(
// @ts-expect-error types
new ConnectError('Request validation failed', Code.InvalidArgument, undefined, validationErrors)

Check failure on line 53 in packages/nestjs-connectrpc-errors/src/exception-factories/validation.exception-factory.ts

View workflow job for this annotation

GitHub Actions / Lint

(@typescript-eslint/ban-ts-comment): Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.

Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 10 characters or longer.
Raw output
  50 |
  51 |   return new RpcException(
> 52 |     // @ts-expect-error types
     |     ^
  53 |     new ConnectError('Request validation failed', Code.InvalidArgument, undefined, validationErrors)
  54 |   )
  55 | }
)
}
20 changes: 6 additions & 14 deletions packages/nestjs-connectrpc/src/connectrpc.interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type * as http from 'http'
import type * as http2 from 'http2'
import type * as https from 'https'
import type * as http from 'http'
import type * as http2 from 'http2'
import type * as https from 'https'
import type { ConnectRouterOptions } from '@connectrpc/connect'
import type { Observable } from 'rxjs'
import type { Observable } from 'rxjs'

export interface ConnectRpcPattern {
service: string
Expand Down Expand Up @@ -48,17 +48,9 @@ export interface Http2InsecureOptions extends BaseServerOptions {
serverOptions?: http2.ServerOptions
}

export type ServerTypeOptions =
| Http2InsecureOptions
| Http2Options
| HttpOptions
| HttpsOptions
export type ServerTypeOptions = Http2InsecureOptions | Http2Options | HttpOptions | HttpsOptions

export type ServerInstance =
| http.Server
| http2.Http2Server
| https.Server
| null
export type ServerInstance = http.Server | http2.Http2Server | https.Server | null

export interface ConstructorWithPrototype {
prototype: Record<string, PropertyDescriptor>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class ExternalRendererModule {
provide: EXTERNAL_RENDERER_MODULE_OPTIONS,
useFactory: async (optionsFactory: ExternalRendererOptionsFactory) =>
optionsFactory.createExternalRendererOptions(),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
inject: [options.useExisting! || options.useClass!],
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/nestjs-gateway/src/mesh/graphql.mesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export class GraphQLMesh {
this.mesh = await getMesh(await this.config.create())
}


return this.mesh
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

import type { INestMicroservice } from '@nestjs/common'

import { readFileSync } from 'node:fs'
import { join } from 'node:path'

import { Metadata } from '@grpc/grpc-js'
import { ClientsModule } from '@nestjs/microservices'
import { Transport } from '@nestjs/microservices'
Expand All @@ -14,9 +17,7 @@ import { beforeAll } from '@jest/globals'
import { it } from '@jest/globals'
import { expect } from '@jest/globals'
import { afterAll } from '@jest/globals'
import { readFileSync } from 'node:fs'
import { sign } from 'jsonwebtoken'
import { join } from 'node:path'
import getPort from 'get-port'

import { GrpcIdentityIntegrationModule } from './src/index.js'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export class KetoWriteClientService {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
delta.setAction(action).setRelationTuple(tuple)


return delta
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ export class RelationTupleConverter {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
subjectSet.setRelation(relation)


return subjectSet
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { S3ClientConfig } from '@aws-sdk/client-s3'


import type { S3ClientModuleOptions } from './s3-client.module.interfaces.js'

import { Inject } from '@nestjs/common'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { SignUrlOptions } from '../storage/index.js'
import type { SignedUrl } from '../storage/index.js'

import type { AbstractStorage } from '../storage/index.js'

import { Inject } from '@nestjs/common'
Expand Down

0 comments on commit 5caac16

Please sign in to comment.