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

feat: resolve & convert circular dependent Js plain object to Js class instance #1625

Conversation

Norlandz
Copy link

@Norlandz Norlandz commented Oct 4, 2023

Description

src\CircularDependencyLinkageManager.ts

@|important @|main

the main file for adding functionality
to resolve & convert circular dependent Js plain object to Js class instance
(-- ResolveCircularDependenyWhenPlainToClass)
(only works in simple case)

src\TransformOperationExecutor.ts

@|important

modified to use src\CircularDependencyLinkageManager.ts

test\functional\ResolveCircularDependenyWhenPlainToClass.spec.ts

@|important

test/demo file for src\CircularDependencyLinkageManager.ts

@|WARN::
for ResolveCircularDependenyWhenPlainToClass.spec.ts
You MUST Run this Test file with "emitDecoratorMetadata": false

related: #1622

src\interfaces\class-transformer-options.interface.ts
src\constants\default-options.constant.ts

add the option for src\CircularDependencyLinkageManager.ts

tsconfig.json
tsconfig.spec.json
jest.config.js

@|not_important @|messy @|tweaks

tweak tsconfig.json so that vscode can recognize the test files & debug/run the Jest test file

  • vscode support on multi tsconfig.json is poor

  • Jest & "emitDecoratorMetadata": true & ReferenceError: Cannot access 'Photo' before initialization has a big problem

  • -> I wasted a lot of time on it, it still works poorly

  • @|WARN::
    for ResolveCircularDependenyWhenPlainToClass.spec.ts
    You MUST Run this Test file with "emitDecoratorMetadata": false

package.json
pnpm-lock.yaml

@|not_important

need upgrade jest, otherwise the bomb array test fail dk why

.vscode\launch.json

@|not_important

use tsx to run ts file

Checklist

  • the pull request title describes what this PR does (not a vague title like Update index.md)
  • the pull request targets the default branch of the repository (develop)
  • the code follows the established code style of the repository
    • npm run prettier:check passes
      • (passes, has warn)
    • npm run lint:check passes
      • (just some order problem?)
  • tests are added for the changes I made (if any source code was modified)
    • @|WARN::
      for ResolveCircularDependenyWhenPlainToClass.spec.ts
      You MUST Run this Test file with "emitDecoratorMetadata": false

  • documentation added or updated
    • (has code comments)
  • I have run the project locally and verified that there are no errors

Fixes

fixes #224 (though the OP claimed the issue was fixed, was not for my case.)

Problems facing

Code should run with no problem.
But, Following needs to be fixed.

  • @|WARN::
    for ResolveCircularDependenyWhenPlainToClass.spec.ts
    You MUST Run this Test file with "emitDecoratorMetadata": false

  • tweak tsconfig.json so that vscode can recognize the test files & debug/run the Jest test file

…WhenPlainToClass

> src\CircularDependencyLinkageManager.ts
the main file for adding functionality
to resolve & convert `circular dependent Js plain object` to `Js class instance`
(-- ResolveCircularDependenyWhenPlainToClass)
(only works in simple case)
> src\TransformOperationExecutor.ts
modified to use `src\CircularDependencyLinkageManager.ts`
> test\functional\ResolveCircularDependenyWhenPlainToClass.spec.ts
test/demo file for `src\CircularDependencyLinkageManager.ts`
> src\interfaces\class-transformer-options.interface.ts
> src\constants\default-options.constant.ts
add the option for `src\CircularDependencyLinkageManager.ts`

> tsconfig.json
> tsconfig.spec.json
> jest.config.js
@not_important
tweak tsconfig.json so that vscode can recognize the test file & debug/run the Jest test file
(
  - vscode support on multi tsconfig.json is poor
  - Jest & "emitDecoratorMetadata": true & [ReferenceError: Cannot access 'Photo' before initialization] has a big problem
  -> I wasted a lot of time on it, it still works poorly
  )
> package.json
> pnpm-lock.yaml
@not_important
need upgrade jest, otherwise the bomb array test fail dk why
> .vscode\launch.json
@not_important
use tsx to run ts file
@Norlandz Norlandz changed the title resolve & convert circular dependent Js plain object to Js class instance feat: resolve & convert circular dependent Js plain object to Js class instance Oct 4, 2023
@Norlandz Norlandz closed this Feb 24, 2024
@Norlandz Norlandz deleted the feature-ResolveCircularDependenyWhenPlainToClass branch February 24, 2024 02:20
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

enableCircularCheck issue
1 participant