Skip to content

Feature: Koishi plugin documentation could explain how to run TypeScript examples #1540

Description

@wenna-tao

Describe the problem related to the feature request

Hi, I followed the Koishi plugin development documentation and tried to use the TypeScript examples.

However, when I tried to run the code directly with Node.js, it did not work and produced syntax errors, such as:

  • SyntaxError: Unexpected token 'export'

After checking for a while, I found that this might be because TypeScript code needs to be compiled to JavaScript before it can be executed by Node.js. Another option would be to use tools like ts-node.

I did not notice this clearly in the documentation, so at first I thought I had configured Koishi incorrectly.

What happened:

  • The documentation provides TypeScript examples
  • I copied the example code
  • I tried to run it directly with Node.js
  • The code failed with syntax errors
  • The actual issue was that the TypeScript code was not compiled

As a beginner, this was a bit confusing because the error looked like a Koishi or Node.js problem. Since the example was in the documentation, I assumed it could be run directly, but there was still a missing TypeScript setup step.

Describe the solution you'd like

It might be helpful to add a short note in the plugin development documentation, such as:

  • TypeScript code needs to be compiled with tsc before running with Node.js
  • or it can be run using tools like ts-node
  • Node.js cannot directly run TypeScript syntax without extra setup

Thanks for the project and the documentation!

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions