-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Typescript definitions for 'create-emotion-server' and 'emotion-s…
…erver'
- Loading branch information
1 parent
d9a9e33
commit 45c8dff
Showing
10 changed files
with
126 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/// <reference types="node" /> | ||
// TypeScript Version: 2.3 | ||
|
||
import { Emotion } from 'create-emotion'; | ||
|
||
export interface EmotionServer { | ||
extractCritical(html: string): { html: string; ids: string[]; css: string; }; | ||
renderStylesToString(html: string): string; | ||
renderStylesToNodeStream(): NodeJS.ReadWriteStream; | ||
} | ||
|
||
export default function createEmotionServer(emotion: Emotion): EmotionServer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Emotion } from 'create-emotion'; | ||
|
||
import createEmotionServer from '../'; | ||
|
||
declare const emotion: Emotion; | ||
|
||
const emotionServer = createEmotionServer(emotion); | ||
|
||
const { html, css, ids } = emotionServer.extractCritical("<div></div>"); | ||
|
||
emotionServer.renderStylesToString("<div></div>"); | ||
|
||
declare const stream: NodeJS.ReadableStream; | ||
|
||
stream.pipe(emotionServer.renderStylesToNodeStream()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": "../", | ||
"forceConsistentCasingInFileNames": true, | ||
"jsx": "react", | ||
"lib": [ | ||
"es6" | ||
], | ||
"module": "commonjs", | ||
"noEmit": true, | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strict": true, | ||
"strictNullChecks": true, | ||
"strictFunctionTypes": true, | ||
"target": "es5", | ||
"typeRoots": [ | ||
"../" | ||
], | ||
"types": [] | ||
}, | ||
"include": [ | ||
"./*.ts", | ||
"./*.tsx" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "dtslint/dtslint.json", | ||
"rules": { | ||
"no-relative-import-in-test": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// TypeScript Version: 2.3 | ||
|
||
import { EmotionServer } from 'create-emotion-server'; | ||
|
||
export const renderStylesToString: EmotionServer["renderStylesToString"]; | ||
export const renderStylesToNodeStream: EmotionServer["renderStylesToNodeStream"]; | ||
export const extractCritical: EmotionServer["extractCritical"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
import { renderToNodeStream, renderToString } from 'react-dom/server'; | ||
import { extractCritical, renderStylesToNodeStream, renderStylesToString } from '../'; | ||
|
||
declare const element: React.ReactElement<any>; | ||
|
||
const { html, css, ids } = extractCritical(renderToString(element)); | ||
|
||
renderStylesToString(renderToString(element)); | ||
|
||
renderToNodeStream(element).pipe(renderStylesToNodeStream()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowSyntheticDefaultImports": true, | ||
"baseUrl": "../", | ||
"forceConsistentCasingInFileNames": true, | ||
"jsx": "react", | ||
"lib": [ | ||
"es6" | ||
], | ||
"module": "commonjs", | ||
"noEmit": true, | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strict": true, | ||
"strictNullChecks": true, | ||
"strictFunctionTypes": true, | ||
"target": "es5", | ||
"typeRoots": [ | ||
"../" | ||
], | ||
"types": [] | ||
}, | ||
"include": [ | ||
"./*.ts", | ||
"./*.tsx" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "dtslint/dtslint.json", | ||
"rules": { | ||
"no-relative-import-in-test": false | ||
} | ||
} |