Pesquisa de site

typescript - ts-node não parece estar reconhecendo tipos de typeRoots


Estou usando TypeScript para a configuração do webpack.

Meu tsconfig está assim:

{
  "compilerOptions": {
    "module": "CommonJS",
    "baseUrl": ".",
    "target": "esnext",
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "typeRoots": [
      "typings",
      "node_modules/@types"
    ],
    "sourceMap": true,
    "types": [
      "node"
    ]
  },
  "include": ["src", "typings"],
  "exclude": [
    "node_modules",
    "../../../node_modules"
  ]
}

então no meu typings/index.d.ts

import webpack from 'webpack';

declare global {
  namespace NodeJS {
    interface ProcessEnv {
      NODE_ENV: 'development' | 'production' | 'none';
      PROFILING?: string;
      SOURCE_MAP?: webpack.Options.Devtool;
      IMAGE_INLINE_SIZE_LIMIT: string;
      KIND: 'lib' | 'app' | 'shell';
      PUBLIC_PATH?: string;
      MAX_ASSET_SIZE: string;
      MAX_ENTRY_POINT_SIZE: string;
      OPTIMIZE?: 'optimize';
    }
  }
}

declare module 'dotenv-extended' {
  interface dotEnvExtended {
    load: (options: Partial<{
      encoding: string,
      silent: boolean,
      path: string,
      defaults: string,
      schema: string,
      errorOnMissing: boolean,
      errorOnExtra: boolean,
      errorOnRegex: boolean,
      includeProcessEnv: boolean,
      assignToProcessEnv: boolean,
      overrideProcessEnv: boolean
    }>) => void
  }
}

export {}

Estou usando o VS Code e parece que ele está reconhecendo minhas tipagens perfeitamente

No entanto, ao executar a compilação real, o ts-node parece estar usando [key: string]: string | undefined; do global.d.ts

Estou executando a build assim yarn cross-env TS_NODE_PROJECT=\"../dev-tools/tsconfig.json\" webpack --config ../dev-tools/src/webpack.config.ts