Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript boilerplate #78

Merged
merged 2 commits into from
Sep 26, 2024
Merged

Add TypeScript boilerplate #78

merged 2 commits into from
Sep 26, 2024

Conversation

marklundin
Copy link
Member

This PR adds support for generating TS boilerplate in the createScript() method. The boilerplate is an extension of the .mjs with type annotations.

import { Script } from 'playcanvas';

/**
 * The {@link https://api.playcanvas.com/classes/Engine.Script.html | Script} class is
 * the base class for all PlayCanvas scripts. Learn more about writing scripts in the
 * {@link https://developer.playcanvas.com/user-manual/scripting/ | scripting guide}.
 */
export class MyClass extends Script {
    /**
     * Called when the script is about to run for the first time.
     */
    initialize(): void {
    }

    /**
     * Called for enabled (running state) scripts on each tick.
     * 
     * @param {number} dt - The delta time in seconds since the last frame.
     */
    update(dt: number): void {
    }
}

@marklundin marklundin self-assigned this Sep 25, 2024
@marklundin marklundin requested a review from a team September 25, 2024 16:38
@marklundin marklundin changed the title Add support for TypeScript boilerplate generation Add support for TypeScript boilerplate Sep 25, 2024
@marklundin marklundin changed the title Add support for TypeScript boilerplate Add TypeScript boilerplate Sep 26, 2024
@marklundin marklundin merged commit 5bab6f2 into main Sep 26, 2024
2 checks passed
@marklundin marklundin deleted the feat-ts branch September 26, 2024 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants