Skip to content

Commit

Permalink
wip export viz type
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaines committed Dec 28, 2023
1 parent b6c80de commit d65c48d
Show file tree
Hide file tree
Showing 6 changed files with 20 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
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";

function myRender(viz: Viz, src: string) {
return viz.render(src);
}

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 d65c48d

Please sign in to comment.