Skip to content

Commit

Permalink
Added more type information and support for boolean expressions in Ty…
Browse files Browse the repository at this point in the history
…pescript JSX
  • Loading branch information
Havunen committed May 16, 2018
1 parent 61d4e09 commit b2c3908
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"devDependencies": {
"@types/history": "^4.6.2",
"@types/jest": "^22.2.3",
"@types/node": "^10.0.3",
"@types/node": "^10.1.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-jest": "^22.4.3",
Expand All @@ -89,7 +89,7 @@
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-undefined-to-void": "^6.9.2",
"babel-plugin-transform-undefined-to-void": "^6.9.4",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
Expand All @@ -113,7 +113,7 @@
"pre-commit": "^1.2.2",
"prettier": "^1.12.1",
"rimraf": "^2.6.2",
"rollup": "^0.58.2",
"rollup": "^0.59.1",
"rollup-plugin-alias": "^1.4.0",
"rollup-plugin-buble": "^0.19.2",
"rollup-plugin-commonjs": "^9.1.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/inferno-test-utils/src/jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function createSnapshotObject(object: object) {
return object;
}

export function vNodeToSnapshot(node: VNode) {
export function vNodeToSnapshot(node: VNode|Element) {
let object;
const children: any[] = [];
if (isDOMVNode(node)) {
Expand Down Expand Up @@ -52,7 +52,7 @@ export function vNodeToSnapshot(node: VNode) {
} else if (isString(node.children)) {
children.push(node.children);
} else if (isObject(node.children) && !isNull(node.children)) {
const asJSON = vNodeToSnapshot(node.children);
const asJSON = vNodeToSnapshot(node.children as any);
if (asJSON) {
children.push(asJSON);
}
Expand Down
10 changes: 5 additions & 5 deletions packages/inferno-test-utils/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ export function isVNode(instance: any): instance is VNode {
return Boolean(instance) && isObject(instance) && isNumber((instance as any).flags) && (instance as any).flags > 0;
}

export function isTextVNode(inst: VNode): boolean {
export function isTextVNode(inst: VNode): inst is VNode {
return inst.flags === VNodeFlags.Text;
}

export function isFunctionalVNode(instance: VNode): boolean {
export function isFunctionalVNode(instance: VNode): instance is VNode {
return isVNode(instance) && Boolean(instance.flags & VNodeFlags.ComponentFunction);
}

export function isClassVNode(instance: VNode): boolean {
export function isClassVNode(instance: VNode): instance is VNode {
return isVNode(instance) && Boolean(instance.flags & VNodeFlags.ComponentClass);
}

export function isComponentVNode(inst: VNode): boolean {
export function isComponentVNode(inst: VNode): inst is VNode {
return isFunctionalVNode(inst) || isClassVNode(inst);
}

export function getTagNameOfVNode(inst: any) {
return (inst && inst.dom && inst.dom.tagName.toLowerCase()) || (inst && inst.$V && inst.$V.dom && inst.$V.dom.tagName.toLowerCase()) || undefined;
}

export function isDOMVNode(inst: VNode): boolean {
export function isDOMVNode(inst: any): inst is VNode {
return !isComponentVNode(inst) && !isTextVNode(inst);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/inferno/src/core/implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface VNode<P = {}> {
}
export type InfernoInput = VNode | null | string | number;
export type Ref<T = Element> = { bivarianceHack(instance: T | null): any }['bivarianceHack'];
export type InfernoChildren = string | number | boolean | undefined | VNode | Array<string | number | VNode | null | undefined> | null;
export type InfernoChildren = Element | string | number | boolean | undefined | VNode | Array<Element | boolean | string | number | VNode | null | undefined> | null;

export interface Props<P, T = Element> extends Refs<P> {
children?: InfernoChildren;
Expand Down

0 comments on commit b2c3908

Please sign in to comment.