question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No auto-completion on typescript interface with classes implement

See original GitHub issue

Redirected by https://github.com/microsoft/vscode-cpptools/issues/3789

Type: LanguageService Describe the bug

  • macOS Mojave 10.14.5
  • VSCODE : 1.35.1
  • TS 3.5.1

To Reproduce

Create a file with the following :

import { Strategy } from "passport-local";

class SSOPlugin implements Plugin {

  constructor() {}

  init() {}
}

interface Plugin {
  authenticators?: Record<string, any>;

  strategies: { [key: string]: KuzzleStrategy };
}

interface KuzzleStrategy {
  config: {
    authenticator: string;
    fields: string[];
  };
  methods: {
    afterRegister?: () => any;
    create: () => any;
    delete: () => any;
    exists: () => any;
    getById?: () => any;
    getInfo?: () => any;
    update: () => any;
    validate: () => any;
    verify: () => any;
  };
}

export = SSOPlugin;

In constructor or any method using this. and auto-completion doesn’t give anything.

But if I give the wrong types, the compiler complain (also red line on IDE).

Expected behavior

I should get auto-completion.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
mjbvzcommented, Jun 20, 2019

Thanks.

Minimal example:

class Foo implements IFoo {
    methods = {
        x: '',
        |
    }
}

interface IFoo {
    methods: {
        x: string;
        y: string;
    };
}
  1. Trigger suggestions at |
  2. No suggestion for y shown
0reactions
ScreamZcommented, May 4, 2020

Hello all, any news on that? I’m experiencing it using NestJS CustomScalar interface… Get complicated 😅

@RyanCavanaugh @mjbvz Maybe you have some ideas, not exactly the same issue as reported above

export class PasswordScalar implements CustomScalar<string, ObjectId> {
  parseLiteral(ast) {
    // ast is considered "any"
  }
}

// Those are taken from NestJS, the most advanced typescript framework for nodejs
export interface CustomScalar<T, K> {
    description?: string;
    parseValue: GraphQLScalarValueParser<K>;
    serialize: GraphQLScalarSerializer<T>;
    parseLiteral: GraphQLScalarLiteralParser<K>;
}

export type GraphQLScalarLiteralParser<TInternal> = (
  valueNode: ValueNode,
  variables: Maybe<{ [key: string]: any }>,
) => Maybe<TInternal>;

For not having ast considered as any, is have to parseLiteral(ast: ValueNode) {

Read more comments on GitHub >

github_iconTop Results From Across the Web

class - How to let VSCode/Typescript to do auto complete on ...
//I tried implementing interface, but it won't help, with or without the interface interface FooInterface { bar: Function } class Foo ...
Read more >
Working with JavaScript in Visual Studio Code
Using the TypeScript language service, VS Code can provide smart completions (IntelliSense) as well as type checking for JavaScript.
Read more >
Code completion | WebStorm Documentation - JetBrains
To show you completion suggestions, WebStorm goes through the project files with the source code and adds classes, methods, functions, ...
Read more >
JavaScript IntelliSense - Visual Studio - Microsoft Learn
ts file (see TypeScript documentation), and types such as interfaces and classes declared in TypeScript are available for use as types in JsDoc ......
Read more >
Place Autocomplete | Maps JavaScript API - Google Developers
To retrieve predictions programmatically, use the AutocompleteService class. AutocompleteService does not add any UI controls. Instead, it returns an array of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found