Skip to content

[async] Cannot read property 'members' of undefined #3978

Closed

Description

when compiling this code for ES5 (not ES6)

async function f() {
   return { };  
}

instead of giving the "only available in ES6" warning, it throws this exception:

               throw e;
                     ^
TypeError: Cannot read property 'members' of undefined
   at resolveDeclaredMembers (C:\Users\Nino\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:15429:65)
   at resolveTypeReferenceMembers (C:\Users\Nino\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:15459:26)
   at resolveStructuredTypeMembers (C:\Users\Nino\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:15665:21)
   at getPropertiesOfObjectType (C:\Users\Nino\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:15673:24)
   at propertiesRelatedTo (C:\Users\Nino\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:17141:34)
   at objectTypeRelatedTo (C:\Users\Nino\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:17107:30)
   at isRelatedTo (C:\Users\Nino\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:16935:34)
   at checkTypeRelatedTo (C:\Users\Nino\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:16824:26)
   at checkTypeAssignableTo (C:\Users\Nino\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:16797:20)
   at isTypeAssignableTo (C:\Users\Nino\AppData\Roaming\npm\node_modules\typescript\bin\tsc.js:16791:20)

using tsc 1.5.3

Activity

  1. rbuckton commented on Aug 4, 2015

    @rbuckton
    Contributor

    nino-porcino (@nippur72): TypeScript 1.5.3 does not contain support for Async Functions, and I cannot seem to repro this in master. It's possible a recent unrelated change may have fixed this. Is it possible you were using a different version of the compiler than the one you mentioned above? Can you verify the version of the compiler you are using, or possibly verify this against a recent nightly build?

  2. mhegazy commented on Aug 4, 2015

    @mhegazy
    Contributor

    nino-porcino (@nippur72) can you try using latest `typescript@next?

  3. nippur72 commented on Aug 5, 2015

    @nippur72
    Author

    Mohamed Hegazy (@mhegazy) Ron Buckton (@rbuckton) I've checked with typescript@next and the bug is gone, so I'm closing this.

    (P.S. I was sure it was 1.5.3, but as you've said it couldn't be, so more likely I had something greater than 1.5.3).

  4. mhegazy commented on Aug 5, 2015

    @mhegazy
    Contributor

    thanks nino-porcino (@nippur72) for confirming.

  5. jsen- commented on Aug 20, 2015

    @jsen-

    I think the issue is not yet gone.

    I'm using typescript 1.6.0-dev.20150819 with experimentalAsyncFunctions enabled, targetting es6

    The following code seems to trigger the error:

    async function abcd() {
        console.log('abcd');
    }
    abcd().then(() => {
        console.log('then');
    });

    or

    async function abcd() {
        console.log('abcd');
    }
    async function runAbcd() {
        await abcd();
    }
    runAbcd();

    The following compiles (unfortunately there's no awaiting mechanism):

    async function abcd() {
        console.log('abcd');
    }
    abcd();
    D:\projects\sach\node_modules\electrolyte\node_modules\typescript\lib\typescript.js:35252
                    throw e;
                    ^
    
    TypeError: Cannot read property 'members' of undefined
        at resolveDeclaredMembers (D:\projects\sach\node_modules\electrolyte\node_modules\typescript\lib\typescript.js:15607:65)
        at resolveTypeReferenceMembers (D:\projects\sach\node_modules\electrolyte\node_modules\typescript\lib\typescript.js:15637:26)
        at resolveStructuredTypeMembers (D:\projects\sach\node_modules\electrolyte\node_modules\typescript\lib\typescript.js:15870:21)
        at getPropertyOfType (D:\projects\sach\node_modules\electrolyte\node_modules\typescript\lib\typescript.js:16002:32)
        at checkPropertyAccessExpressionOrQualifiedName (D:\projects\sach\node_modules\electrolyte\node_modules\typescript\lib\typescript.js:19993:24)
        at checkPropertyAccessExpression (D:\projects\sach\node_modules\electrolyte\node_modules\typescript\lib\typescript.js:19978:20)
        at checkExpressionWorker (D:\projects\sach\node_modules\electrolyte\node_modules\typescript\lib\typescript.js:22117:28)
        at checkExpression (D:\projects\sach\node_modules\electrolyte\node_modules\typescript\lib\typescript.js:22068:42)
        at resolveCallExpression (D:\projects\sach\node_modules\electrolyte\node_modules\typescript\lib\typescript.js:20919:28)
        at getResolvedSignature (D:\projects\sach\node_modules\electrolyte\node_modules\typescript\lib\typescript.js:21088:47)
    

    iojs versions:

    { http_parser: '2.5.0',
      node: '3.0.0',
      v8: '4.4.63.26',
      uv: '1.6.1',
      zlib: '1.2.8',
      ares: '1.10.1-DEV',
      modules: '45',
      openssl: '1.0.2d' }
    
  6. nippur72 commented on Aug 20, 2015

    @nippur72
    Author

    Yes the issue is back, I re-discovered it yesterday in 1.6 nightly, so I'm reopening it.

  7. rbuckton commented on Aug 28, 2015

    @rbuckton
    Contributor

    This is now fixed for 1.6.

  8. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions