diff --git a/package.json b/package.json index b454493..ed2c5f4 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "build-dashboard": "webpack --config config/webpack.config.trader.js --progress --profile --bail", "build-all": "npm run build-examples && npm run build-dashboard", "build": "npm run clean && npm run mkdirs && npm run build-all && npm run copy", - "start": "npm run examples" + "start": "npm run examples", + "test" : "sh ./ts-tests/runTsTests.sh" }, "repository": { "type": "git", @@ -38,11 +39,13 @@ "homepage": "http://www.ag-grid.com/", "devDependencies": { "@babel/core": "7.3.3", - "babel-loader": "8.0.5", - "@babel/preset-env": "7.3.1", - "@babel/preset-react": "7.0.0", "@babel/plugin-proposal-class-properties": "7.3.3", "@babel/plugin-proposal-function-bind": "7.2.0", + "@babel/preset-env": "7.3.1", + "@babel/preset-react": "7.0.0", + "@types/react": "^16.8.6", + "@types/react-dom": "^16.8.2", + "babel-loader": "8.0.5", "css-loader": "2.1.0", "file-loader": "3.0.1", "gulp": "3.9.1", @@ -52,6 +55,7 @@ "prop-types": "15.7.2", "rimraf": "2.6.3", "style-loader": "0.23.1", + "typescript": "^3.3.3333", "webpack": "4.29.5", "webpack-cli": "3.2.3", "webpack-dev-server": "3.2.0" diff --git a/ts-tests/InvalidGridProperty.tsx b/ts-tests/InvalidGridProperty.tsx new file mode 100644 index 0000000..82dd282 --- /dev/null +++ b/ts-tests/InvalidGridProperty.tsx @@ -0,0 +1,4 @@ +import React from 'react'; +import {AgGridReact} from 'ag-grid-react'; + +export const App: React.FunctionComponent = () => ; diff --git a/ts-tests/SimpleFunctionalGrid.tsx b/ts-tests/SimpleFunctionalGrid.tsx new file mode 100644 index 0000000..e739f7f --- /dev/null +++ b/ts-tests/SimpleFunctionalGrid.tsx @@ -0,0 +1,4 @@ +import React from 'react'; +import {AgGridReact} from 'ag-grid-react'; + +export const App: React.FunctionComponent = () => ; diff --git a/ts-tests/runTsTests.sh b/ts-tests/runTsTests.sh new file mode 100755 index 0000000..5970611 --- /dev/null +++ b/ts-tests/runTsTests.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +# here as a quick ts test for use in the CI +# in time this will be removed the full battery of tests be moved to a centralised location + +error_found=false + +# has an invalid property - should complain +./node_modules/.bin/tsc --target "ES5" --module 'commonjs' --lib esnext,dom --allowSyntheticDefaultImports --jsx 'preserve' --noEmit --strict ts-tests/InvalidGridProperty.tsx &> /dev/null +if [ $? -ne 1 ]; then + echo "ag-grid-react grid with invalid property should throw a compiler error" + error_found=true +fi + +# a valid grid - no errors should be emitted +./node_modules/.bin/tsc --target "ES5" --module 'commonjs' --lib esnext,dom --allowSyntheticDefaultImports --jsx 'preserve' --noEmit --strict ts-tests/SimpleFunctionalGrid.tsx &> /dev/null +if [ $? -ne 0 ]; then + echo "valid ag-grid-react grid should compile" + error_found=true +fi + +if [ "$error_found" = true ]; then + exit 1 +fi + +exit 0