profile
viewpoint

Ask questionsNo auto-completion on typescript interface with classes implement

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.

microsoft/TypeScript

Answer questions ScreamZ

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) {

useful!

Related questions

Why `window.location.reload(true)` is deprecated? hot 8
Cannot export { ... } interface when --isolatedModules is passed hot 3
TS2739: Type is missing the following properties from type hot 3
TSC Strict mode error TS2722: Cannot invoke an object which is possibly 'undefined'. hot 2
This condition will always return 'false' since the types have no overlap. hot 2
Allow extending types referenced through interfaces hot 2
Suppressing "The import path cannot end with a '.ts' extension" error? hot 2
Property 'setState' does not exist on type 'App'.ts(2339) hot 2
Cannot find name 'MediaRecorder'. hot 2
tsc.ps1 cannot be loaded. The file ... is not digitally signed hot 2
error TS1183: An implementation cannot be declared in ambient contexts. hot 2
3.7.2 Promise.all does infers base type of interfaces rather than actual interface hot 1
Skip typechecking; only emit (support `--transpileOnly` in `tsc`, re-open of #4176) hot 1
tsc crash with node OOM hot 1
error TS2688: Cannot find type definition file for...random paths. hot 1
Github User Rank List