Categories
Uncategorised

`baseUrl` and `include` in tsconfig.json

// Working one
{
  "compilerOptions": {
    "allowJs": true,
    "baseUrl": "./",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "jsx": "react",
    "lib": ["dom", "dom.iterable", "esnext"],
    "module": "commonjs",
    "moduleResolution": "node",
    "noImplicitAny": false,
    "removeComments": true,
    "strict": true,
    "target": "es6"
  },
  "include": ["src"],
  "exclude": ["node_modules"]
}
// Broken one
{
  "compilerOptions": {
    "allowJs": true,
    "baseUrl": "./src",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "jsx": "react",
    "lib": ["dom", "dom.iterable", "esnext"],
    "module": "commonjs",
    "moduleResolution": "node",
    "noImplicitAny": false,
    "removeComments": true,
    "strict": true,
    "target": "es6"
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules"]
}

Something interesting that I found. Be careful when you are “playing” with the param baseUrl and include. It might show the message Compiling with Typescript… but it’s not compiling anything because you are in the folder with a path like ./src/src.