knnhcn
knnhcn

Reputation: 1151

Monaco editor change custom types behaviour

I have discovered how to add custom completions to custom declared classes for the Monaco editor. Like below:

monaco.languages.typescript.javascriptDefaults.addExtraLib([
'declare class Facts {',
'    /**',
'     * Returns the next fact',
'     */',
'    static next():string',
'}',
].join('\n'), 'filename/facts.d.ts');

But the problem I have now is that the new Facts type also shows inherited methods and properties like prototype:

enter image description here Is there a way to disable default class/type behaviour and only show the custom methods declared?

Thanks in advance!

Upvotes: 1

Views: 891

Answers (1)

Mike Cluck
Mike Cluck

Reputation: 32511

You could change your definition from a class to an object. Then it will only display the properties you define on it.

monaco.languages.typescript.javascriptDefaults.addExtraLib([
'declare const Facts = {',
'    /**',
'     * Returns the next fact',
'     */',
'    static next():string',
'}',
].join('\n'), 'filename/facts.d.ts');

Upvotes: 2

Related Questions