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 'escapedName' of undefined #29

Open
ravisharnagat opened this issue Jun 24, 2021 · 2 comments
Open

TypeError: Cannot read property 'escapedName' of undefined #29

ravisharnagat opened this issue Jun 24, 2021 · 2 comments

Comments

@ravisharnagat
Copy link

Getting following error:
Error: Failed to generate a codec for:

Getting this is stack trace:

TypeError: Cannot read property 'escapedName' of undefined
    at Object.isArrayType (/Users/ravisharnagat/ts-2-iots/types.js:50:24)
    at /Users/ravisharnagat/ts-2-iots/index.js:90:22
    at /Users/ravisharnagat/ts-2-iots/index.js:33:48
    at Array.map (<anonymous>)
    at /Users/ravisharnagat/ts-2-iots/index.js:52:14
    at /Users/ravisharnagat/ts-2-iots/index.js:107:42
    at handleDeclaration (/Users/ravisharnagat/ts-2-iots/index.js:128:69)
    at /Users/ravisharnagat/ts-2-iots/index.js:139:21
    at visitNodes (/Users/ravisharnagat/ts-2-iots/node_modules/typescript/lib/typescript.js:18973:30)
    at Object.forEachChild (/Users/ravisharnagat/ts-2-iots/node_modules/typescript/lib/typescript.js:19206:24)
@ravisharnagat
Copy link
Author

ravisharnagat commented Jun 24, 2021

We are getting the error in following part of the code:

export function isArrayType(type: ts.Type) {
  return type.symbol.escapedName === 'Array'
}

Adding type.symbol && check will fix the issue.

Fix:

export function isArrayType(type: ts.Type) {
  return type.symbol && type.symbol.escapedName === 'Array'
}

@ravisharnagat
Copy link
Author

#30 fixes this

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