-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Typescript definitions for 'create-emotion-server' and 'emotion-server' #692
Changes from 3 commits
45c8dff
44cffe5
d097f6c
55f31d0
64fd688
4fe0c25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; |
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()); |
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" | ||
] | ||
} |
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 | ||
} | ||
} |
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"]; |
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()); |
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" | ||
] | ||
} |
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 | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You miss the final linefeeding for this file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are many more tslint.json files without this line feed. Do you want me to add them to those as well? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should depend on
@types/react-dom
as dependencies, or, at least as peerDependencies, shouldn't it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only use is inside the tests so I don't think it should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mgroenhoff Oh, you're right. My miss.