2
votes

I'm looking for a way to extend the type hints in monaco editor (like Object, String or Boolean) with my own king of type. The goal is that the editor knows the type and can provide code completion to the specific type.

All the previous examples I found are by inserting strings on addExtraLib but this is not professional:

monaco.languages.typescript.javascriptDefaults.addExtraLib([
    'declare class MyClass {',
    '    count: number',
    '}'
].join('\n'));

What I am looking for is to provide e.g. following .d.ts file or any file to let the editor know of my type, to better automate the process:

  // myclass.d.ts
  export class MyClass = {
    count: number
  }

Is there something I am missing out?

1

1 Answers

0
votes

After a long time I have finally come across an issue where is explained how to import type definitions by file.

But as also stated in the comment, it still has to be string. The end solution I came up with is to raw-import my files where the types are defined in strings and then add it that way into monaco editor.

Linkt to comment