Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export the Viz type #225

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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