fix some types. close #638

This commit is contained in:
Anton Lavrenov
2019-04-22 08:17:25 -05:00
parent b5944530c3
commit b37286aaa5
4 changed files with 10 additions and 10 deletions

View File

@@ -8,7 +8,7 @@
* Konva JavaScript Framework v3.2.5 * Konva JavaScript Framework v3.2.5
* http://konvajs.org/ * http://konvajs.org/
* Licensed under the MIT * Licensed under the MIT
* Date: Wed Apr 17 2019 * Date: Mon Apr 22 2019
* *
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS) * Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva) * Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)

2
konva.min.js vendored
View File

@@ -3,7 +3,7 @@
* Konva JavaScript Framework v3.2.5 * Konva JavaScript Framework v3.2.5
* http://konvajs.org/ * http://konvajs.org/
* Licensed under the MIT * Licensed under the MIT
* Date: Wed Apr 17 2019 * Date: Mon Apr 22 2019
* *
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS) * Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva) * Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)

View File

@@ -190,10 +190,10 @@ export abstract class Container<ChildType extends Node> extends Node<
* return node.getType() === 'Node' && node.getAbsoluteOpacity() < 1; * return node.getType() === 'Node' && node.getAbsoluteOpacity() < 1;
* }); * });
*/ */
find(selector) { find<ChildNode extends Node = Node>(selector): Collection<ChildNode> {
// protecting _generalFind to prevent user from accidentally adding // protecting _generalFind to prevent user from accidentally adding
// second argument and getting unexpected `findOne` result // second argument and getting unexpected `findOne` result
return this._generalFind(selector, false); return this._generalFind<ChildNode>(selector, false);
} }
get(selector) { get(selector) {
@@ -220,12 +220,12 @@ export abstract class Container<ChildType extends Node> extends Node<
* return node.getType() === 'Shape' * return node.getType() === 'Shape'
* }) * })
*/ */
findOne(selector) { findOne<ChildNode extends Node = Node>(selector): ChildNode {
var result = this._generalFind(selector, true); var result = this._generalFind<ChildNode>(selector, true);
return result.length > 0 ? result[0] : undefined; return result.length > 0 ? result[0] : undefined;
} }
_generalFind(selector, findOne) { _generalFind<ChildNode extends Node = Node>(selector, findOne) {
var retArr = []; var retArr: Array<ChildNode> = [];
this._descendants(node => { this._descendants(node => {
const valid = node._isMatch(selector); const valid = node._isMatch(selector);

View File

@@ -49,8 +49,8 @@ export class Collection<Child extends Node> {
* @memberof Konva.Collection * @memberof Konva.Collection
* @param {Array} arr * @param {Array} arr
*/ */
static toCollection(arr: Array<Node>) { static toCollection<ChildNode extends Node = Node>(arr: Array<ChildNode>) {
var collection = new Collection(), var collection = new Collection<ChildNode>(),
len = arr.length, len = arr.length,
n; n;