Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#51381 Add a few more methods to viz.js Ren…
Browse files Browse the repository at this point in the history
…derer by @danvk
  • Loading branch information
danvk committed Feb 26, 2021
1 parent d64ea2c commit f6ddda2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions types/viz.js/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ type RenderFunction = (instance: Module, src: string, options: Options) => strin
declare class Viz {
constructor(arg: { Module: Module; render: RenderFunction });
renderString(src: string, options?: Options): Promise<string>;
renderSVGElement(src: string, options?: Options): Promise<SVGSVGElement>;
renderImageElement(src: string, options?: Options): Promise<HTMLImageElement>;
renderJSONObject(src: string, options?: Options): Promise<object>;
}
1 change: 1 addition & 0 deletions types/viz.js/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"dom",
"es6"
],
"noImplicitAny": true,
Expand Down
9 changes: 9 additions & 0 deletions types/viz.js/viz.js-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ viz.renderString("string", {files: []});
viz.renderString("string", {images: ["totally a file"]});
viz.renderString("string", {format: "svg", engine: "fdp", files: ["test"], images: ["totally an image"], yInvert: false});

// $ExpectType Promise<SVGSVGElement>
viz.renderSVGElement("string");

// $ExpectType Promise<HTMLImageElement>
viz.renderImageElement("string");

// $ExpectType Promise<object>
viz.renderJSONObject("string");

// Incorrect
new Viz({Module: 1, render}); // $ExpectError
new Viz({Module: {}, render}); // $ExpectError
Expand Down

0 comments on commit f6ddda2

Please sign in to comment.