Type Generation#
OneJS provides TypeScript declarations for C# types so you get IntelliSense, autocomplete, and type checking in your editor.
Unity Types (unity-types)#
The unity-types npm package provides pre-generated declarations for standard Unity assemblies: CoreModule, UIElements, Physics, Audio, InputSystem, and more.
Install it as a dev dependency:
npm install -D unity-typesOnce installed, your editor will provide IntelliSense for CS.UnityEngine.* types and ES6-style imports from Unity namespaces.
Project Types (JSRunner)#
For types from your own C# code (e.g., Assembly-CSharp), JSRunner has built-in auto-generation.
In the JSRunner inspector, open the Typings section. Toggle Auto Generate Typings on and configure which assemblies to include (e.g., Assembly-CSharp, Assembly-CSharp-Editor).
Generated declarations are written to {WorkingDir}/typings/index.d.ts. They regenerate automatically on domain reload, which happens at editor startup and after any C# recompile. You can also trigger regeneration manually from the inspector.
Custom Packages (Type Generator Window)#
For third-party packages or specific assemblies, use the Type Generator window at Tools > OneJS > Type Generator.
The window has three panels: an assembly selector on the left, a type browser in the middle, and a live preview on the right. You can filter assemblies by category (Unity, User, etc.) and search for specific types.
Select the types you need and click Generate to save a .d.ts file.
Programmatic API#
You can also generate declarations from C# scripts:
TypeGenerator.Create()
.AddAssemblyByName("MyCustomPackage")
.IncludeDocumentation()
.Build()
.WriteTo("types/my-package.d.ts");This is useful for CI pipelines or editor tooling that needs to keep type declarations in sync automatically.