Get custom type without preloading

Godot Version

4.2.1 stable


I have a script that is instanced with the root scene. I want to get property hints from the editor to keep things easy. Is the code in the screenshot the best way to do this, or is there a way to do this without pre-loading the script in every script that interacts with the instance of player_state in the root scene?

# Get script
const Player_State = preload("res://scenes/")
# Assign type to instance of script
@onready var player_state: Player_State = tree.get_first_node_in_group("state")

In, add the following line:

class_name Player_State