feat(cli): enable type checking

This commit is contained in:
chenjiahan 2020-05-27 21:13:21 +08:00
parent 26a7cc5d3c
commit f508d2e6c0
4 changed files with 63 additions and 8 deletions

View File

@ -73,6 +73,7 @@
"css-loader": "^3.5.3",
"eslint": "^6.8.0",
"fast-glob": "^3.2.2",
"fork-ts-checker-webpack-plugin": "^4.1.6",
"gh-pages": "^2.2.0",
"hash-sum": "^2.0.0",
"html-webpack-plugin": "4.3.0",

View File

@ -1,7 +1,11 @@
import sass from 'sass';
import FriendlyErrorsPlugin from '@nuxt/friendly-errors-webpack-plugin';
import { VueLoaderPlugin } from 'vue-loader';
import { join } from 'path';
import { existsSync } from 'fs';
import { consola } from '../common/logger';
import {
CWD,
CACHE_DIR,
STYLE_EXTS,
SCRIPT_EXTS,
@ -28,6 +32,36 @@ const CSS_LOADERS = [
},
];
const plugins = [
new VueLoaderPlugin(),
new FriendlyErrorsPlugin({
clearConsole: false,
logLevel: 'WARNING',
}),
];
const tsconfigPath = join(CWD, 'tsconfig.json');
console.log('tsconfigPath', existsSync(tsconfigPath));
if (existsSync(tsconfigPath)) {
const ForkTsCheckerPlugin = require('fork-ts-checker-webpack-plugin');
plugins.push(
new ForkTsCheckerPlugin({
formatter: 'codeframe',
vue: { enabled: true },
logger: {
// skip info message
info() {},
warn(message: string) {
consola.warn(message);
},
error(message: string) {
consola.error(message);
},
},
})
);
}
export const baseConfig = {
mode: 'development',
resolve: {
@ -83,11 +117,5 @@ export const baseConfig = {
},
],
},
plugins: [
new VueLoaderPlugin(),
new FriendlyErrorsPlugin({
clearConsole: false,
logLevel: 'WARNING',
}),
],
plugins,
};

View File

@ -2,7 +2,7 @@
# yarn lockfile v1
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.8.3":
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.5.5", "@babel/code-frame@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.8.3.tgz#33e25903d7481181534e12ec0a25f16b6fcf419e"
integrity sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==
@ -4946,6 +4946,19 @@ forever-agent@~0.6.1:
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=
fork-ts-checker-webpack-plugin@^4.1.6:
version "4.1.6"
resolved "https://registry.npm.taobao.org/fork-ts-checker-webpack-plugin/download/fork-ts-checker-webpack-plugin-4.1.6.tgz#5055c703febcf37fa06405d400c122b905167fc5"
integrity sha1-UFXHA/6883+gZAXUAMEiuQUWf8U=
dependencies:
"@babel/code-frame" "^7.5.5"
chalk "^2.4.1"
micromatch "^3.1.10"
minimatch "^3.0.4"
semver "^5.6.0"
tapable "^1.0.0"
worker-rpc "^0.1.0"
form-data@3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.0.tgz#31b7e39c85f1355b7139ee0c647cf0de7f83c682"
@ -7582,6 +7595,11 @@ methods@~1.1.2:
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"
integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=
microevent.ts@~0.1.1:
version "0.1.1"
resolved "https://registry.npm.taobao.org/microevent.ts/download/microevent.ts-0.1.1.tgz#70b09b83f43df5172d0205a63025bce0f7357fa0"
integrity sha1-cLCbg/Q99RctAgWmMCW84Pc1f6A=
micromatch@^3.1.10, micromatch@^3.1.4:
version "3.1.10"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23"
@ -11892,6 +11910,13 @@ worker-farm@^1.7.0:
dependencies:
errno "~0.1.7"
worker-rpc@^0.1.0:
version "0.1.1"
resolved "https://registry.npm.taobao.org/worker-rpc/download/worker-rpc-0.1.1.tgz#cb565bd6d7071a8f16660686051e969ad32f54d5"
integrity sha1-y1Zb1tcHGo8WZgaGBR6WmtMvVNU=
dependencies:
microevent.ts "~0.1.1"
wrap-ansi@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"

1
types/sku.d.ts vendored
View File

@ -16,6 +16,7 @@ export type SkuTreeItemData = {
k: string;
v: SkuTreeItemValueData[];
k_s: string;
is_multiple: never;
};
export type SkuTreeItemValueData = {