mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 11:41:44 +00:00
Add react-dom/node-stream (#18493)
This commit is contained in:
committed by
Sheetal Nandi
parent
1f6ae7189d
commit
692b49b070
+20
@@ -0,0 +1,20 @@
|
||||
/// <reference types="node" />
|
||||
import { ReactElement } from 'react';
|
||||
import * as stream from 'stream';
|
||||
|
||||
/**
|
||||
* Render a ReactElement to its initial HTML. This should only be used on the
|
||||
* server.
|
||||
* See https://facebook.github.io/react/docs/react-dom-stream.html#rendertostream
|
||||
*/
|
||||
export function renderToStream(element: ReactElement<any>): stream.Readable;
|
||||
|
||||
/**
|
||||
* Similar to renderToStream, except this doesn't create extra DOM attributes
|
||||
* such as data-react-id that React uses internally.
|
||||
* See https://facebook.github.io/react/docs/react-dom-stream.html#rendertostaticstream
|
||||
*/
|
||||
export function renderToStaticStream(element: ReactElement<any>): stream.Readable;
|
||||
export const version: string;
|
||||
|
||||
export as namespace ReactDOMNodeStream;
|
||||
@@ -1,7 +1,9 @@
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as ReactDOMServer from 'react-dom/server';
|
||||
import * as ReactDOMNodeStream from 'react-dom/node-stream';
|
||||
import * as ReactTestUtils from 'react-dom/test-utils';
|
||||
import * as stream from 'stream';
|
||||
|
||||
declare function describe(desc: string, f: () => void): void;
|
||||
declare function it(desc: string, f: () => void): void;
|
||||
@@ -37,6 +39,16 @@ describe('ReactDOMServer', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('ReactDOMNodeStream', () => {
|
||||
it('renderToStream', () => {
|
||||
const content: stream.Readable = ReactDOMNodeStream.renderToStream(React.createElement('div'));
|
||||
});
|
||||
|
||||
it('renderToStaticStream', () => {
|
||||
const content: stream.Readable = ReactDOMNodeStream.renderToStaticStream(React.createElement('div'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('React dom test utils', () => {
|
||||
it('Simulate', () => {
|
||||
const element = document.createElement('div');
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"index.d.ts",
|
||||
"react-dom-tests.ts",
|
||||
"server/index.d.ts",
|
||||
"node-stream/index.d.ts",
|
||||
"test-utils/index.d.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
@@ -22,4 +23,4 @@
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user