Skip to content

TypeError: Cannot read property 'length' of undefined in watch mode and {allowJS: true} #35074

Closed
@lephuongbg

Description

@lephuongbg

TypeScript Version: 3.7.2 and 3.8 beta

Expected behavior:

Newer typescript should not crash with existing code.

Actual behavior:

A specific combination of vuex and typescript 3.7.2 with allowJs: true and watch mode causes typescript to crashes with following stack trace:

$ ./node_modules/.bin/tsc --noEmit --watch
/var/app/web/node_modules/typescript/lib/tsc.js:78566
                throw e;
                ^

TypeError: Cannot read property 'length' of undefined
    at Object.find (/var/app/web/node_modules/typescript/lib/tsc.js:207:35)
    at getDeclarationWithTypeAnnotation (/var/app/web/node_modules/typescript/lib/tsc.js:31333:31)
    at isTypeRepresentableAsFunctionNamespaceMerge (/var/app/web/node_modules/typescript/lib/tsc.js:31275:26)
    at serializeMaybeAliasAssignment (/var/app/web/node_modules/typescript/lib/tsc.js:31251:29)
    at serializeVariableOrProperty (/var/app/web/node_modules/typescript/lib/tsc.js:31059:25)
    at serializeSymbolWorker (/var/app/web/node_modules/typescript/lib/tsc.js:30927:25)
    at serializeSymbol (/var/app/web/node_modules/typescript/lib/tsc.js:30894:38)
    at /var/app/web/node_modules/typescript/lib/tsc.js:30875:25
    at Map.forEach (<anonymous>)
    at visitSymbolTable (/var/app/web/node_modules/typescript/lib/tsc.js:30874:33)

A simple js file like this will trigger above bug:

import {createNamespacedHelpers} from 'vuex'

const {mapState} = createNamespacedHelpers(STORE_NS)

export default {
    computed: {
        ...mapState(['panels'])  // <==== Bug is triggered with this line
    }
}

Reproduction repository is here: https://github.com/lephuongbg/typescript-bug-repro

Related Issues:
Not sure

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputDomain: Declaration EmitThe issue relates to the emission of d.ts filesFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions