Skip to content

Commit

Permalink
Converted inferno-hydrate to TSX #1632
Browse files Browse the repository at this point in the history
  • Loading branch information
Havunen committed Apr 13, 2024
1 parent 7ddfedc commit cbbf12a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, createRef, forwardRef, render } from 'inferno';
import { Component, createRef, forwardRef, RefObject, render } from 'inferno';
import { hydrate } from 'inferno-hydrate';

describe('Hydrate - Forward Ref', () => {
Expand All @@ -25,6 +25,8 @@ describe('Hydrate - Forward Ref', () => {
expect(FancyButton.render).toBeDefined();

class Hello extends Component {
private readonly btn: RefObject<Element>;

constructor(props) {
super(props);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
createFragment,
createPortal,
createRef,
Fragment,
Fragment, InfernoNode,
render,
rerender,
} from 'inferno';
Expand Down Expand Up @@ -32,8 +32,8 @@ describe('rendering routine', () => {
// create matching DOM
container.innerHTML = '<input type="checkbox"/>';

let clickChecked = null;
let changeChecked = null;
let clickChecked: boolean | null = null;
let changeChecked: boolean | null = null;

// Hydrate manually, instead rendering
hydrate(
Expand Down Expand Up @@ -63,8 +63,8 @@ describe('rendering routine', () => {
const spy = jasmine.createSpy('spy');
container.innerHTML = '<div><input type="checkbox"/></div>';

let clickChecked = null;
let changeChecked = null;
let clickChecked: boolean | null = null;
let changeChecked: boolean | null = null;

// Hydrate manually, instead rendering
hydrate(
Expand Down Expand Up @@ -133,7 +133,7 @@ describe('rendering routine', () => {
// create matching DOM
container.innerHTML = '<div>Okay<span>foobar</span></div>';

const newRef = createRef();
const newRef = createRef<HTMLSpanElement>();

hydrate(
<div>
Expand All @@ -151,7 +151,7 @@ describe('rendering routine', () => {
// create matching DOM
container.innerHTML = '<div>Okay<span>foobar</span></div>';

let instance = null;
let instance: Foobar | null = null;

class Foobar extends Component {
constructor(props, context) {
Expand All @@ -171,7 +171,7 @@ describe('rendering routine', () => {
}
}

const newRef = createRef();
const newRef = createRef<Foobar>();

hydrate(
<div>
Expand Down Expand Up @@ -603,7 +603,13 @@ describe('rendering routine', () => {
});

it('Should be possible to hydrate fragments JSX way', () => {
function Fragmenter({ first, mid, last, changeOrder }) {
interface FragmenterProps {
first: string;
mid: string;
last: string;
changeOrder?: boolean;
}
function Fragmenter({ first, mid, last, changeOrder }: FragmenterProps) {
if (changeOrder) {
return (
<>
Expand Down Expand Up @@ -645,7 +651,7 @@ describe('rendering routine', () => {
let mountCounter = 0;
let unmountCounter = 0;

class FoobarCom extends Component {
class FoobarCom extends Component<{node: HTMLDivElement}> {
componentWillMount() {
mountCounter++;
}
Expand Down Expand Up @@ -1101,7 +1107,7 @@ describe('rendering routine', () => {
return <div>Ok</div>;
}

let content = [];
let content: InfernoNode[] = [];

hydrate(
<Fragment>
Expand Down Expand Up @@ -1189,7 +1195,7 @@ describe('rendering routine', () => {
}
}

let nodes = [];
let nodes : InfernoNode[] = [];

hydrate(<>{nodes}</>, container);

Expand Down Expand Up @@ -1383,7 +1389,7 @@ describe('rendering routine', () => {

render() {
return createElement('rect', {
className: this.state.className,
className: this.state!.className,
});
}
}
Expand Down

0 comments on commit cbbf12a

Please sign in to comment.