Skip to content

Commit

Permalink
Export the Viz type
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaines committed Jan 5, 2024
1 parent 012cc0a commit ab72f38
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 17 deletions.
1 change: 0 additions & 1 deletion .github/workflows/viz-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,4 @@ jobs:
run: |
yarn install --frozen-lockfile
yarn check-types
yarn check-types-esnext
working-directory: packages/viz/test/types
2 changes: 2 additions & 0 deletions packages/viz/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

* Export the Viz type (#224, #225)

## 3.2.3

* Add a workaround for node names not being used as labels (#218)
Expand Down
8 changes: 8 additions & 0 deletions packages/viz/test/types/not-exported.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @ts-expect-error
import { Viz } from "@viz-js/viz";

// @ts-expect-error
import { type SuccessResult } from "@viz-js/viz";

// @ts-expect-error
import { type FailureResult } from "@viz-js/viz";
4 changes: 2 additions & 2 deletions packages/viz/test/types/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"private": true,
"type": "module",
"dependencies": {
"@viz-js/viz": "link:../..",
"typescript": "^5.1.3"
},
"scripts": {
"check-types": "tsc --strict --lib es2015,dom --noEmit *.ts",
"check-types-esnext": "tsc --strict --lib es2015,dom --module esnext --moduleResolution bundler --noEmit *.ts"
"check-types": "tsc --strict --lib es2015,dom --module esnext --moduleResolution bundler --verbatimModuleSyntax --noEmit *.ts"
}
}
14 changes: 1 addition & 13 deletions packages/viz/test/types/top-level.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
import { instance, graphvizVersion, formats, engines, type RenderOptions, type RenderResult, type RenderError } from "@viz-js/viz";

// @ts-expect-error
import { Viz } from "@viz-js/viz";

// @ts-expect-error
import { type Viz } from "@viz-js/viz";

// @ts-expect-error
import { type SuccessResult } from "@viz-js/viz";

// @ts-expect-error
import { type FailureResult } from "@viz-js/viz";
import { instance, graphvizVersion, formats, engines, type RenderOptions, type RenderResult, type RenderError, type Viz } from "@viz-js/viz";

let version: string = graphvizVersion;

Expand Down
8 changes: 7 additions & 1 deletion packages/viz/test/types/viz.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { instance } from "@viz-js/viz";
import { instance, type Viz } from "@viz-js/viz";

export function myRender(viz: Viz, src: string): string {
return viz.renderString(src, { graphAttributes: { label: "My graph" } });
}

instance().then(viz => {
viz.render("digraph { a -> b }");
Expand All @@ -11,6 +15,8 @@ instance().then(viz => {

viz.render({ edges: [{ tail: "a", head: "b" }] });

myRender(viz, "digraph { a -> b }");

// @ts-expect-error
viz.render("digraph { a -> b }", { format: false });

Expand Down
2 changes: 2 additions & 0 deletions packages/viz/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ declare class Viz {
renderJSON(input: string | Graph, options?: RenderOptions): object
}

export { type Viz }

export interface RenderOptions {
format?: string
engine?: string
Expand Down

0 comments on commit ab72f38

Please sign in to comment.