修改tsconfig.js 增加"noImplicitAny": false,解决代码类型没有指定,显示Any 错误
To solve the error, explicitly set the parameter's type to any
, use a more specific type or set noImplicitAny
to false
in tsconfig.json
.
https://bobbyhadz.com/blog/typescript-parameter-implicitly-has-an-any-type#:~:text=The%20%22Parameter%20%27X%27%20implicitly%20has%20an%20%27any%27%20type%22,type%20or%20set%20noImplicitAny%20to%20false%20in%20tsconfig.json.
{
"extends": "./.config/tsconfig.json",
"compilerOptions": {
"noImplicitAny": false
}
}
2.This syntax requires an imported helper but module 'tslib' cannot be found
pnpm
install tslib@latest
https://bobbyhadz.com/blog/typescript-syntax-requires-imported-helper-but-module-tslib-cannot#:~:text=To%20solve%20the%20error%20%22This%20syntax%20requires%20an,IDE%20is%20using%20the%20correct%20%28workspace%29%20TypeScript%20version.
3. 错误信息:
RROR in ./module.ts
Module build failed (from ../node_modules/.pnpm/swc-loader@0.2.6_@swc+core@1.4.17_@swc+helpers@0.4.36__webpack@5.91.0_@swc+core@1.4.17_@swc+h_rr3j462mo335la4upn5l7exuzi/node_modules/swc-loader/src/index.js):
Error: failed to handle: base_dir(`./src`) must be absolute. Please ensure that `jsc.baseUrl` is specified correctly. This cannot be deduced by SWC itself because SWC is a transpiler and it does not try to resolve project details. In other words, SWC does not know which directory should be used as a base directory. It can be deduced if `.swcrc` is used, but if not, there are many candidates. e.g. the directory containing `package.json`, or the current working directory. Because of that, the caller (typically the developer of the JavaScript package) should specify it. If you see this error, please report an issue to the package author.webpack 5.91.0 compiled with 1 error in 327 ms
Type-checking in progress...
thread '<unnamed>' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_transforms_module-0.180.19/src/path.rs:122:13:
base_dir(`./src`) must be absolute. Please ensure that `jsc.baseUrl` is specified correctly. This cannot be deduced by SWC itself because SWC is a transpiler and it does not try to resolve project details. In other words, SWC does not know which directory should be used as a base directory. It can be deduced if `.swcrc` is used, but if not, there are many candidates. e.g. the directory containing `package.json`, or the current working directory. Because of that, the caller (typically the developer of the JavaScript package) should specify it. If you see this error, please report an issue to the package author.
=============WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.
You may find that it works just fine, or you may not.
SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <4.9.0
YOUR TYPESCRIPT VERSION: 4.9.5
Please only submit bug reports when using the officially supported version.
=============
assets by status 583 KiB [cached] 10 assets
./module.ts 39 bytes [built] [1 error]ERROR in ./module.ts
Module build failed (from ../node_modules/.pnpm/swc-loader@0.2.6_@swc+core@1.4.17_@swc+helpers@0.4.36__webpack@5.91.0_@swc+core@1.4.17_@swc+h_rr3j462mo335la4upn5l7exuzi/node_modules/swc-loader/src/index.js):
Error: failed to handle: base_dir(`./src`) must be absolute. Please ensure that `jsc.baseUrl` is specified correctly. This cannot be deduced by SWC itself because SWC is a transpiler and it does not try to resolve project details. In other words, SWC does not know which directory should be used as a base directory. It can be deduced if `.swcrc` is used, but if not, there are many candidates. e.g. the directory containing `package.json`, or the current working directory. Because of that, the caller (typically the developer of the JavaScript package) should specify it. If you see this error, please report an issue to the package author.webpack 5.91.0 compiled with 1 error in 947 ms
解决: 降@swc/core 版本
pnpm install @swc/core@1.3.75
重新运行: