From 16ee8e142cedbe09f13b905d1867f71c7047c5a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20V=C3=A4=C3=A4n=C3=A4nen?= Date: Wed, 18 Jan 2017 20:00:10 +0200 Subject: [PATCH] Test the typings by trying to render a simple component server-side --- .gitignore | 1 + circle.yml | 2 ++ package.json | 5 ++++- test/typings/test.tsx | 15 +++++++++++++++ test/typings/tsconfig.json | 20 ++++++++++++++++++++ 5 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test/typings/test.tsx create mode 100644 test/typings/tsconfig.json diff --git a/.gitignore b/.gitignore index 964f8c52e7..3f09403146 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ dist/ docs/build/ docs/app/docgenInfo.json dll/ +.vscode/ .DS_Store .idea/ diff --git a/circle.yml b/circle.yml index a08c7136c4..8ac12c430e 100644 --- a/circle.yml +++ b/circle.yml @@ -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) diff --git a/package.json b/package.json index 3685a454d1..4bffc4372b 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", @@ -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", diff --git a/test/typings/test.tsx b/test/typings/test.tsx new file mode 100644 index 0000000000..47d637e1de --- /dev/null +++ b/test/typings/test.tsx @@ -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 = () => ( + +); + +console.log(ReactDOMServer.renderToStaticMarkup()); + + diff --git a/test/typings/tsconfig.json b/test/typings/tsconfig.json new file mode 100644 index 0000000000..5931b8d8cd --- /dev/null +++ b/test/typings/tsconfig.json @@ -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 + } +}