How to integrate Dva with Typescript

1. The original project uses dva,. When integrating typescript, refer to the official example given by dva

.

clipboard.png

global.d.tsrequiretypescript:

clipboard.png

the following is the code involved in the error:


//  tsconfig.json
{
  "compilerOptions": {
    "sourceMap": true,
    "target": "es6",
    "jsx": "react",
    "module": "commonjs",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "declaration": false,
    "noImplicitAny": false,
    "noImplicitReturns": false,
    "removeComments": true,
    "strictNullChecks": false,
    "outDir": "build",
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "lib": [
      "es6",
      "es7",
      "dom"
    ],
    "baseUrl": "./src",
    "paths": {
      "IconFont": [
        "src/components/Iconfont"
      ]
    }
  },
  "exclude": [
    "dist",
    "build",
    "node_modules"
  ]
}

// global.d.ts
declare var require: {
  <T>(path: string): T;
  (paths: string[], callback: (...modules: any[]) => void): void;
  ensure: (paths: string[], callback: (require: <T>(path: string) => T) => void) => void;
};

// package.json
"devDependencies": {
    "awesome-typescript-loader": "^4.0.0",
    "tslint": "^5.10.0",
    "typescript": "^2.8.3",
  },
  "dependencies": {
    "@types/react": "^16.3.14",
    "@types/react-dom": "^16.0.5",
    "dva": "^2.1.0",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
}

// ./node_modules/@types/node/index.d.ts 
declare var require: NodeRequire;

interface NodeModule {
    exports: any;
    require: NodeRequireFunction;
    id: string;
    filename: string;
    loaded: boolean;
    parent: NodeModule | null;
    children: NodeModule[];
    paths: string[];
}

Please take a look at it. Thank you. Thank you.


there are more environmental pits created by yourself. Share a project built by others and use it directly. address

  • How does react scroll horizontally?

    this icon may have hundreds of pieces of data, but if it can t be displayed on one screen, I want it to scroll horizontally to show the data that has not been displayed, which cannot be realized with css. Is there a boss in react-native, who knows t...

Menu