Skip to content

No matching model found for referenced type ... 77 more .... #749

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

Closed
2 of 4 tasks
fantapop opened this issue Jul 8, 2020 · 8 comments · Fixed by #788
Closed
2 of 4 tasks

No matching model found for referenced type ... 77 more .... #749

fantapop opened this issue Jul 8, 2020 · 8 comments · Fixed by #788
Labels

Comments

@fantapop
Copy link
Contributor

fantapop commented Jul 8, 2020

I'm running into a weird one. I'm unable to build. The error is:

Error: Could not determine the keys on JobTemplateAttributes
At: ../shared/src/ipp.ts:4856:4856.
This was caused by 'keyof JobTemplateAttributes
    | 'document-copies'
    | 'document-numbers'
    | 'pages''
    at new GenerateMetadataError (/Users/chris/Development/fantapop-tsoa/src/metadataGeneration/exceptions.ts:6:5)
    at TypeResolver.resolve (/Users/chris/Development/fantapop-tsoa/src/metadataGeneration/typeResolver.ts:245:15)
    at /Users/chris/Development/fantapop-tsoa/src/metadataGeneration/typeResolver.ts:62:84
    at Array.map (<anonymous>)
    at TypeResolver.resolve (/Users/chris/Development/fantapop-tsoa/src/metadataGeneration/typeResolver.ts:61:41)
    at TypeResolver.getTypeAliasReference (/Users/chris/Development/fantapop-tsoa/src/metadataGeneration/typeResolver.ts:504:120)
    at TypeResolver.getReferenceType (/Users/chris/Development/fantapop-tsoa/src/metadataGeneration/typeResolver.ts:474:30)
    at TypeResolver.resolve (/Users/chris/Development/fantapop-tsoa/src/metadataGeneration/typeResolver.ts:307:32)
    at TypeResolver.resolve (/Users/chris/Development/fantapop-tsoa/src/metadataGeneration/typeResolver.ts:55:133)
    at TypeResolver.propertyFromSignature (/Users/chris/Development/fantapop-tsoa/src/metadataGeneration/typeResolver.ts:827:113)

I've got a local copy of tsoa running so I was trying to debug a bit. That area of the code was catching an error but not logging it. When I log it out I get:

error was:  Error: No matching model found for referenced type ... 77 more .... If ... 77 more ... comes from a dependency, please create an interface in your own code that has the same structure. Tsoa can not utilize interfaces from external dependencies. Read more
 at https://github.com/lukeautry/tsoa/blob/master/docs/ExternalInterfacesExplanation.MD

My best guess here is that there are too many classes and typescript isn't giving all the info so at some point, it gives back "77 more" expecting to display that in a gui.

Here is some more info:

getModelTypeDeclaration is being called with this type:

 IdentifierObject {
    pos: -1,
    end: -1,
    flags: 8,
    modifierFlagsCache: 0,
    transformFlags: 0,
    parent: undefined,
    kind: 75,
    escapedText: '... 77 more ...',
    originalKeywordKind: undefined,
    autoGenerateFlags: 0,
    autoGenerateId: 0
  }
  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn't already been submit

Possible Solution

I'm not sure what else to try here. I'm open to debugging some more with some instruction.

Context (Environment)

Version of the library: 3.2.1
Version of NodeJS: I'm running tsoa using ts-node

  • Confirm you were using yarn not npm: [x]
@jookshub
Copy link
Contributor

jookshub commented Jul 28, 2020

I've encountered a similar kind of issue and used a console.log('parentNode:', parentNode) in typeResolver.js:

parentNode: NodeObject {
  pos: -1,
  end: -1,
  flags: 8,
  modifierFlagsCache: 0,
  transformFlags: 0,
  parent: undefined,
  kind: 158,
  modifiers: undefined,
  name: IdentifierObject {
    pos: -1,
    end: -1,
    flags: 8,
    modifierFlagsCache: 0,
    transformFlags: 0,
    parent: undefined,
    kind: 75,
    escapedText: '... 4 more ...',
    originalKeywordKind: undefined,
    autoGenerateFlags: 0,
    autoGenerateId: 0
  },
  questionToken: undefined,
  type: undefined,
  initializer: undefined
}
Generate swagger error.
 TypeError: Cannot read property 'kind' of undefined
    at TypeResolver.getPrimitiveType (/Users/jokroj/__Cellular__/bitburger-one-cds/node_modules/tsoa/dist/metadataGeneration/typeResolver.js:349:72)
    at TypeResolver.resolve (/Users/jokroj/__Cellular__/bitburger-one-cds/node_modules/tsoa/dist/metadataGeneration/typeResolver.js:92:34)
    at /Users/jokroj/__Cellular__/bitburger-one-cds/node_modules/tsoa/dist/metadataGeneration/typeResolver.js:147:118
    at Array.reduce (<anonymous>)
    at TypeResolver.resolve (/Users/jokroj/__Cellular__/bitburger-one-cds/node_modules/tsoa/dist/metadataGeneration/typeResolver.js:146:18)
    at /Users/jokroj/__Cellular__/bitburger-one-cds/node_modules/tsoa/dist/metadataGeneration/typeResolver.js:147:118
    at Array.reduce (<anonymous>)
    at TypeResolver.resolve (/Users/jokroj/__Cellular__/bitburger-one-cds/node_modules/tsoa/dist/metadataGeneration/typeResolver.js:146:18)
    at TypeResolver.resolve (/Users/jokroj/__Cellular__/bitburger-one-cds/node_modules/tsoa/dist/metadataGeneration/typeResolver.js:308:118)
    at MethodGenerator.Generate (/Users/jokroj/__Cellular__/bitburger-one-cds/node_modules/tsoa/dist/metadataGeneration/methodGenerator.js:52:76)

If I decrease the size of an object I am returning in one of my functions this error is omitted. And by size I mean that using a different length of a field name e.g. demo instead of longdemo makes the difference if tsoa runs or fails.

I'll try to reduce this down into a neat example, but since this may take a while, I'll leave this comment to support further investigation of this bug.

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the Stale label Aug 28, 2020
@fantapop
Copy link
Contributor Author

not stale. Maybe I will have time to look more into this. I see these in the VS Code type hints as well for large types. I found this: https://stackoverflow.com/questions/53113031/how-to-see-a-fully-expanded-typescript-type-without-n-more-and maybe setting this will help.

@fantapop
Copy link
Contributor Author

Also this: microsoft/TypeScript#26238

@WoH
Copy link
Collaborator

WoH commented Aug 28, 2020

I'd hope there is a way to access the properties without truncation regardless of the project config using the compiler/tc api

@github-actions github-actions bot closed this as completed Sep 3, 2020
@fantapop
Copy link
Contributor Author

fantapop commented Sep 3, 2020

It seems like the action bot decided to not respect commenting in order to remove the stale label

Anyways, I was able to make some progress. I was able to get past this error by doing something similar to what is described here: microsoft/TypeScript#26238 (comment)

In the built typescript files, there were many copies of the mentioned line: ts.defaultMaximumTruncationLength = 160
The one that is used by TSOA seems to be this file: node_modules/typescript/lib/typescript.js. My type was apparently very large. I had to bump up the ts.defaultMaximumTruncationLength to 2000 to finally make my build succeed.

I also found mention of a method to set this value here:
microsoft/TypeScript#29564

by doing like (ts as any).defaultMaximumTruncationLength = 2000;

however, I've been unable to get this to have an affect by setting the value from inside TSOA.

@jookshub
Copy link
Contributor

jookshub commented Sep 9, 2020

Thanks to @fantapop and microsoft/TypeScript#26238 (comment) I was able to solve this with ts.NodeBuilderFlags.NoTruncation

I've created a fork and a patch-branch here:
master...cellular:feature/patch_truncation_issue_781

However, I am lost in providing a test for that. All tests run trough - with and without the patch.

I've tried to edit the ModelService and the TestClassModel, but failed to edit them in a way, that would result in the error this issue is about.

So a patch is available, a test ist missing.

@fantapop
Copy link
Contributor Author

@jookshub Your fix is working for me as well. Thanks for figuring that out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants