Skip to content

Commit 470f098

Browse files
Merge pull request #83 from 9renpoto/fix/types
Added type definition tests
2 parents f3fbba3 + 4dbd0eb commit 470f098

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"transpile": "echo 'export const ENABLE_PRETTY = false;'>env.js && microbundle src/index.js -f es,umd --target web --external preact",
1313
"transpile:jsx": "echo 'export const ENABLE_PRETTY = true;'>env.js && microbundle src/jsx.js -o dist/jsx.js --target web --external none && microbundle dist/jsx.js -o dist/jsx.js -f cjs",
1414
"copy-typescript-definition": "copyfiles -f src/index.d.ts dist",
15-
"test": "eslint src test && mocha --compilers js:babel-register test/**/*.js",
15+
"test": "eslint src test && tsc && mocha --compilers js:babel-register test/**/*.js",
1616
"prepublish": "npm run build",
1717
"release": "npm run build && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish"
1818
},
@@ -74,7 +74,8 @@
7474
"mocha": "^5.2.0",
7575
"preact": "^10.0.0-alpha.0",
7676
"sinon": "^1.17.5",
77-
"sinon-chai": "^2.8.0"
77+
"sinon-chai": "^2.8.0",
78+
"typescript": "^3.4.1"
7879
},
7980
"dependencies": {
8081
"pretty-format": "^3.8.0"

src/index.d.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import { VNode } from 'preact';
22

3-
declare module render {
4-
interface Options {
5-
shallow?: boolean;
6-
xml?: boolean;
7-
pretty?: boolean;
8-
}
9-
10-
function render(vnode: VNode, context?: any, options?: Options): string;
11-
function shallowRender(vnode: VNode, context?: any): string;
3+
interface Options {
4+
shallow?: boolean;
5+
xml?: boolean;
6+
pretty?: boolean;
127
}
138

14-
export = render;
9+
export function render(vnode: VNode, context?: any, options?: Options):string;
10+
export function shallowRender(vnode: VNode, context?: any):string;
11+
export default render;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import render from '../src';
2+
import { h } from 'preact';
3+
4+
let vdom = <div class="foo">content</div>;
5+
6+
let html = render(vdom);
7+
console.log(html);

tsconfig.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"lib": [
5+
"es6",
6+
"dom"
7+
],
8+
"strict": true,
9+
"strictNullChecks": true,
10+
"strictFunctionTypes": true,
11+
"baseUrl": "../",
12+
"typeRoots": [
13+
"../"
14+
],
15+
"jsx": "react",
16+
"jsxFactory": "h",
17+
"types": [],
18+
"noEmit": true,
19+
"forceConsistentCasingInFileNames": true
20+
},
21+
"files": [
22+
"src/index.d.ts",
23+
"test/preact-render-to-string-tests.tsx"
24+
]
25+
}

0 commit comments

Comments
 (0)