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 property 'some' of undefined #1329

Closed
gz65555 opened this issue Jun 30, 2020 · 4 comments
Closed

TypeError: Cannot read property 'some' of undefined #1329

gz65555 opened this issue Jun 30, 2020 · 4 comments
Labels
bug Functionality does not match expectation

Comments

@gz65555
Copy link

gz65555 commented Jun 30, 2020

function createReferenceReflection(context, source, target) {
    if (!(context.scope instanceof models_1.ContainerReflection)) {
        throw new Error('Cannot add reference to a non-container');
    }
    if (target.declarations.some(d => context.isOutsideDocumentation(d.getSourceFile().fileName))) {
        return;
...
}

I don't know when will be target.declaration === undefined. I have used typedoc-plugin-lerna-packages plugin. Would someone give me some information ?

Environment

  • Typedoc version: 0.16.11
  • TypeScript version: 3.7.5
  • Node.js version: v13.8.0
  • OS: mac os catalina
@gz65555 gz65555 added the bug Functionality does not match expectation label Jun 30, 2020
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jun 30, 2020

TypeScript's types are wrong about some nullable types. symbol.declarations is one of them. We should be using symbol.getDeclarations() there instead and checking for null. I think it is correct to assume that if there are no declarations, the symbol is external.

@gz65555
Copy link
Author

gz65555 commented Jun 30, 2020

Sorry, I'm a newbie of typescript and typedoc. I still have some questions for your explain:

  • Are these code (target.declarations.some..) finding .d.ts files?
  • What does symbol.getDeclarations() do?

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jul 2, 2020

symbol.declarations is refers to everywhere the symbol is defined. That might be in declaration files or source files.
symbol.getDeclarations() is just a getter which returns symbol.declarations, but is correctly typed to return ts.Node[] | undefined, while symbol.declarations is incorrectly typed to be type ts.Node[]. There's an open issue in the TS repo regarding this. microsoft/TypeScript#24706

@lagoasoft-lucasschmidt
Copy link

same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

3 participants