TypeScript: TypeError: Cannot read property 'kind' of undefined at getAssignmentTargetKind

TypeScript Version: 3.2.2

Search Terms: Cannot read property ‘kind’ of undefined

I have found some results about this error but I haven’t found anything about the problem where my project throws the error: “at getAssignmentTargetKind”

Code I’m using angular 7.2.0 - the error first occured when I updated from 6.x to 7.x. Also I tried creating a new project and just migrate everything file by file but since the error happens so randomly it’s almost impossible to track down the file causing the problem 😕

Here’s the full error message:


ERROR in : TypeError: Cannot read property 'kind' of undefined
    at getAssignmentTargetKind (E:\dev\client7\node_modules\typescript\lib\typescript.js:10234:28)
    at Object.isAssignmentTarget (E:\dev\client7\node_modules\typescript\lib\typescript.js:10277:16)
    at checkObjectLiteral (E:\dev\client7\node_modules\typescript\lib\typescript.js:47309:45)
    at checkExpressionWorker (E:\dev\client7\node_modules\typescript\lib\typescript.js:51806:28)
    at checkExpression (E:\dev\client7\node_modules\typescript\lib\typescript.js:51751:42)
    at checkExpressionWithContextualType (E:\dev\client7\node_modules\typescript\lib\typescript.js:51581:26)
    at checkApplicableSignature (E:\dev\client7\node_modules\typescript\lib\typescript.js:48900:35)
    at chooseOverload (E:\dev\client7\node_modules\typescript\lib\typescript.js:49219:26)
    at resolveCall (E:\dev\client7\node_modules\typescript\lib\typescript.js:49171:26)
    at resolveCallExpression (E:\dev\client7\node_modules\typescript\lib\typescript.js:49478:20)
    at resolveSignature (E:\dev\client7\node_modules\typescript\lib\typescript.js:49766:28)
    at getResolvedSignature (E:\dev\client7\node_modules\typescript\lib\typescript.js:49798:26)
    at checkCallExpression (E:\dev\client7\node_modules\typescript\lib\typescript.js:49890:29)
    at checkExpressionWorker (E:\dev\client7\node_modules\typescript\lib\typescript.js:51817:28)
    at checkExpression (E:\dev\client7\node_modules\typescript\lib\typescript.js:51751:42)
    at resolveDecorator (E:\dev\client7\node_modules\typescript\lib\typescript.js:49685:28)

I added this to typescript.js:

function getAssignmentTargetKind(node) {
        var parent = node.parent;

        if(!parent) {
          console.log(node)
        }

Here’s the console.log


NodeObject {
  pos: 493,
  end: 596,
  flags: 8,
  transformFlags: 536870912,
  parent: undefined,
  kind: 188,
  properties:
   [ NodeObject {
       pos: 494,
       end: 516,
       flags: 0,
       transformFlags: 536870912,
       parent: [NodeObject],
       kind: 275,
       decorators: undefined,
       modifiers: undefined,
       name: [IdentifierObject],
       questionToken: undefined,
       exclamationToken: undefined,
       initializer: [TokenObject],
       modifierFlagsCache: 536870912,
       symbol: [SymbolObject] },
     NodeObject {
       pos: 517,
       end: 555,
       flags: 8,
       transformFlags: 536870912,
       parent: undefined,
       kind: 275,
       name: [IdentifierObject],
       questionToken: undefined,
       initializer: [NodeObject],
       original: [NodeObject],
       modifierFlagsCache: 536870912 },
     NodeObject {
       pos: -1,
       end: -1,
       flags: 8,
       transformFlags: 536870912,
       parent: undefined,
       kind: 275,
       name: [IdentifierObject],
       questionToken: undefined,
       initializer: [NodeObject],
       modifierFlagsCache: 536870912 },
     pos: -1,
     end: -1,
     hasTrailingComma: undefined,
     transformFlags: 536870912 ],
  multiLine: true,
  original:
   NodeObject {
     pos: 493,
     end: 596,
     flags: 0,
     transformFlags: 536870912,
     parent:
      NodeObject {
        pos: 483,
        end: 597,
        flags: 8192,
        transformFlags: 536870912,
        parent: [NodeObject],
        kind: 191,
        expression: [IdentifierObject],
        arguments: [Array],
        id: 136557 },
     kind: 188,
     multiLine: true,
     properties:
      [ [NodeObject],
        [NodeObject],
        [NodeObject],
        pos: 494,
        end: 594,
        transformFlags: 536870912 ],
     symbol:
      SymbolObject {
        flags: 4096,
        escapedName: '__object',
        declarations: [Array],
        members: [Map],
        valueDeclaration: [Circular] },
     nextContainer:
      NodeObject {
        pos: 666,
        end: 879,
        flags: 128,
        transformFlags: 536875010,
        parent: [NodeObject],
        kind: 157,
        decorators: undefined,
        modifiers: undefined,
        typeParameters: undefined,
        parameters: [Array],
        body: [NodeObject],
        modifierFlagsCache: 536870912,
        symbol: [SymbolObject],
        locals: [Map],
        returnFlowNode: [Object],
        nextContainer: [NodeObject],
        id: 136559 },
     contextualType: undefined,
     contextualMapper: undefined,
     jsDocCache: [] },
  modifierFlagsCache: 536870912,
  contextualType:
   TypeObject {
     checker:
      { getNodeCount: [Function: getNodeCount],
        getIdentifierCount: [Function: getIdentifierCount],
        getSymbolCount: [Function: getSymbolCount],
        getTypeCount: [Function: getTypeCount],
        isUndefinedSymbol: [Function: isUndefinedSymbol],
        isArgumentsSymbol: [Function: isArgumentsSymbol],
        isUnknownSymbol: [Function: isUnknownSymbol],
        getMergedSymbol: [Function: getMergedSymbol],
        getDiagnostics: [Function: getDiagnostics],
        getGlobalDiagnostics: [Function: getGlobalDiagnostics],
        getTypeOfSymbolAtLocation: [Function: getTypeOfSymbolAtLocation],
        getSymbolsOfParameterPropertyDeclaration: [Function: getSymbolsOfParameterPropertyDeclaration],
        getDeclaredTypeOfSymbol: [Function: getDeclaredTypeOfSymbol],
        getPropertiesOfType: [Function: getPropertiesOfType],
        getPropertyOfType: [Function: getPropertyOfType],
        getTypeOfPropertyOfType: [Function: getTypeOfPropertyOfType],
        getIndexInfoOfType: [Function: getIndexInfoOfType],
        getSignaturesOfType: [Function: getSignaturesOfType],
        getIndexTypeOfType: [Function: getIndexTypeOfType],
        getBaseTypes: [Function: getBaseTypes],
        getBaseTypeOfLiteralType: [Function: getBaseTypeOfLiteralType],
        getWidenedType: [Function: getWidenedType],
        getTypeFromTypeNode: [Function: getTypeFromTypeNode],
        getParameterType: [Function: getTypeAtPosition],
        getPromisedTypeOfPromise: [Function: getPromisedTypeOfPromise],
        getReturnTypeOfSignature: [Function: getReturnTypeOfSignature],
        getNullableType: [Function: getNullableType],
        getNonNullableType: [Function: getNonNullableType],
        typeToTypeNode: [Function: typeToTypeNode],
        indexInfoToIndexSignatureDeclaration: [Function: indexInfoToIndexSignatureDeclaration],
        signatureToSignatureDeclaration: [Function: signatureToSignatureDeclaration],
        symbolToEntityName: [Function: symbolToEntityName],
        symbolToExpression: [Function: symbolToExpression],
        symbolToTypeParameterDeclarations: [Function: symbolToTypeParameterDeclarations],
        symbolToParameterDeclaration: [Function: symbolToParameterDeclaration],
        typeParameterToDeclaration: [Function: typeParameterToDeclaration],
        getSymbolsInScope: [Function: getSymbolsInScope],
        getSymbolAtLocation: [Function: getSymbolAtLocation],
        getShorthandAssignmentValueSymbol: [Function: getShorthandAssignmentValueSymbol],
        getExportSpecifierLocalTargetSymbol: [Function: getExportSpecifierLocalTargetSymbol],
        getExportSymbolOfSymbol: [Function: getExportSymbolOfSymbol],
        getTypeAtLocation: [Function: getTypeAtLocation],
        getPropertySymbolOfDestructuringAssignment: [Function: getPropertySymbolOfDestructuringAssignment],
        signatureToString: [Function: signatureToString],
        typeToString: [Function: typeToString],
        symbolToString: [Function: symbolToString],
        typePredicateToString: [Function: typePredicateToString],
        writeSignature: [Function: writeSignature],
        writeType: [Function: writeType],
        writeSymbol: [Function: writeSymbol],
        writeTypePredicate: [Function: writeTypePredicate],
        getAugmentedPropertiesOfType: [Function: getAugmentedPropertiesOfType],
        getRootSymbols: [Function: getRootSymbols],
        getContextualType: [Function: getContextualType],
        getContextualTypeForObjectLiteralElement: [Function: getContextualTypeForObjectLiteralElement],
        getContextualTypeForArgumentAtIndex: [Function: getContextualTypeForArgumentAtIndex],
        getContextualTypeForJsxAttribute: [Function: getContextualTypeForJsxAttribute],
        isContextSensitive: [Function: isContextSensitive],
        getFullyQualifiedName: [Function: getFullyQualifiedName],
        getResolvedSignature: [Function: getResolvedSignature],
        getResolvedSignatureForSignatureHelp: [Function: getResolvedSignatureForSignatureHelp],
        getConstantValue: [Function: getConstantValue],
        isValidPropertyAccess: [Function: isValidPropertyAccess],
        isValidPropertyAccessForCompletions: [Function: isValidPropertyAccessForCompletions],
        getSignatureFromDeclaration: [Function: getSignatureFromDeclaration],
        isImplementationOfOverload: [Function: isImplementationOfOverload],
        getImmediateAliasedSymbol: [Function: getImmediateAliasedSymbol],
        getAliasedSymbol: [Function: resolveAlias],
        getEmitResolver: [Function: getEmitResolver],
        getExportsOfModule: [Function: getExportsOfModuleAsArray],
        getExportsAndPropertiesOfModule: [Function: getExportsAndPropertiesOfModule],
        getSymbolWalker: [Function: getSymbolWalker],
        getAmbientModules: [Function: getAmbientModules],
        getJsxIntrinsicTagNamesAt: [Function: getJsxIntrinsicTagNamesAt],
        isOptionalParameter: [Function: isOptionalParameter],
        tryGetMemberInModuleExports: [Function: tryGetMemberInModuleExports],
        tryGetMemberInModuleExportsAndProperties: [Function: tryGetMemberInModuleExportsAndProperties],
        tryFindAmbientModuleWithoutAugmentations: [Function: tryFindAmbientModuleWithoutAugmentations],
        getApparentType: [Function: getApparentType],
        getUnionType: [Function: getUnionType],
        createAnonymousType: [Function: createAnonymousType],
        createSignature: [Function: createSignature],
        createSymbol: [Function: createSymbol],
        createIndexInfo: [Function: createIndexInfo],
        getAnyType: [Function: getAnyType],
        getStringType: [Function: getStringType],
        getNumberType: [Function: getNumberType],
        createPromiseType: [Function: createPromiseType],
        createArrayType: [Function: createArrayType],
        getElementTypeOfArrayType: [Function: getElementTypeOfArrayType],
        getBooleanType: [Function: getBooleanType],
        getFalseType: [Function: getFalseType],
        getTrueType: [Function: getTrueType],
        getVoidType: [Function: getVoidType],
        getUndefinedType: [Function: getUndefinedType],
        getNullType: [Function: getNullType],
        getESSymbolType: [Function: getESSymbolType],
        getNeverType: [Function: getNeverType],
        isSymbolAccessible: [Function: isSymbolAccessible],
        getObjectFlags: [Function: getObjectFlags],
        isArrayLikeType: [Function: isArrayLikeType],
        isTypeInvalidDueToUnionDiscriminant: [Function: isTypeInvalidDueToUnionDiscriminant],
        getAllPossiblePropertiesOfTypes: [Function: getAllPossiblePropertiesOfTypes],
        getSuggestionForNonexistentProperty: [Function: getSuggestionForNonexistentProperty],
        getSuggestionForNonexistentSymbol: [Function: getSuggestionForNonexistentSymbol],
        getSuggestionForNonexistentExport: [Function: getSuggestionForNonexistentExport],
        getBaseConstraintOfType: [Function: getBaseConstraintOfType],
        getDefaultFromTypeParameter: [Function: getDefaultFromTypeParameter],
        resolveName: [Function: resolveName],
        getJsxNamespace: [Function: getJsxNamespace],
        getAccessibleSymbolChain: [Function: getAccessibleSymbolChain],
        getTypePredicateOfSignature: [Function: getTypePredicateOfSignature],
        resolveExternalModuleSymbol: [Function: resolveExternalModuleSymbol],
        tryGetThisTypeAt: [Function: tryGetThisTypeAt],
        getTypeArgumentConstraint: [Function: getTypeArgumentConstraint],
        getSuggestionDiagnostics: [Function: getSuggestionDiagnostics],
        runWithCancellationToken: [Function: runWithCancellationToken],
        getLocalTypeParametersOfClassOrInterfaceOrTypeAlias:
         [Function: getLocalTypeParametersOfClassOrInterfaceOrTypeAlias] },
     flags: 524288,
     id: 14277,
     objectFlags: 2,
     symbol:
      SymbolObject {
        flags: 66,
        escapedName: 'Component',
        declarations: [Array],
        members: [Map],
        parent: [SymbolObject],
        exports: Map {},
        valueDeclaration: [NodeObject],
        id: 118624,
        isReferenced: 67897832 },
     members:
      Map {
        'changeDetection' => [SymbolObject],
        'viewProviders' => [SymbolObject],
        'moduleId' => [SymbolObject],
        'templateUrl' => [SymbolObject],
        'template' => [SymbolObject],
        'styleUrls' => [SymbolObject],
        'styles' => [SymbolObject],
        'animations' => [SymbolObject],
        'encapsulation' => [SymbolObject],
        'interpolation' => [SymbolObject],
        'entryComponents' => [SymbolObject],
        'preserveWhitespaces' => [SymbolObject],
        'selector' => [SymbolObject],
        'inputs' => [SymbolObject],
        'outputs' => [SymbolObject],
        'providers' => [SymbolObject],
        'exportAs' => [SymbolObject],
        'queries' => [SymbolObject],
        'host' => [SymbolObject],
        'jit' => [SymbolObject] },
     properties:
      [ [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject] ],
     callSignatures: [],
     constructSignatures: [],
     stringIndexInfo: undefined,
     numberIndexInfo: undefined,
     resolvedBaseTypes: [ [TypeObject] ],
     declaredProperties:
      [ [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject],
        [SymbolObject] ],
     declaredCallSignatures: [],
     declaredConstructSignatures: [],
     declaredStringIndexInfo: undefined,
     declaredNumberIndexInfo: undefined },
  contextualMapper: undefined }

Expected behavior: No errors

Actual behavior: See above

Is there anything I can do to finally track down the file/code causing the error?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 17
  • Comments: 25 (2 by maintainers)

Commits related to this issue

Most upvoted comments

and only on Windows

Same issue for me. I use angular 7.2.2, typescript 3.2.4

@therawk Hi, I installed ‘@type/history’ and it dosn’t works. Personnaly, I don’t understand how could it have worked.