Skip to content
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

Test the typings by trying to render a simple component server-side #1181

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dist/
docs/build/
docs/app/docgenInfo.json
dll/
.vscode/

.DS_Store
.idea/
Expand Down
2 changes: 2 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ test:
- npm run lint
- npm run tsd:lint
post:
- npm run build:commonjs
- npm run tsd:test
- bash <(curl -s https://codecov.io/bash)
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"test:watch": "npm run test --silent -- --watch",
"tsd": "cpx './src/**/*.d.ts' dist/commonjs",
"tsd:lint": "tslint './src/**/*.d.ts'",
"tsd:lint:fix": "npm run -s tsd:lint -- --fix"
"tsd:lint:fix": "npm run -s tsd:lint -- --fix",
"tsd:test": "ts-node -P test/typings test/typings/test.tsx"
},
"repository": {
"type": "git",
Expand All @@ -55,6 +56,7 @@
},
"devDependencies": {
"@types/react": "^0.14.54",
"@types/react-dom": "^0.14.20",
"babel-cli": "^6.18.0",
"babel-core": "^6.21.0",
"babel-eslint": "^7.0.0",
Expand Down Expand Up @@ -126,6 +128,7 @@
"style-loader": "^0.13.1",
"ta-scripts": "^2.5.2",
"through2": "^2.0.2",
"ts-node": "^2.0.0",
"tslint": "^4.3.1",
"tslint-config-typings": "^0.3.1",
"typescript": "^2.1.5",
Expand Down
15 changes: 15 additions & 0 deletions test/typings/test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as React from 'react';
import * as ReactDOMServer from 'react-dom/server';

import { Button } from '../../'; // Import Button from the main index.d.ts
import { Icon } from '../../dist/commonjs/elements/Icon'; // Import Icon directly from a subfolder

const Component = () => (
<Button>
<Icon name="sidebar"/>
</Button>
);

console.log(ReactDOMServer.renderToStaticMarkup(<Component/>));


20 changes: 20 additions & 0 deletions test/typings/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"sourceMap": true,
"pretty": true,
"strictNullChecks": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitThis": true,
"forceConsistentCasingInFileNames": true,
"module": "commonjs",
"target": "es5",
"jsx": "react",
"lib": ["dom", "es5"],
"importHelpers": false,
"noEmit": true
}
}