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

Fix "Cannot read property 'kind' of undefined" error related to missing NodeBuilderFlags.NoTruncation #781

Closed
2 tasks
jookshub opened this issue Sep 9, 2020 · 1 comment · Fixed by #788
Closed
2 tasks

Comments

@jookshub
Copy link
Contributor

jookshub commented Sep 9, 2020

Sorting

  • I'm submitting a ...

    • [ x] bug report
    • feature request
    • support request
  • I confirm that I

    • [ x] used the search to make sure that a similar issue hasn't already been submit - and solved

Expected Behavior

  @Get('abridgedObject')
  public async abridgedObject() {
    return {
      demo01: '',
      demo02: '',
      demo03: '',
      demo04: '',
      demo05: '',
      demo06: '',
      demo07: '',
      demo08: '',
      demo09: '',
      demo10: '',
      demo11: '',
      demo12: '',
      demo13: '',
      demo14: '',
      demo15: '',
      demo16: '',
      demo17: '',
      d: ''
    }
  }

This should not break tsoa swaggeror tsoa routes.

Current Behavior

See #749 and possibly #681

TSOA is not using ts.NodeBuilderFlags.NoTruncation which leads to issues like those mentioned or like the following:

TypeError: Cannot read property 'kind' of undefined
    at TypeResolver.getPrimitiveType (/Users/jook/tsoa/src/metadataGeneration/typeResolver.ts:336:70)
    at TypeResolver.resolve (/Users/jook/tsoa/src/metadataGeneration/typeResolver.ts:39:32)
    at /Users/jook/tsoa/src/metadataGeneration/typeResolver.ts:104:127
    at Array.reduce (<anonymous>)

Possible Solution

See working patch: master...cellular:feature/patch_truncation_issue_781

I am working on creating/submitting a PR based on it.

Steps to Reproduce

  1. checkout master...cellular:feature/test_truncation_issue_781
  2. run yarn build
  3. run yarn test
  4. see failing test
  5. delete d: '' from the return object of the abridgedObject function
  6. run yarn test
  7. see working test

Context (Environment)

Version of the library: 3.2.1
Version of NodeJS: 12.18.2

  • Confirm you were using yarn not npm: [x]

Detailed Description

Thanks to the intel of @fantapop (#749 (comment)) and microsoft/TypeScript#26238 (comment) I was able to determine the cause of the truncation to be a missing ts.NodeBuilderFlags.NoTruncation flag in some of the TS functions used by tsoa.

With this flag in place, the output of TS won't be truncated.

Breaking change?

This change might lead to a different output of tsoa, however this should not result in regressions and if so, due to errors which were silent otherwise.

@WoH
Copy link
Collaborator

WoH commented Sep 11, 2020

Looking forward to the PR for this. Seems like it should be a very helpful improvement.

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 a pull request may close this issue.

2 participants