#Relative imports broken in TS 6.0

5 messages · Page 1 of 1 (latest)

cosmic dove
#

I get this error using webpack after upgrading to TS 6.0:

ERROR in ./src/Inventory/components/BarcodeScanner/QrCodeScanner.tsx 
[tsl] ERROR
      TS5011: The common source directory of 'tsconfig.json' is './src/Inventory/components/BarcodeScanner'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout.
  Visit https://aka.ms/ts6 for migration information.

The import in question is:

import BarcodeScanner from "./BarcodeScanner";

I am very confused because the tsconfig.json is definitely not in that folder. The command I run is "NODE_OPTIONS='--max-old-space-size=8192' webpack --watch --mode development --devtool eval-cheap-module-source-map"

#

This is my current tsconfig:

{
  "compilerOptions": {
    "outDir": "./dist/",
    "noImplicitAny": true,
    "target": "ES2024",
    "jsx": "react-jsx",
    "allowJs": true,
    "module": "ESNext",
    "moduleResolution": "bundler",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "paths": {
      "@/*": ["./src/*"],
      "Styles": ["./src/util/styles"]
    },
    "resolveJsonModule": true,
    "lib": ["ES2024", "DOM", "DOM.Iterable"],
    "types": [
      "@testing-library/jest-dom",
      "@sa11y/vitest",
      "jquery",
    ]
  }
}
bronze badger
#

The webpack aspect of this complicates it, your webpack config may actually be relevant, but I'd start with trying to set rootDir to whatever the outermost folder containing your code is - probably "rootDir": "src"