Skip to content

"TypeError: Cannot read property 'flags' of undefined" when returning a non Promise custom type from an async function #5399

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
robotlovesyou opened this issue Oct 25, 2015 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@robotlovesyou
Copy link

I'm fairly sure this is unrelated to #5389

Returning a non-Promise custom type from an async function causes the compiler to crash.

Given this tsconfig

{
    "compilerOptions": {
        "experimentalAsyncFunctions": true,
        "target": "ES6"
    }
}

and this code

type SomeType = {
    someValue: string
}

async function someFunction(): SomeType {
    return {
        someValue: ''
    }
}

tsc will crash with the following

TypeError: Cannot read property 'flags' of undefined
    at isKnownProperty (/Users/andrewsmith/.nvm/versions/node/v0.12.6/lib/node_modules/typescript/lib/tsc.js:14041:25)
    at hasExcessProperties (/Users/andrewsmith/.nvm/versions/node/v0.12.6/lib/node_modules/typescript/lib/tsc.js:14063:26)
    at isRelatedTo (/Users/andrewsmith/.nvm/versions/node/v0.12.6/lib/node_modules/typescript/lib/tsc.js:13955:25)
    at checkTypeRelatedTo (/Users/andrewsmith/.nvm/versions/node/v0.12.6/lib/node_modules/typescript/lib/tsc.js:13903:26)
    at checkTypeAssignableTo (/Users/andrewsmith/.nvm/versions/node/v0.12.6/lib/node_modules/typescript/lib/tsc.js:13886:20)
    at checkReturnStatement (/Users/andrewsmith/.nvm/versions/node/v0.12.6/lib/node_modules/typescript/lib/tsc.js:19460:29)
    at checkSourceElement (/Users/andrewsmith/.nvm/versions/node/v0.12.6/lib/node_modules/typescript/lib/tsc.js:20461:28)
    at Object.forEach (/Users/andrewsmith/.nvm/versions/node/v0.12.6/lib/node_modules/typescript/lib/tsc.js:90:30)
    at checkBlock (/Users/andrewsmith/.nvm/versions/node/v0.12.6/lib/node_modules/typescript/lib/tsc.js:18973:16)
    at checkSourceElement (/Users/andrewsmith/.nvm/versions/node/v0.12.6/lib/node_modules/typescript/lib/tsc.js:20440:28)

tsc -v returns message TS6029: Version 1.6.2

@DanielRosenwasser
Copy link
Member

Might be a duplicate of #5115. Looks like this has been fixed for release-1.7 and master. You can try out our recent nightly builds by installing typescript@next on npm. Thanks for filing this @robotlovesyou.

@DanielRosenwasser DanielRosenwasser added the Duplicate An existing issue was already created label Oct 26, 2015
@robotlovesyou
Copy link
Author

Oops. Sorry. Only checked open issues. I'll test against a @next release before filing next time.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants