Skip to content
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

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

Open
dobesv opened this issue May 25, 2020 · 3 comments
Open

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

dobesv opened this issue May 25, 2020 · 3 comments

Comments

@dobesv
Copy link

dobesv commented May 25, 2020

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.

@paibamboo
Copy link
Contributor

Hi @dobesv! Sorry for the delay. Thanks for your interest in the project. Too bad interface-sort-keys rule covers very limited use case. It only supports instance fields. I recommend checking out member-ordering instead. We also abandoned interface-sort-keys and have used member-ordering, have had no issues so far.

@dobesv
Copy link
Author

dobesv commented Jun 1, 2020

Does member-ordering work for interfaces? I thought it only works for classes.

@paibamboo
Copy link
Contributor

Yes, it does work on interfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants