Skip to content

import relations as ts types to fix circular imports#66

Open
rhyek wants to merge 1 commit into
kimjbstar:mainfrom
rhyek:import_as_type_to_fix_circular_imports
Open

import relations as ts types to fix circular imports#66
rhyek wants to merge 1 commit into
kimjbstar:mainfrom
rhyek:import_as_type_to_fix_circular_imports

Conversation

@rhyek
Copy link
Copy Markdown

@rhyek rhyek commented Jun 3, 2024

Fixes #60

Proposed Changes

  • Import generated relation types both as classes for use in ApiProperty decorators, but also as TypeScript types for use as the field type definition to avoid circular import errors when building the project.

Example of the result:

import { users, type users as usersAsType } from './users';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class identities {
  @ApiProperty({ type: () => users })
  users: usersAsType;
}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot access 'User' before initialization

1 participant