From 9aac5b4ebf0fef2aeaedb970e867cf92952c2d6c Mon Sep 17 00:00:00 2001 From: Nathan Muir Date: Wed, 20 Aug 2025 11:27:20 +1200 Subject: [PATCH] refactor: enable typescript option `verbatimModuleSyntax` --- src/Animation.ts | 4 ++-- src/Canvas.ts | 3 ++- src/Container.ts | 11 ++++++----- src/Context.ts | 6 +++--- src/DragAndDrop.ts | 6 +++--- src/Factory.ts | 4 ++-- src/Group.ts | 7 ++++--- src/Layer.ts | 12 +++++++----- src/Node.ts | 15 ++++++++------- src/PointerEvents.ts | 6 +++--- src/Shape.ts | 9 +++++---- src/Stage.ts | 9 +++++---- src/Tween.ts | 5 +++-- src/Util.ts | 4 ++-- src/_CoreInternals.ts | 9 ++++++--- src/_FullInternals.ts | 5 ++++- src/filters/Blur.ts | 3 ++- src/filters/Brighten.ts | 3 ++- src/filters/Contrast.ts | 3 ++- src/filters/Emboss.ts | 3 ++- src/filters/Enhance.ts | 3 ++- src/filters/Grayscale.ts | 2 +- src/filters/HSL.ts | 3 ++- src/filters/HSV.ts | 3 ++- src/filters/Invert.ts | 2 +- src/filters/Kaleidoscope.ts | 3 ++- src/filters/Mask.ts | 3 ++- src/filters/Noise.ts | 3 ++- src/filters/Pixelate.ts | 3 ++- src/filters/Posterize.ts | 3 ++- src/filters/RGB.ts | 3 ++- src/filters/RGBA.ts | 3 ++- src/filters/Sepia.ts | 2 +- src/filters/Solarize.ts | 2 +- src/filters/Threshold.ts | 3 ++- src/shapes/Arc.ts | 7 ++++--- src/shapes/Arrow.ts | 7 ++++--- src/shapes/Circle.ts | 7 ++++--- src/shapes/Ellipse.ts | 7 ++++--- src/shapes/Image.ts | 7 ++++--- src/shapes/Label.ts | 11 ++++++----- src/shapes/Line.ts | 7 ++++--- src/shapes/Path.ts | 5 +++-- src/shapes/Rect.ts | 7 ++++--- src/shapes/RegularPolygon.ts | 7 ++++--- src/shapes/Ring.ts | 7 ++++--- src/shapes/Sprite.ts | 7 ++++--- src/shapes/Star.ts | 7 ++++--- src/shapes/Text.ts | 7 ++++--- src/shapes/TextPath.ts | 7 ++++--- src/shapes/Transformer.ts | 4 ++-- src/shapes/Wedge.ts | 7 ++++--- test/unit/Blob-test.ts | 2 +- test/unit/Container-test.ts | 2 +- test/unit/Node-test.ts | 2 +- test/unit/Transformer-test.ts | 2 +- test/unit/test-utils.ts | 4 ++-- tsconfig.json | 3 +-- 58 files changed, 173 insertions(+), 128 deletions(-) diff --git a/src/Animation.ts b/src/Animation.ts index 23a1494f..e1dff7f9 100644 --- a/src/Animation.ts +++ b/src/Animation.ts @@ -1,6 +1,6 @@ import { glob } from './Global.ts'; -import { Layer } from './Layer.ts'; -import { IFrame, AnimationFn } from './types.ts'; +import type { Layer } from './Layer.ts'; +import type { IFrame, AnimationFn } from './types.ts'; import { Util } from './Util.ts'; const now = (function (): () => number { diff --git a/src/Canvas.ts b/src/Canvas.ts index 56a05270..fa2db24c 100644 --- a/src/Canvas.ts +++ b/src/Canvas.ts @@ -1,5 +1,6 @@ import { Util } from './Util.ts'; -import { SceneContext, HitContext, Context } from './Context.ts'; +import type { Context } from './Context.ts'; +import { SceneContext, HitContext } from './Context.ts'; import { Konva } from './Global.ts'; // calculate pixel ratio diff --git a/src/Container.ts b/src/Container.ts index 3b95bcb8..83d42e8b 100644 --- a/src/Container.ts +++ b/src/Container.ts @@ -1,9 +1,10 @@ -import { HitCanvas, SceneCanvas } from './Canvas.ts'; -import { SceneContext } from './Context.ts'; +import type { HitCanvas, SceneCanvas } from './Canvas.ts'; +import type { SceneContext } from './Context.ts'; import { Factory } from './Factory.ts'; -import { Node, NodeConfig } from './Node.ts'; -import { Shape } from './Shape.ts'; -import { GetSet, IRect } from './types.ts'; +import type { NodeConfig } from './Node.ts'; +import { Node } from './Node.ts'; +import type { Shape } from './Shape.ts'; +import type { GetSet, IRect } from './types.ts'; import { getNumberValidator } from './Validators.ts'; export type ClipFuncOutput = diff --git a/src/Context.ts b/src/Context.ts index 4141c5b4..43c51b05 100644 --- a/src/Context.ts +++ b/src/Context.ts @@ -1,8 +1,8 @@ import { Util } from './Util.ts'; import { Konva } from './Global.ts'; -import { Canvas } from './Canvas.ts'; -import { Shape } from './Shape.ts'; -import { IRect } from './types.ts'; +import type { Canvas } from './Canvas.ts'; +import type { Shape } from './Shape.ts'; +import type { IRect } from './types.ts'; import type { Node } from './Node.ts'; function simplifyArray(arr: Array) { diff --git a/src/DragAndDrop.ts b/src/DragAndDrop.ts index 42e709f8..3eeb9a12 100644 --- a/src/DragAndDrop.ts +++ b/src/DragAndDrop.ts @@ -1,7 +1,7 @@ -import { Container } from './Container.ts'; +import type { Container } from './Container.ts'; import { Konva } from './Global.ts'; -import { Node } from './Node.ts'; -import { Vector2d } from './types.ts'; +import type { Node } from './Node.ts'; +import type { Vector2d } from './types.ts'; import { Util } from './Util.ts'; export const DD = { diff --git a/src/Factory.ts b/src/Factory.ts index cbab6e63..334b688f 100644 --- a/src/Factory.ts +++ b/src/Factory.ts @@ -1,5 +1,5 @@ -import { Node } from './Node.ts'; -import { GetSet } from './types.ts'; +import type { Node } from './Node.ts'; +import type { GetSet } from './types.ts'; import { Util } from './Util.ts'; import { getComponentValidator } from './Validators.ts'; diff --git a/src/Group.ts b/src/Group.ts index b751c678..f4f26131 100644 --- a/src/Group.ts +++ b/src/Group.ts @@ -1,8 +1,9 @@ import { Util } from './Util.ts'; -import { Container, ContainerConfig } from './Container.ts'; +import type { ContainerConfig } from './Container.ts'; +import { Container } from './Container.ts'; import { _registerNode } from './Global.ts'; -import { Node } from './Node.ts'; -import { Shape } from './Shape.ts'; +import type { Node } from './Node.ts'; +import type { Shape } from './Shape.ts'; export interface GroupConfig extends ContainerConfig {} diff --git a/src/Layer.ts b/src/Layer.ts index b99be812..d56ddd4e 100644 --- a/src/Layer.ts +++ b/src/Layer.ts @@ -1,14 +1,16 @@ import { Util } from './Util.ts'; -import { Container, ContainerConfig } from './Container.ts'; +import type { ContainerConfig } from './Container.ts'; +import { Container } from './Container.ts'; import { Node } from './Node.ts'; import { Factory } from './Factory.ts'; import { SceneCanvas, HitCanvas } from './Canvas.ts'; -import { Stage } from './Stage.ts'; +import type { Stage } from './Stage.ts'; import { getBooleanValidator } from './Validators.ts'; -import { GetSet, Vector2d } from './types.ts'; -import { Group } from './Group.ts'; -import { Shape, shapes } from './Shape.ts'; +import type { GetSet, Vector2d } from './types.ts'; +import type { Group } from './Group.ts'; +import type { Shape } from './Shape.ts'; +import { shapes } from './Shape.ts'; import { _registerNode } from './Global.ts'; export interface LayerConfig extends ContainerConfig { diff --git a/src/Node.ts b/src/Node.ts index 2a4a01d0..b1aeb125 100644 --- a/src/Node.ts +++ b/src/Node.ts @@ -1,13 +1,14 @@ -import { Canvas, HitCanvas, SceneCanvas } from './Canvas.ts'; -import { Container } from './Container.ts'; -import { Context } from './Context.ts'; +import type { Canvas } from './Canvas.ts'; +import { HitCanvas, SceneCanvas } from './Canvas.ts'; +import type { Container } from './Container.ts'; +import type { Context } from './Context.ts'; import { DD } from './DragAndDrop.ts'; import { Factory } from './Factory.ts'; import { Konva } from './Global.ts'; -import { Layer } from './Layer.ts'; -import { Shape } from './Shape.ts'; -import { Stage } from './Stage.ts'; -import { GetSet, IRect, Vector2d } from './types.ts'; +import type { Layer } from './Layer.ts'; +import type { Shape } from './Shape.ts'; +import type { Stage } from './Stage.ts'; +import type { GetSet, IRect, Vector2d } from './types.ts'; import { Transform, Util } from './Util.ts'; import { getBooleanValidator, diff --git a/src/PointerEvents.ts b/src/PointerEvents.ts index bbc5ef87..140ccd5e 100644 --- a/src/PointerEvents.ts +++ b/src/PointerEvents.ts @@ -1,8 +1,8 @@ -import { KonvaEventObject } from './Node.ts'; +import type { KonvaEventObject } from './Node.ts'; import { Konva } from './Global.ts'; -import { Shape } from './Shape.ts'; -import { Stage } from './Stage.ts'; +import type { Shape } from './Shape.ts'; +import type { Stage } from './Stage.ts'; const Captures = new Map(); diff --git a/src/Shape.ts b/src/Shape.ts index d9e07a04..8be6cb00 100644 --- a/src/Shape.ts +++ b/src/Shape.ts @@ -1,7 +1,8 @@ import { Konva } from './Global.ts'; import { Transform, Util } from './Util.ts'; import { Factory } from './Factory.ts'; -import { Node, NodeConfig } from './Node.ts'; +import type { NodeConfig } from './Node.ts'; +import { Node } from './Node.ts'; import { getNumberValidator, getNumberOrAutoValidator, @@ -10,12 +11,12 @@ import { getStringOrGradientValidator, } from './Validators.ts'; -import { Context, SceneContext } from './Context.ts'; +import type { Context, SceneContext } from './Context.ts'; import { _registerNode } from './Global.ts'; import * as PointerEvents from './PointerEvents.ts'; -import { GetSet, Vector2d } from './types.ts'; -import { HitCanvas, SceneCanvas } from './Canvas.ts'; +import type { GetSet, Vector2d } from './types.ts'; +import type { HitCanvas, SceneCanvas } from './Canvas.ts'; // hack from here https://stackoverflow.com/questions/52667959/what-is-the-purpose-of-bivariancehack-in-typescript-types/52668133#52668133 export type ShapeConfigHandler = { diff --git a/src/Stage.ts b/src/Stage.ts index 33cb7ca0..b05aed7a 100644 --- a/src/Stage.ts +++ b/src/Stage.ts @@ -1,11 +1,12 @@ import { Util } from './Util.ts'; import { Factory } from './Factory.ts'; -import { Container, ContainerConfig } from './Container.ts'; +import type { ContainerConfig } from './Container.ts'; +import { Container } from './Container.ts'; import { Konva } from './Global.ts'; import { SceneCanvas, HitCanvas } from './Canvas.ts'; -import { GetSet, Vector2d } from './types.ts'; -import { Shape } from './Shape.ts'; -import { Layer } from './Layer.ts'; +import type { GetSet, Vector2d } from './types.ts'; +import type { Shape } from './Shape.ts'; +import type { Layer } from './Layer.ts'; import { DD } from './DragAndDrop.ts'; import { _registerNode } from './Global.ts'; import * as PointerEvents from './PointerEvents.ts'; diff --git a/src/Tween.ts b/src/Tween.ts index 912a8f7b..7c78011b 100644 --- a/src/Tween.ts +++ b/src/Tween.ts @@ -1,8 +1,9 @@ import { Util } from './Util.ts'; import { Animation } from './Animation.ts'; -import { Node, NodeConfig } from './Node.ts'; +import type { NodeConfig } from './Node.ts'; +import { Node } from './Node.ts'; import { Konva } from './Global.ts'; -import { Line } from './shapes/Line.ts'; +import type { Line } from './shapes/Line.ts'; const blacklist = { node: 1, diff --git a/src/Util.ts b/src/Util.ts index 1b9dffc2..372d3ad2 100644 --- a/src/Util.ts +++ b/src/Util.ts @@ -1,6 +1,6 @@ import { Konva } from './Global.ts'; -import { Context } from './Context.ts'; -import { IRect, RGB, Vector2d } from './types.ts'; +import type { Context } from './Context.ts'; +import type { IRect, RGB, Vector2d } from './types.ts'; const NODE_ERROR = `Konva.js unsupported environment. diff --git a/src/_CoreInternals.ts b/src/_CoreInternals.ts index de8356bf..412e7866 100644 --- a/src/_CoreInternals.ts +++ b/src/_CoreInternals.ts @@ -46,11 +46,14 @@ export namespace Konva { export type Vector2d = import('./types.ts').Vector2d; export type Node = import('./Node.ts').Node; export type NodeConfig = import('./Node.ts').NodeConfig; - export type KonvaEventObject = import('./Node.ts').KonvaEventObject; + export type KonvaEventObject = + import('./Node.ts').KonvaEventObject; - export type KonvaPointerEvent = import('./PointerEvents.ts').KonvaPointerEvent; + export type KonvaPointerEvent = + import('./PointerEvents.ts').KonvaPointerEvent; - export type KonvaEventListener = import('./Node.ts').KonvaEventListener; + export type KonvaEventListener = + import('./Node.ts').KonvaEventListener; export type Container = import('./Container.ts').Container; export type ContainerConfig = import('./Container.ts').ContainerConfig; diff --git a/src/_FullInternals.ts b/src/_FullInternals.ts index 2094082a..e1790ff6 100644 --- a/src/_FullInternals.ts +++ b/src/_FullInternals.ts @@ -96,7 +96,10 @@ export namespace Konva { export type KonvaPointerEvent = Core.KonvaPointerEvent; - export type KonvaEventListener = Core.KonvaEventListener; + export type KonvaEventListener = Core.KonvaEventListener< + This, + EventType + >; export type Container = Core.Container; export type ContainerConfig = Core.ContainerConfig; diff --git a/src/filters/Blur.ts b/src/filters/Blur.ts index 0245511d..9d15850a 100644 --- a/src/filters/Blur.ts +++ b/src/filters/Blur.ts @@ -1,5 +1,6 @@ import { Factory } from '../Factory.ts'; -import { Node, Filter } from '../Node.ts'; +import type { Filter } from '../Node.ts'; +import { Node } from '../Node.ts'; import { getNumberValidator } from '../Validators.ts'; /* the Gauss filter diff --git a/src/filters/Brighten.ts b/src/filters/Brighten.ts index c790ce86..435f45e3 100644 --- a/src/filters/Brighten.ts +++ b/src/filters/Brighten.ts @@ -1,5 +1,6 @@ import { Factory } from '../Factory.ts'; -import { Node, Filter } from '../Node.ts'; +import type { Filter } from '../Node.ts'; +import { Node } from '../Node.ts'; import { getNumberValidator } from '../Validators.ts'; /** diff --git a/src/filters/Contrast.ts b/src/filters/Contrast.ts index 899bd382..ad0eb10f 100644 --- a/src/filters/Contrast.ts +++ b/src/filters/Contrast.ts @@ -1,5 +1,6 @@ import { Factory } from '../Factory.ts'; -import { Node, Filter } from '../Node.ts'; +import type { Filter } from '../Node.ts'; +import { Node } from '../Node.ts'; import { getNumberValidator } from '../Validators.ts'; /** * Contrast Filter. diff --git a/src/filters/Emboss.ts b/src/filters/Emboss.ts index 4bf4af8b..64ef32e2 100644 --- a/src/filters/Emboss.ts +++ b/src/filters/Emboss.ts @@ -1,5 +1,6 @@ import { Factory } from '../Factory.ts'; -import { Node, Filter } from '../Node.ts'; +import type { Filter } from '../Node.ts'; +import { Node } from '../Node.ts'; import { Util } from '../Util.ts'; import { getNumberValidator } from '../Validators.ts'; /** diff --git a/src/filters/Enhance.ts b/src/filters/Enhance.ts index 284c5b1d..af773f34 100644 --- a/src/filters/Enhance.ts +++ b/src/filters/Enhance.ts @@ -1,5 +1,6 @@ import { Factory } from '../Factory.ts'; -import { Node, Filter } from '../Node.ts'; +import type { Filter } from '../Node.ts'; +import { Node } from '../Node.ts'; import { getNumberValidator } from '../Validators.ts'; function remap( diff --git a/src/filters/Grayscale.ts b/src/filters/Grayscale.ts index a478c7e9..030ef84d 100644 --- a/src/filters/Grayscale.ts +++ b/src/filters/Grayscale.ts @@ -1,4 +1,4 @@ -import { Filter } from '../Node.ts'; +import type { Filter } from '../Node.ts'; /** * Grayscale Filter diff --git a/src/filters/HSL.ts b/src/filters/HSL.ts index b3f153f2..b651a496 100644 --- a/src/filters/HSL.ts +++ b/src/filters/HSL.ts @@ -1,5 +1,6 @@ import { Factory } from '../Factory.ts'; -import { Node, Filter } from '../Node.ts'; +import type { Filter } from '../Node.ts'; +import { Node } from '../Node.ts'; import { getNumberValidator } from '../Validators.ts'; Factory.addGetterSetter( diff --git a/src/filters/HSV.ts b/src/filters/HSV.ts index 2557fa90..42174862 100644 --- a/src/filters/HSV.ts +++ b/src/filters/HSV.ts @@ -1,5 +1,6 @@ import { Factory } from '../Factory.ts'; -import { Filter, Node } from '../Node.ts'; +import type { Filter } from '../Node.ts'; +import { Node } from '../Node.ts'; import { getNumberValidator } from '../Validators.ts'; /** diff --git a/src/filters/Invert.ts b/src/filters/Invert.ts index 5d3f5d30..a02c1c1d 100644 --- a/src/filters/Invert.ts +++ b/src/filters/Invert.ts @@ -1,4 +1,4 @@ -import { Filter } from '../Node.ts'; +import type { Filter } from '../Node.ts'; /** * Invert Filter * @function diff --git a/src/filters/Kaleidoscope.ts b/src/filters/Kaleidoscope.ts index 88e6e23b..330d6827 100644 --- a/src/filters/Kaleidoscope.ts +++ b/src/filters/Kaleidoscope.ts @@ -1,5 +1,6 @@ import { Factory } from '../Factory.ts'; -import { Filter, Node } from '../Node.ts'; +import type { Filter } from '../Node.ts'; +import { Node } from '../Node.ts'; import { Util } from '../Util.ts'; import { getNumberValidator } from '../Validators.ts'; diff --git a/src/filters/Mask.ts b/src/filters/Mask.ts index c5e76938..7fdf3146 100644 --- a/src/filters/Mask.ts +++ b/src/filters/Mask.ts @@ -1,5 +1,6 @@ import { Factory } from '../Factory.ts'; -import { Filter, Node } from '../Node.ts'; +import type { Filter } from '../Node.ts'; +import { Node } from '../Node.ts'; import { getNumberValidator } from '../Validators.ts'; function pixelAt(idata, x: number, y: number) { diff --git a/src/filters/Noise.ts b/src/filters/Noise.ts index 9bf7655d..70fd752c 100644 --- a/src/filters/Noise.ts +++ b/src/filters/Noise.ts @@ -1,5 +1,6 @@ import { Factory } from '../Factory.ts'; -import { Filter, Node } from '../Node.ts'; +import type { Filter } from '../Node.ts'; +import { Node } from '../Node.ts'; import { getNumberValidator } from '../Validators.ts'; /** diff --git a/src/filters/Pixelate.ts b/src/filters/Pixelate.ts index 8f76c752..0348cb7a 100644 --- a/src/filters/Pixelate.ts +++ b/src/filters/Pixelate.ts @@ -1,6 +1,7 @@ import { Factory } from '../Factory.ts'; import { Util } from '../Util.ts'; -import { Node, Filter } from '../Node.ts'; +import type { Filter } from '../Node.ts'; +import { Node } from '../Node.ts'; import { getNumberValidator } from '../Validators.ts'; /** diff --git a/src/filters/Posterize.ts b/src/filters/Posterize.ts index 33f82e4e..0b7050e7 100644 --- a/src/filters/Posterize.ts +++ b/src/filters/Posterize.ts @@ -1,5 +1,6 @@ import { Factory } from '../Factory.ts'; -import { Filter, Node } from '../Node.ts'; +import type { Filter } from '../Node.ts'; +import { Node } from '../Node.ts'; import { getNumberValidator } from '../Validators.ts'; /** diff --git a/src/filters/RGB.ts b/src/filters/RGB.ts index 1b1c0d7a..abf84414 100644 --- a/src/filters/RGB.ts +++ b/src/filters/RGB.ts @@ -1,5 +1,6 @@ import { Factory } from '../Factory.ts'; -import { Node, Filter } from '../Node.ts'; +import type { Filter } from '../Node.ts'; +import { Node } from '../Node.ts'; import { RGBComponent } from '../Validators.ts'; /** diff --git a/src/filters/RGBA.ts b/src/filters/RGBA.ts index ddca47b2..44ae8077 100644 --- a/src/filters/RGBA.ts +++ b/src/filters/RGBA.ts @@ -1,5 +1,6 @@ import { Factory } from '../Factory.ts'; -import { Node, Filter } from '../Node.ts'; +import type { Filter } from '../Node.ts'; +import { Node } from '../Node.ts'; import { RGBComponent } from '../Validators.ts'; /** diff --git a/src/filters/Sepia.ts b/src/filters/Sepia.ts index d44ebc8d..b06473fc 100644 --- a/src/filters/Sepia.ts +++ b/src/filters/Sepia.ts @@ -1,4 +1,4 @@ -import { Filter } from '../Node.ts'; +import type { Filter } from '../Node.ts'; // based on https://stackoverflow.com/questions/1061093/how-is-a-sepia-tone-created diff --git a/src/filters/Solarize.ts b/src/filters/Solarize.ts index 274c5592..ad15cf77 100644 --- a/src/filters/Solarize.ts +++ b/src/filters/Solarize.ts @@ -1,4 +1,4 @@ -import { Filter } from '../Node.ts'; +import type { Filter } from '../Node.ts'; /** * Solarize Filter * Pixastic Lib - Solarize filter - v0.1.0 diff --git a/src/filters/Threshold.ts b/src/filters/Threshold.ts index ad317f87..5ac6400e 100644 --- a/src/filters/Threshold.ts +++ b/src/filters/Threshold.ts @@ -1,5 +1,6 @@ import { Factory } from '../Factory.ts'; -import { Node, Filter } from '../Node.ts'; +import type { Filter } from '../Node.ts'; +import { Node } from '../Node.ts'; import { getNumberValidator } from '../Validators.ts'; /** * Threshold Filter. Pushes any value above the mid point to diff --git a/src/shapes/Arc.ts b/src/shapes/Arc.ts index b185b75f..aa384ae2 100644 --- a/src/shapes/Arc.ts +++ b/src/shapes/Arc.ts @@ -1,10 +1,11 @@ import { Factory } from '../Factory.ts'; -import { Shape, ShapeConfig } from '../Shape.ts'; +import type { ShapeConfig } from '../Shape.ts'; +import { Shape } from '../Shape.ts'; import { Konva } from '../Global.ts'; -import { GetSet } from '../types.ts'; +import type { GetSet } from '../types.ts'; import { getNumberValidator, getBooleanValidator } from '../Validators.ts'; import { _registerNode } from '../Global.ts'; -import { Context } from '../Context.ts'; +import type { Context } from '../Context.ts'; export interface ArcConfig extends ShapeConfig { angle: number; diff --git a/src/shapes/Arrow.ts b/src/shapes/Arrow.ts index d1316f06..ef7674dc 100644 --- a/src/shapes/Arrow.ts +++ b/src/shapes/Arrow.ts @@ -1,10 +1,11 @@ import { Factory } from '../Factory.ts'; -import { Line, LineConfig } from './Line.ts'; -import { GetSet } from '../types.ts'; +import type { LineConfig } from './Line.ts'; +import { Line } from './Line.ts'; +import type { GetSet } from '../types.ts'; import { getNumberValidator } from '../Validators.ts'; import { _registerNode } from '../Global.ts'; import { Path } from './Path.ts'; -import { Context } from '../Context.ts'; +import type { Context } from '../Context.ts'; export interface ArrowConfig extends LineConfig { points: number[]; diff --git a/src/shapes/Circle.ts b/src/shapes/Circle.ts index 924bf280..afbe459a 100644 --- a/src/shapes/Circle.ts +++ b/src/shapes/Circle.ts @@ -1,9 +1,10 @@ import { Factory } from '../Factory.ts'; -import { Shape, ShapeConfig } from '../Shape.ts'; -import { GetSet } from '../types.ts'; +import type { ShapeConfig } from '../Shape.ts'; +import { Shape } from '../Shape.ts'; +import type { GetSet } from '../types.ts'; import { getNumberValidator } from '../Validators.ts'; import { _registerNode } from '../Global.ts'; -import { Context } from '../Context.ts'; +import type { Context } from '../Context.ts'; export interface CircleConfig extends ShapeConfig { radius?: number; diff --git a/src/shapes/Ellipse.ts b/src/shapes/Ellipse.ts index 69380811..5f4e33e3 100644 --- a/src/shapes/Ellipse.ts +++ b/src/shapes/Ellipse.ts @@ -1,10 +1,11 @@ import { Factory } from '../Factory.ts'; -import { Shape, ShapeConfig } from '../Shape.ts'; +import type { ShapeConfig } from '../Shape.ts'; +import { Shape } from '../Shape.ts'; import { getNumberValidator } from '../Validators.ts'; import { _registerNode } from '../Global.ts'; -import { Context } from '../Context.ts'; +import type { Context } from '../Context.ts'; -import { GetSet, Vector2d } from '../types.ts'; +import type { GetSet, Vector2d } from '../types.ts'; export interface EllipseConfig extends ShapeConfig { radiusX: number; diff --git a/src/shapes/Image.ts b/src/shapes/Image.ts index 73be4ebb..667d3bf6 100644 --- a/src/shapes/Image.ts +++ b/src/shapes/Image.ts @@ -1,14 +1,15 @@ import { Util } from '../Util.ts'; import { Factory } from '../Factory.ts'; -import { Shape, ShapeConfig } from '../Shape.ts'; +import type { ShapeConfig } from '../Shape.ts'; +import { Shape } from '../Shape.ts'; import { _registerNode } from '../Global.ts'; import { getNumberOrArrayOfNumbersValidator, getNumberValidator, } from '../Validators.ts'; -import { GetSet, IRect } from '../types.ts'; -import { Context } from '../Context.ts'; +import type { GetSet, IRect } from '../types.ts'; +import type { Context } from '../Context.ts'; export interface ImageConfig extends ShapeConfig { image: CanvasImageSource | undefined; diff --git a/src/shapes/Label.ts b/src/shapes/Label.ts index 8b043b1a..a7f0e215 100644 --- a/src/shapes/Label.ts +++ b/src/shapes/Label.ts @@ -1,16 +1,17 @@ import { Factory } from '../Factory.ts'; -import { Shape, ShapeConfig } from '../Shape.ts'; +import type { ShapeConfig } from '../Shape.ts'; +import { Shape } from '../Shape.ts'; import { Group } from '../Group.ts'; -import { Context } from '../Context.ts'; -import { ContainerConfig } from '../Container.ts'; +import type { Context } from '../Context.ts'; +import type { ContainerConfig } from '../Container.ts'; import { getNumberOrArrayOfNumbersValidator, getNumberValidator, } from '../Validators.ts'; import { _registerNode } from '../Global.ts'; -import { GetSet } from '../types.ts'; -import { Text } from './Text.ts'; +import type { GetSet } from '../types.ts'; +import type { Text } from './Text.ts'; export interface LabelConfig extends ContainerConfig {} diff --git a/src/shapes/Line.ts b/src/shapes/Line.ts index b49f6df6..59416516 100644 --- a/src/shapes/Line.ts +++ b/src/shapes/Line.ts @@ -1,10 +1,11 @@ import { Factory } from '../Factory.ts'; import { _registerNode } from '../Global.ts'; -import { Shape, ShapeConfig } from '../Shape.ts'; +import type { ShapeConfig } from '../Shape.ts'; +import { Shape } from '../Shape.ts'; import { getNumberArrayValidator, getNumberValidator } from '../Validators.ts'; -import { Context } from '../Context.ts'; -import { GetSet } from '../types.ts'; +import type { Context } from '../Context.ts'; +import type { GetSet } from '../types.ts'; function getControlPoints( x0: number, diff --git a/src/shapes/Path.ts b/src/shapes/Path.ts index aa749ab3..a80b02de 100644 --- a/src/shapes/Path.ts +++ b/src/shapes/Path.ts @@ -1,13 +1,14 @@ import { Factory } from '../Factory.ts'; import { _registerNode } from '../Global.ts'; -import { Shape, ShapeConfig } from '../Shape.ts'; +import type { ShapeConfig } from '../Shape.ts'; +import { Shape } from '../Shape.ts'; import { getCubicArcLength, getQuadraticArcLength, t2length, } from '../BezierFunctions.ts'; -import { GetSet, PathSegment } from '../types.ts'; +import type { GetSet, PathSegment } from '../types.ts'; export interface PathConfig extends ShapeConfig { data?: string; diff --git a/src/shapes/Rect.ts b/src/shapes/Rect.ts index d0ef3143..581f98c9 100644 --- a/src/shapes/Rect.ts +++ b/src/shapes/Rect.ts @@ -1,10 +1,11 @@ import { Factory } from '../Factory.ts'; -import { Shape, ShapeConfig } from '../Shape.ts'; +import type { ShapeConfig } from '../Shape.ts'; +import { Shape } from '../Shape.ts'; import { _registerNode } from '../Global.ts'; import { Util } from '../Util.ts'; -import { GetSet } from '../types.ts'; -import { Context } from '../Context.ts'; +import type { GetSet } from '../types.ts'; +import type { Context } from '../Context.ts'; import { getNumberOrArrayOfNumbersValidator } from '../Validators.ts'; export interface RectConfig extends ShapeConfig { diff --git a/src/shapes/RegularPolygon.ts b/src/shapes/RegularPolygon.ts index 7bf9a888..9bd79d17 100644 --- a/src/shapes/RegularPolygon.ts +++ b/src/shapes/RegularPolygon.ts @@ -1,12 +1,13 @@ import { Factory } from '../Factory.ts'; -import { Shape, ShapeConfig } from '../Shape.ts'; -import { GetSet, Vector2d } from '../types.ts'; +import type { ShapeConfig } from '../Shape.ts'; +import { Shape } from '../Shape.ts'; +import type { GetSet, Vector2d } from '../types.ts'; import { getNumberOrArrayOfNumbersValidator, getNumberValidator, } from '../Validators.ts'; import { _registerNode } from '../Global.ts'; -import { Context } from '../Context.ts'; +import type { Context } from '../Context.ts'; import { Util } from '../Util.ts'; export interface RegularPolygonConfig extends ShapeConfig { diff --git a/src/shapes/Ring.ts b/src/shapes/Ring.ts index 567f81c0..508d992d 100644 --- a/src/shapes/Ring.ts +++ b/src/shapes/Ring.ts @@ -1,9 +1,10 @@ import { Factory } from '../Factory.ts'; -import { Shape, ShapeConfig } from '../Shape.ts'; -import { GetSet } from '../types.ts'; +import type { ShapeConfig } from '../Shape.ts'; +import { Shape } from '../Shape.ts'; +import type { GetSet } from '../types.ts'; import { getNumberValidator } from '../Validators.ts'; import { _registerNode } from '../Global.ts'; -import { Context } from '../Context.ts'; +import type { Context } from '../Context.ts'; export interface RingConfig extends ShapeConfig { innerRadius: number; diff --git a/src/shapes/Sprite.ts b/src/shapes/Sprite.ts index 8265a561..005c1999 100644 --- a/src/shapes/Sprite.ts +++ b/src/shapes/Sprite.ts @@ -1,11 +1,12 @@ import { Factory } from '../Factory.ts'; -import { Context } from '../Context.ts'; -import { Shape, ShapeConfig } from '../Shape.ts'; +import type { Context } from '../Context.ts'; +import type { ShapeConfig } from '../Shape.ts'; +import { Shape } from '../Shape.ts'; import { Animation } from '../Animation.ts'; import { getNumberValidator } from '../Validators.ts'; import { _registerNode } from '../Global.ts'; -import { GetSet } from '../types.ts'; +import type { GetSet } from '../types.ts'; export interface SpriteConfig extends ShapeConfig { animation: string; diff --git a/src/shapes/Star.ts b/src/shapes/Star.ts index b0319604..4c401e46 100644 --- a/src/shapes/Star.ts +++ b/src/shapes/Star.ts @@ -1,10 +1,11 @@ import { Factory } from '../Factory.ts'; -import { Context } from '../Context.ts'; -import { Shape, ShapeConfig } from '../Shape.ts'; +import type { Context } from '../Context.ts'; +import type { ShapeConfig } from '../Shape.ts'; +import { Shape } from '../Shape.ts'; import { getNumberValidator } from '../Validators.ts'; import { _registerNode } from '../Global.ts'; -import { GetSet } from '../types.ts'; +import type { GetSet } from '../types.ts'; export interface StarConfig extends ShapeConfig { numPoints: number; diff --git a/src/shapes/Text.ts b/src/shapes/Text.ts index ab8f5949..9c641313 100644 --- a/src/shapes/Text.ts +++ b/src/shapes/Text.ts @@ -1,7 +1,8 @@ import { Util } from '../Util.ts'; -import { Context } from '../Context.ts'; +import type { Context } from '../Context.ts'; import { Factory } from '../Factory.ts'; -import { Shape, ShapeConfig } from '../Shape.ts'; +import type { ShapeConfig } from '../Shape.ts'; +import { Shape } from '../Shape.ts'; import { Konva } from '../Global.ts'; import { getNumberValidator, @@ -11,7 +12,7 @@ import { } from '../Validators.ts'; import { _registerNode } from '../Global.ts'; -import { GetSet } from '../types.ts'; +import type { GetSet } from '../types.ts'; export interface CharRenderProps { char: string; diff --git a/src/shapes/TextPath.ts b/src/shapes/TextPath.ts index 39b65b27..fac51002 100644 --- a/src/shapes/TextPath.ts +++ b/src/shapes/TextPath.ts @@ -1,13 +1,14 @@ import { Util } from '../Util.ts'; import { Factory } from '../Factory.ts'; -import { Context } from '../Context.ts'; -import { Shape, ShapeConfig } from '../Shape.ts'; +import type { Context } from '../Context.ts'; +import type { ShapeConfig } from '../Shape.ts'; +import { Shape } from '../Shape.ts'; import { Path } from './Path.ts'; import { Text, stringToArray } from './Text.ts'; import { getNumberValidator } from '../Validators.ts'; import { _registerNode } from '../Global.ts'; -import { GetSet, PathSegment, Vector2d } from '../types.ts'; +import type { GetSet, PathSegment, Vector2d } from '../types.ts'; export interface TextPathConfig extends ShapeConfig { text?: string; diff --git a/src/shapes/Transformer.ts b/src/shapes/Transformer.ts index be99aeaf..6146fec9 100644 --- a/src/shapes/Transformer.ts +++ b/src/shapes/Transformer.ts @@ -4,12 +4,12 @@ import { Node } from '../Node.ts'; import { Shape } from '../Shape.ts'; import { Rect } from './Rect.ts'; import { Group } from '../Group.ts'; -import { ContainerConfig } from '../Container.ts'; +import type { ContainerConfig } from '../Container.ts'; import { Konva } from '../Global.ts'; import { getBooleanValidator, getNumberValidator } from '../Validators.ts'; import { _registerNode } from '../Global.ts'; -import { GetSet, IRect, Vector2d } from '../types.ts'; +import type { GetSet, IRect, Vector2d } from '../types.ts'; export interface Box extends IRect { rotation: number; diff --git a/src/shapes/Wedge.ts b/src/shapes/Wedge.ts index fee22d90..0cff7756 100644 --- a/src/shapes/Wedge.ts +++ b/src/shapes/Wedge.ts @@ -1,11 +1,12 @@ import { Factory } from '../Factory.ts'; -import { Context } from '../Context.ts'; -import { Shape, ShapeConfig } from '../Shape.ts'; +import type { Context } from '../Context.ts'; +import type { ShapeConfig } from '../Shape.ts'; +import { Shape } from '../Shape.ts'; import { Konva } from '../Global.ts'; import { getNumberValidator } from '../Validators.ts'; import { _registerNode } from '../Global.ts'; -import { GetSet } from '../types.ts'; +import type { GetSet } from '../types.ts'; export interface WedgeConfig extends ShapeConfig { angle: number; diff --git a/test/unit/Blob-test.ts b/test/unit/Blob-test.ts index 209d130c..f018f96a 100644 --- a/test/unit/Blob-test.ts +++ b/test/unit/Blob-test.ts @@ -1,5 +1,5 @@ import { assert } from 'chai'; -import { Line } from '../../src/shapes/Line.ts'; +import type { Line } from '../../src/shapes/Line.ts'; import { addStage, Konva, cloneAndCompareLayer } from './test-utils.ts'; diff --git a/test/unit/Container-test.ts b/test/unit/Container-test.ts index 399e882a..b96ccf72 100644 --- a/test/unit/Container-test.ts +++ b/test/unit/Container-test.ts @@ -1,5 +1,5 @@ import { assert } from 'chai'; -import { Shape } from '../../src/Shape.js'; +import type { Shape } from '../../src/Shape.js'; import { addStage, Konva, compareLayers, isNode } from './test-utils.ts'; describe('Container', function () { diff --git a/test/unit/Node-test.ts b/test/unit/Node-test.ts index a45fea4e..ad746c20 100644 --- a/test/unit/Node-test.ts +++ b/test/unit/Node-test.ts @@ -1,5 +1,5 @@ import { assert } from 'chai'; -import { Shape } from '../../src/Shape.ts'; +import type { Shape } from '../../src/Shape.ts'; import { addStage, diff --git a/test/unit/Transformer-test.ts b/test/unit/Transformer-test.ts index c7b06b67..f1972000 100644 --- a/test/unit/Transformer-test.ts +++ b/test/unit/Transformer-test.ts @@ -1,5 +1,5 @@ import { assert } from 'chai'; -import { Transformer } from '../../src/shapes/Transformer.ts'; +import type { Transformer } from '../../src/shapes/Transformer.ts'; import type { Rect } from '../../src/shapes/Rect.ts'; import type { Shape } from '../../src/Shape.ts'; diff --git a/test/unit/test-utils.ts b/test/unit/test-utils.ts index cb4b991d..730bf13d 100644 --- a/test/unit/test-utils.ts +++ b/test/unit/test-utils.ts @@ -9,8 +9,8 @@ Konva.enableTrace = true; Konva.showWarnings = true; import { imagediff } from './imagediff.ts'; -import { Layer } from '../../src/Layer.ts'; -import { Stage } from '../../src/Stage.ts'; +import type { Layer } from '../../src/Layer.ts'; +import type { Stage } from '../../src/Stage.ts'; // reset some data beforeEach(function () { diff --git a/tsconfig.json b/tsconfig.json index 99e36024..38412e07 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,8 +8,7 @@ "rewriteRelativeImportExtensions": true, "isolatedModules": true, "erasableSyntaxOnly": true, - // ideally we want to enable erasableSyntaxOnly & verbatimModuleSyntax for true node interop - "verbatimModuleSyntax": false, + "verbatimModuleSyntax": true, // "sourceMap": true, "noEmitOnError": true, "declaration": true,