From cb22354b5c298fced542c65db97c664bae96880a Mon Sep 17 00:00:00 2001 From: cnrmck <22061955+cnrmck@users.noreply.github.com> Date: Wed, 15 Feb 2023 14:18:18 -0500 Subject: [PATCH] Add `as VisualizationSpec` type to spec definition Otherwise, user gets error: ``` Type '{ width: number; height: number; mark: { type: string; }; encoding: { x: { field: string; type: string; }; y: { field: string; type: string; }; }; data: { name: string; }; }' is not assignable to type 'VisualizationSpec'. Type '{ width: number; height: number; mark: { type: string; }; encoding: { x: { field: string; type: string; }; y: { field: string; type: string; }; }; data: { name: string; }; }' is not assignable to type 'TopLevelUnitSpec'. Type '{ width: number; height: number; mark: { type: string; }; encoding: { x: { field: string; type: string; }; y: { field: string; type: string; }; }; data: { name: string; }; }' is not assignable to type 'GenericUnitSpec, AnyMark, TopLevelParameter>'. Types of property 'mark' are incompatible. Type '{ type: string; }' is not assignable to type 'AnyMark'. Type '{ type: string; }' is not assignable to type 'MarkDef<"bar" | "area" | "circle" | "image" | "line" | "rect" | "text" | "arc" | "point" | "rule" | "tick" | "trail" | "square" | "geoshape", ExprRef | SignalRef>'. Types of property 'type' are incompatible. Type 'string' is not assignable to type '"bar" | "area" | "circle" | "image" | "line" | "rect" | "text" | "arc" | "point" | "rule" | "tick" | "trail" | "square" | "geoshape"'. ``` --- packages/react-vega/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-vega/README.md b/packages/react-vega/README.md index d18c90e..074dddb 100644 --- a/packages/react-vega/README.md +++ b/packages/react-vega/README.md @@ -86,7 +86,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { Vega } from 'react-vega'; -const spec = { +const spec: VisualizationSpec = { "width": 400, "height": 200, "data": [{ "name": "table" }], @@ -134,7 +134,7 @@ import React from 'react' import ReactDOM from 'react-dom' import { VegaLite } from 'react-vega' -const spec = { +const spec: VisualizationSpec = { width: 400, height: 200, mark: 'bar',