diff --git a/tests/run_all_tests.sh b/tests/run_all_tests.sh index c73a4cfd1..775b0b4ca 100755 --- a/tests/run_all_tests.sh +++ b/tests/run_all_tests.sh @@ -67,6 +67,9 @@ run_test_command "node" "./node_modules/.bin/mocha tests/node --opts tests/node/ # Run generator tests inside a browser and check the results. run_test_command "generators" "tests/scripts/run_generators.sh" +# Generate TypeScript typings and ensure there are no errors. +run_test_command "typings" "tests/scripts/compile_typings.sh" + # # Attempt advanced compilation of a Blockly app. # run_test_command "compile" "tests/compile/compile.sh" diff --git a/tests/scripts/compile_typings.sh b/tests/scripts/compile_typings.sh new file mode 100755 index 000000000..ee16beb56 --- /dev/null +++ b/tests/scripts/compile_typings.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# ANSI colors +BOLD_GREEN='\033[1;32m' +BOLD_RED='\033[1;31m' +ANSI_RESET='\033[0m' + +# Download TypeScript to obtain the compiler. +echo "Downloading TypeScript" +npm install typescript + +# Generate Blockly typings. +echo "Generating Blockly typings" +npm run typings + +# Use the TypeScript compiler to compile the generated typings. +echo "Compiling typings" +cd typings +../node_modules/.bin/tsc blockly.d.ts + + +if [ $? -eq 0 ] +then + echo -e "${BOLD_GREEN}TypeScript typings compiled successfully.${ANSI_RESET}" + exit 0 +else + echo -e "${BOLD_RED}Failed to compile TypeScript typings.${ANSI_RESET}" >&2 + exit 1 +fi