Skip to content

Unknown Node Type error when putting call signatures in interface #37

Description

@dobesv
The 'interface-sort-keys' rule threw an error in '/home/ubuntu/app/src/lib/client/apollo/dataIdFromObject.ts':
Error: 
          Unknown Node Type!
          This might be a case that's not covered yet.
          Please file an issue at https://github.com/crazyfactory/tslint-rules
        
    at InterfaceSortKeysRule.checkAlphabetical (/home/ubuntu/app/node_modules/@crazyfactory/tslint-rules/lib/interfaceSortKeysRule.js:50:23)
    at InterfaceSortKeysRule.visitInterfaceDeclaration (/home/ubuntu/app/node_modules/@crazyfactory/tslint-rules/lib/interfaceSortKeysRule.js:32:14)
    at InterfaceSortKeysRule.SyntaxWalker.visitNode (/home/ubuntu/app/node_modules/tslint/lib/language/walker/syntaxWalker.js:401:22)
    at /home/ubuntu/app/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:63
    at visitNodes (/home/ubuntu/app/node_modules/typescript/lib/typescript.js:18440:30)
    at Object.forEachChild (/home/ubuntu/app/node_modules/typescript/lib/typescript.js:18673:24)
    at InterfaceSortKeysRule.SyntaxWalker.walkChildren (/home/ubuntu/app/node_modules/tslint/lib/language/walker/syntaxWalker.js:535:12)
    at InterfaceSortKeysRule.SyntaxWalker.visitSourceFile (/home/ubuntu/app/node_modules/tslint/lib/language/walker/syntaxWalker.js:228:14)
    at InterfaceSortKeysRule.SyntaxWalker.visitNode (/home/ubuntu/app/node_modules/tslint/lib/language/walker/syntaxWalker.js:482:22)
    at InterfaceSortKeysRule.SyntaxWalker.walk (/home/ubuntu/app/node_modules/tslint/lib/language/walker/syntaxWalker.js:24:14)

This is the file:

interface DataIdFromObjectProps {
  __typename: string;
  _id?: string | null;
}

// with our custom resolvers
interface DataIdFromObjectType {
  (obj: { __typename: string; _id: string }): string;
  (obj: { __typename?: string | null } | { _id?: string | null }):
    | string
    | null;
  (obj: { __typename?: null } | { _id?: null }): null;
}

export const cacheObjectId = (__typename: string, _id: string) =>
  [__typename, _id].join(':');

const dataIdFromObject = (({ __typename, _id }: DataIdFromObjectProps) =>
  (__typename && _id && cacheObjectId(__typename, _id)) ||
  null) as DataIdFromObjectType;

export default dataIdFromObject;

I'm guessing it doesn't like the syntax for the call signature of the interface.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions