godotjs / godotjs/javascript

Global pollution

Open
#187 3 comments 7 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
1.1k
Forks
80
PR merge metrics
No merged PRs in 30d

Description

I personally don't really like global pollution, you could take advantage of the javascript module system to export godot methods, utilities and classes without needing to register the ``godot`` namespace into the global. If you are wondering how this would work, it is quite simple, the first thing needed would be a d.ts documentation file for intellisense to work. And then we can consume the godot api using import syntax:

```js
import { Node2D, print } from "godot";

export class Main extends Node2D {
_ready() {
print("Hi from Javascript Main class");
}
}
```

This is literally the only thing I dislike about this api, the godot api is simply thrown into the global scope.

Contributor guide

Open the contributing guide

Research direction

Review how the current global godot namespace is exposed, then examine the proposed d.ts documentation file and the JavaScript module-system entry points. Confirm the intended import syntax with the Node2D and print example, and treat removal of global registration while preserving the Godot API as the definition of done.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
api, developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.