JetBrains / web-types

JSON standard for documenting web component libraries for IDEs, documentation generators and other tools
Apache License 2.0
285 stars 25 forks source link

Source class for Web Components #40

Closed Illusive7Man closed 2 years ago

Illusive7Man commented 2 years ago

I am trying to add a TypeScript class as a source for my custom element, but I can't figure out how to properly configure it.

Here's one of the things I've tried:

"name": "my-element",
"source": {
  "module": "MyModule",
  "symbol": "MyClass"
}

and this is a typescript file containing the class:

export declare module MyModule {
    export class MyClass {
        public Name: string;
        public LastName: string;
    }
}

I have also tried adding path in the "module" option,

Can someone instruct me on how to get a TypeScript class to work as a custom-element's source? To be able to navigate to it, etc.?

piotrtomiak commented 2 years ago

Hi!

The module can be the name of node_module package or a relative path to a TS/JS file. The TS module construct is not recognized. Is it possible for you to export the class from the "node_module" package? Or from a file?

Illusive7Man commented 2 years ago

That did it. Removed the module declaration and in the "module" field added the relative path to the .ts file from web-types. Thanks!