Skip to content

Commit

Permalink
expose svelte2tsx component documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tymek committed Jan 27, 2022
1 parent cad755f commit 7bb4385
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
19 changes: 16 additions & 3 deletions packages/svelte2tsx/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,24 @@ export interface SvelteCompiledToTsx {
map: import("magic-string").SourceMap;
exportedNames: IExportedNames;
events: ComponentEvents;
componentDocumentation: string;
slots: Map<string, Map<string, string>>;
generics: {
definitions: string[];
references: string[];
};
}

export interface IExportedNames {
has(name: string): boolean;
}
export type IExportedNames = Map<
string,
{
isLet: boolean;
type?: string;
identifierText?: string;
required?: boolean;
doc?: string;
}
>;

export interface ComponentEvents {
getAll(): { name: string; type: string; doc?: string }[];
Expand Down
8 changes: 7 additions & 1 deletion packages/svelte2tsx/src/svelte2tsx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,13 @@ declare function __sveltets_1_createSvelteComponentTyped<Props, Events, Slots>(
code: str.toString(),
map: str.generateMap({ hires: true, source: options?.filename }),
exportedNames: exportedNames.getExportsMap(),
events: events.createAPI()
events: events.createAPI(),
componentDocumentation: componentDocumentation.getFormatted(),
slots,
generics: {
definition: generics.toDefinitionString(),
references: generics.toReferencesString()
}
};
}
}

0 comments on commit 7bb4385

Please sign in to comment.