Open lyricnz opened 4 months ago
This feels like a tsconfig problem? My tsconfig.json file is
{
"compilerOptions": {
"target": "es2022",
"module": "commonjs",
"lib": [
"es2022"
],
"declaration": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"esModuleInterop": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": false,
"inlineSourceMap": true,
"inlineSources": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"typeRoots": [
"./node_modules/@types"
]
},
"exclude": [
"node_modules",
"dist"
]
}
and the generated .js file includes
Object.defineProperty(exports, "__esModule", { value: true });
const chai = __importStar(require("chai"));
const chai_as_promised_1 = __importDefault(require("chai-as-promised"));
const instrumentedResource_1 = require("../../drivers/instrumentedResource");
const driverInterface_1 = require("../../drivers/driverInterface");
chai.use(chai_as_promised_1.default);
you're in a commonjs project (module: "commonjs"
)
8.0.0 is esm-only (like chai 5.x is too)
so you can either:
"module": "nodenext"
, and set "type": "module"
in your package.json)Thanks. It looks like doing that and I'll have to change 500+ imports to include explicit .js
extension?
Node will probably still handle the imports without extensions but I guess typescript may complain if they're not exported paths 😬
It should be scriptable at least but I understand your pain (code review won't be a fun one)
You may be able to loosen typescript's constraints by using module: "bundler"
The problem is you can't use 8.0.0 with Typescript yet, because the @types/chai-as-promised
package hasn't been updated yet. I'm using this workaround for now:
import * as chaiAsPromised from "chai-as-promised";
use((chaiAsPromised as any).default);
Once the @types
package is updated to 8.0, that can be changed to:
import chaiAsPromised from "chai-as-promised";
use(chaiAsPromised);
we should definitely push a new major to the @types
package
if anyone has time to contribute that upstream to DT, i'd be happy to review
But the quoted
driverInterface.spec.js
is built from a TS which is:Which bit of the code is wrong? (sorry, I'm maintaining a project, but didn't set up any of this TS/JS stuff)