I’m trying to use Godot-TS with a pure ESNext setup (no CommonJS), but I can’t find any examples demonstrating this configuration. When I attempt to import the godot namespace, I get an error saying that the module has no exported member godot.
Reproduction Steps:
- Create a new GodotJS + TypeScript project.
- Generate a godot.d.ts at the project root via the Godot editor:
// godot.d.ts
export namespace godot {
export type GodotClass = new () => godot.Object;
export class Object {}
export class Node extends godot.Object {
_ready(): void;
}
export namespace Node {}
}
- Configure tsconfig.json as follows:
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "node",
"rootDir": ".",
"outDir": "dist",
"declaration": true,
"declarationDir": "typings",
"isolatedModules": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"experimentalDecorators": true,
"incremental": true,
"tsBuildInfoFile": ".godot/.tsbuildinfo",
"baseUrl": "."
},
"include": [
"src",
"godot.d.ts",
"typings"
],
"exclude": [
"lib.dom.d.ts",
"node_modules",
"dist"
],
"types": ["godot.d.ts"]
}
- In a TypeScript file:
import { godot } from "godot";
- Build or run the project.
Actual Behavior:
Module '"godot"' has no exported member 'godot'.
Expected Behavior:
The godot namespace should be available as an ES module import, matching the declarations in godot.d.ts.
Notes / Questions:
-
Are there existing examples or recommended settings for using Godot-TS with "module": "ESNext"?
-
Should the declarations in `godot.d.ts` be modified (e.g. use export default godot, or a different module mapping) to support ESM?
-
Is there a mapping or alias configuration needed in `tsconfig.json` (e.g. paths) to make import { godot } from "godot" work?
Any guidance or example repository demonstrating a pure ESNext import setup would be greatly appreciated.
I’m trying to use Godot-TS with a pure ESNext setup (no CommonJS), but I can’t find any examples demonstrating this configuration. When I attempt to import the godot namespace, I get an error saying that the module has no exported member godot.
Reproduction Steps:
{ "compilerOptions": { "target": "ES2022", "module": "ESNext", "moduleResolution": "node", "rootDir": ".", "outDir": "dist", "declaration": true, "declarationDir": "typings", "isolatedModules": true, "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "resolveJsonModule": true, "experimentalDecorators": true, "incremental": true, "tsBuildInfoFile": ".godot/.tsbuildinfo", "baseUrl": "." }, "include": [ "src", "godot.d.ts", "typings" ], "exclude": [ "lib.dom.d.ts", "node_modules", "dist" ], "types": ["godot.d.ts"] }Actual Behavior:
Module '"godot"' has no exported member 'godot'.
Expected Behavior:
The godot namespace should be available as an ES module import, matching the declarations in godot.d.ts.
Notes / Questions:
Any guidance or example repository demonstrating a pure ESNext import setup would be greatly appreciated.