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

TypeError: Cannot read properties of undefined (reading '0') #1059

Open
ChristiaanWillemsen opened this issue Oct 8, 2024 · 2 comments
Open

Comments

@ChristiaanWillemsen
Copy link

Summary

Write a short summary of the bug in here.

  • SDK Version: [email protected], @nestia/core@^3.17.0, @nestia/fetcher@^3.17, typia@^6.11.0
  • Expected behavior: I don't know, never had it working ;)
  • Actual behavior: When running the project, on several files I get this error: TypeError: Cannot read properties of undefined (reading '0')

So, I have an existing Nest project using mono-repo, and I'd like to add nestia to this. So I followed the instructions, and all this seems to work fine. When I try to start one of the mono-repo apps using

nest start --inspect --debug --watch

It gives several error messages, all similar, like this:

ERROR in ./libs/raja/src/raja.serviceInterface.ts Module build failed (from ./node_modules/ts-loader/index.js): TypeError: Cannot read properties of undefined (reading '0') at get_name (/Users/***/***-mono-ts/node_modules/@nestia/core/lib/transformers/MethodTransformer.js:47:67) at /Users/***/***-mono-ts/node_modules/@nestia/core/lib/transformers/MethodTransformer.js:37:22 at /Users/***/***-mono-ts/node_modules/@nestia/core/lib/transformers/MethodTransformer.js:20:70 at /Users/***/***-mono-ts/node_modules/@nestia/core/lib/transformers/NodeTransformer.js:13:67 at /Users/***/***-mono-ts/node_modules/@nestia/core/lib/transformers/FileTransformer.js:22:72 at /Users/***/***-mono-ts/node_modules/@nestia/core/lib/transformers/FileTransformer.js:16:91 at /Users/***/***-mono-ts/node_modules/@nestia/core/lib/transformers/FileTransformer.js:16:185 at visitArrayWorker (/Users/***/***-mono-ts/node_modules/typescript/lib/typescript.js:93751:49) at visitNodes2 (/Users/***/***-mono-ts/node_modules/typescript/lib/typescript.js:93722:19) at visitEachChildOfClassDeclaration (/Users/***/***-mono-ts/node_modules/typescript/lib/typescript.js:94665:7) @ ./libs/raja/src/raja.serviceImpl.ts 4:32-66 @ ./apps/ingest/src/***/***.module.ts 25:27-68 @ ./apps/ingest/src/main.ts 7:25-60

Sadly, It doesn't tell me what line number to check, and I've checked the files and cannot find anything "offensive" in there either. Also don't know how to debug this further.

Code occuring the bug

I don't know...

Before creating some demonstration code, I though I might have missed something very obvious, plus given that I do not know what triggers any of this, it's rather hard to make any demonstration code.

@ChristiaanWillemsen
Copy link
Author

ChristiaanWillemsen commented Oct 9, 2024

Okay, so I can get rid of the error by removing the decorators of the controller functions, like @Get and @Post, or the types variants like @TypedRoute.Post.

Not particularly helpful in solving the issue, but might help narrow down what exactly the issue is?

@ChristiaanWillemsen
Copy link
Author

Upon further investigation it seem as though the code isn't properly patched, or just not ran though the compiler?

I added some debug statement just before it fails:

symbol SymbolObject {
  flags: 34078720,
  escapedName: 'Promise',
  declarations: undefined,
  valueDeclaration: undefined,
  id: 1333,
  mergeId: 0,
  parent: undefined,
  members: undefined,
  exports: undefined,
  exportSymbol: undefined,
  constEnumOnlyModule: undefined,
  isReferenced: undefined,
  lastAssignmentPos: undefined,
  links: SymbolLinks {
    checkFlags: 1048576,
    declaredType: TypeObject {
      flags: 1,
      checker: [Object],
      id: 6,
      intrinsicName: 'unresolved',
      debugIntrinsicName: undefined,
      objectFlags: 52953088
    }
  }
}

It seems like declarations is empty, which it should probably not be.

So I checked the patching, and that seems to be fine:

yarn prepare
yarn run v1.22.19
$ ts-patch install && typia patch
[!] tsc.js is already patched with the latest version. For details, run: ts-patch check
[!] typescript.js is already patched with the latest version. For details, run: ts-patch check
[+] ts-patch installed!
----------------------------------------
 Typia Setup Wizard
----------------------------------------
Since TypeScript v5.3 update, "tsc" no more parses JSDoc comments.

Therefore, "typia" revives the JSDoc parsing feature by patching "tsc".

This is a temporary feature of "typia", and it would be removed when "ts-patch" being updated.
✨  Done in 0.75s.

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

No branches or pull requests

1 participant