1- import { Util , Transform } from './Util' ;
2- import { Factory } from './Factory' ;
3- import { SceneCanvas , HitCanvas , Canvas } from './Canvas' ;
4- import { Konva } from './Global' ;
1+ import { Canvas , HitCanvas , SceneCanvas } from './Canvas' ;
52import { Container } from './Container' ;
6- import { GetSet , Vector2d , IRect } from './types ' ;
3+ import { Context } from './Context ' ;
74import { DD } from './DragAndDrop' ;
5+ import { Factory } from './Factory' ;
6+ import { Konva } from './Global' ;
7+ import { Layer } from './Layer' ;
8+ import { Shape } from './Shape' ;
9+ import { Stage } from './Stage' ;
10+ import { GetSet , IRect , Vector2d } from './types' ;
11+ import { Transform , Util } from './Util' ;
812import {
13+ getBooleanValidator ,
914 getNumberValidator ,
1015 getStringValidator ,
11- getBooleanValidator ,
1216} from './Validators' ;
13- import { Stage } from './Stage' ;
14- import { Context } from './Context' ;
15- import { Shape } from './Shape' ;
16- import { Layer } from './Layer' ;
1717
1818export type Filter = ( this : Node , imageData : ImageData ) => void ;
1919
@@ -738,7 +738,7 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
738738 this . eventListeners [ baseEvent ] = [ ] ;
739739 }
740740
741- this . eventListeners [ baseEvent ] . push ( { name , handler } ) ;
741+ this . eventListeners [ baseEvent ] . push ( { name, handler } ) ;
742742 }
743743
744744 return this ;
@@ -894,13 +894,13 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
894894 * @example
895895 * var x = node.getAttr('x');
896896 */
897- getAttr ( attr : string ) {
897+ getAttr < T > ( attr : string ) {
898898 const method = 'get' + Util . _capitalize ( attr ) ;
899899 if ( Util . _isFunction ( ( this as any ) [ method ] ) ) {
900900 return ( this as any ) [ method ] ( ) ;
901901 }
902902 // otherwise get directly
903- return this . attrs [ attr ] ;
903+ return this . attrs [ attr ] as T | undefined ;
904904 }
905905 /**
906906 * get ancestors
@@ -2284,7 +2284,7 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
22842284 * @example
22852285 * node.setAttr('x', 5);
22862286 */
2287- setAttr ( attr , val ) {
2287+ setAttr ( attr : string , val ) {
22882288 const func = this [ SET + Util . _capitalize ( attr ) ] ;
22892289
22902290 if ( Util . _isFunction ( func ) ) {
@@ -2301,7 +2301,7 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
23012301 drawNode ?. batchDraw ( ) ;
23022302 }
23032303 }
2304- _setAttr ( key , val ) {
2304+ _setAttr ( key : string , val ) {
23052305 const oldVal = this . attrs [ key ] ;
23062306 if ( oldVal === val && ! Util . isObject ( val ) ) {
23072307 return ;
0 commit comments