我的项目是通过与打字稿反应来设置的,通常它可以正常工作,但是在某些细节上,它甚至无法编译也不能工作,我该如何配置我的项目?
这是我的tsconfig.json
{
"compilerOptions": {
"sourceMap": true,
"noImplicitAny": false,
"module": "commonjs",
"target": "es6",
"jsx": "react",
"paths": {
"src": ["./src"],
"root": ["."],
"utils": ["./src/utils"]
},
"baseUrl": ".",
"rootDir": ".",
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true
},
"files": [
"./js_transition.d.ts"
],
"include": [
"./src/**/*",
"./server/**/*"
],
"exclude": [
"build",
"node_modules"
]
}
这是我的js_transition.d.ts
// External libs
// These will have to remain until we (or someone else) writes
// proper .d.ts definition files for them.
declare var template:any;
// node's typings definitions currently break stuff, use this instead
declare var require:any;
declare var process:any;
declare var __dirname:any;
declare var module:any;
declare var DEBUG:boolean;
declare var window:Window;
declare var ca:any;
declare var __PRELOADED_STATE__:any;
interface System {
import<T = any>(module: string): Promise<T>
}
declare const System: System
在我这样做的同时,
Syntax error: Unexpected token, expected , (26:12)
24 | set(this.props.dispatch);
25 | // wx_init();
> 26 | (window as any).a = 1;
| ^
27 | }
28 | componentWillUnmount() {
29 | }
它将抛出此错误。