From 118c1ff305132faa8a0ec26bfb181971bb691a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8Eura=C5=A1?= Date: Wed, 29 Aug 2018 01:45:03 +0200 Subject: [PATCH] Typescript cli (#647) * Add tsconfig.json and static module resolution for ts * Add trailing newline to tsconfig * Change tsc module to commonjs to support .json import * Add tsc as dependency and to scripts --- package.json | 4 +++- static.d.ts | 6 ++++++ tsconfig.json | 22 ++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 static.d.ts create mode 100644 tsconfig.json diff --git a/package.json b/package.json index de41e316..08b1efea 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ ], "scripts": { "lint": "eslint .", + "type-check": "tsc", "build": "webpack --config=config/webpack.prod.js", "build-library": "webpack --config=config/webpack.library.js", "analyze": "webpack --config=config/webpack.bundle-analyzer.js", @@ -20,7 +21,7 @@ "stats-library": "webpack --config=config/webpack.library.js --json > stats.json", "weight": "npm run build-library > /dev/null && gzip-size built/webamp.bundle.min.js", "test": "jest --projects config/jest.unit.js config/jest.eslint.js", - "travis-tests": "npm run test && npm run build && npm run build-library", + "travis-tests": "npm run test && npm run type-check && npm run build && npm run build-library", "tdd": "jest --projects config/jest.unit.js --watch", "format": "prettier --write experiments/**/*.js js/**/*.js css/**/*.css !css/**/*.min.css", "integration-tests": "npm run build -- --display=errors-only && jest --projects config/jest.integration.js", @@ -107,6 +108,7 @@ "style-loader": "^0.19.1", "tinyqueue": "^1.2.3", "travis-weigh-in": "^1.0.2", + "typescript": "^3.0.1", "uglifyjs-webpack-plugin": "^1.2.5", "url-loader": "^0.6.2", "webpack": "^3.6.0", diff --git a/static.d.ts b/static.d.ts new file mode 100644 index 00000000..2627e897 --- /dev/null +++ b/static.d.ts @@ -0,0 +1,6 @@ +declare module "*.wsz"; +declare module "*.mp3"; +declare module "*.png"; +declare module "*.ico"; +declare module "*.jpg"; +declare module "*.svg"; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..418366c9 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "moduleResolution": "node", + "module": "commonjs", + "target": "esnext", + "allowJs": true, + "skipLibCheck": true, + "allowSyntheticDefaultImports": true, + "resolveJsonModule": true, + "strict": true, + "jsx": "preserve", + "noEmit": true, + "pretty": true + }, + "include": [ + "js/**/*.js" + ], + "exclude": [ + "node_modules", + "**/*.spec.ts" + ] +}