mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 04:14:52 +08:00
types fixes. close #945
This commit is contained in:
@@ -219,7 +219,7 @@ export abstract class Container<ChildType extends Node> extends Node<
|
||||
* return node.getType() === 'Shape'
|
||||
* })
|
||||
*/
|
||||
findOne<ChildNode extends Node = Node>(selector: string | Function): Node {
|
||||
findOne<ChildNode extends Node = Node>(selector: string | Function) {
|
||||
var result = this._generalFind<ChildNode>(selector, true);
|
||||
return result.length > 0 ? result[0] : undefined;
|
||||
}
|
||||
@@ -227,9 +227,9 @@ export abstract class Container<ChildType extends Node> extends Node<
|
||||
selector: string | Function,
|
||||
findOne: boolean
|
||||
) {
|
||||
var retArr: Array<Node> = [];
|
||||
var retArr: Array<ChildNode> = [];
|
||||
|
||||
this._descendants((node) => {
|
||||
this._descendants((node: ChildNode) => {
|
||||
const valid = node._isMatch(selector);
|
||||
if (valid) {
|
||||
retArr.push(node);
|
||||
@@ -240,7 +240,7 @@ export abstract class Container<ChildType extends Node> extends Node<
|
||||
return false;
|
||||
});
|
||||
|
||||
return Collection.toCollection(retArr);
|
||||
return Collection.toCollection<ChildNode>(retArr);
|
||||
}
|
||||
private _descendants(fn: (n: Node) => boolean) {
|
||||
let shouldStop = false;
|
||||
|
@@ -3,6 +3,7 @@ import { Container } from './Container';
|
||||
import { _registerNode } from './Global';
|
||||
import { Node } from './Node';
|
||||
import { Shape } from './Shape';
|
||||
import Konva from './index-types';
|
||||
|
||||
/**
|
||||
* Group constructor. Groups are used to contain shapes or other groups.
|
||||
|
Reference in New Issue
Block a user