colyseus / colyseus-unity-sdk

⚔ Colyseus Multiplayer SDK for Unity
https://docs.colyseus.io/getting-started/unity-sdk/
MIT License
371 stars 100 forks source link

colyseus-unity-sdk-0.14.20 schema-codegen bug. #207

Closed yty closed 1 year ago

yty commented 1 year ago
PS D:\GithubFiles\colyseus\colyseus-unity-sdk-0.14.20\Server\src\rooms\schema> npx schema-codegen MyRoomState.ts --output client-side/ --csharp --namespace MyGame.Schema
Creating client-side/ directory
ts.canHaveDecorators is not a function
TypeError: ts.canHaveDecorators is not a function
    at getDecorators (D:\GithubFiles\colyseus\colyseus-unity-sdk-0.14.20\Server\node_modules\@colyseus\schema\lib\codegen\parser.js:211:12)
    at inspectNode (D:\GithubFiles\colyseus\colyseus-unity-sdk-0.14.20\Server\node_modules\@colyseus\schema\lib\codegen\parser.js:85:37)
    at D:\GithubFiles\colyseus\colyseus-unity-sdk-0.14.20\Server\node_modules\@colyseus\schema\lib\codegen\parser.js:149:49
    at visitNode (D:\GithubFiles\colyseus\colyseus-unity-sdk-0.14.20\Server\node_modules\typescript\lib\typescript.js:18964:24)
    at Object.forEachChild (D:\GithubFiles\colyseus\colyseus-unity-sdk-0.14.20\Server\node_modules\typescript\lib\typescript.js:19336:21)
    at inspectNode (D:\GithubFiles\colyseus\colyseus-unity-sdk-0.14.20\Server\node_modules\@colyseus\schema\lib\codegen\parser.js:149:8)
    at D:\GithubFiles\colyseus\colyseus-unity-sdk-0.14.20\Server\node_modules\@colyseus\schema\lib\codegen\parser.js:149:49
    at visitNodes (D:\GithubFiles\colyseus\colyseus-unity-sdk-0.14.20\Server\node_modules\typescript\lib\typescript.js:18973:30)
    at Object.forEachChild (D:\GithubFiles\colyseus\colyseus-unity-sdk-0.14.20\Server\node_modules\typescript\lib\typescript.js:19327:24)
    at inspectNode (D:\GithubFiles\colyseus\colyseus-unity-sdk-0.14.20\Server\node_modules\@colyseus\schema\lib\codegen\parser.js:149:8)

schema-codegen [path/to/Schema.ts]

Usage (C#/Unity)
    schema-codegen src/Schema.ts --output client-side/ --csharp --namespace MyGame.Schema

Valid options:
    --output: the output directory for generated client-side schema files
    --csharp: generate for C#/Unity
    --cpp: generate for C++
    --haxe: generate for Haxe
    --ts: generate for TypeScript
    --js: generate for JavaScript
    --java: generate for Java
    --lua: generate for LUA

Optional:
    --namespace: generate namespace on output code
    --decorator: custom name for @type decorator to scan for
endel commented 1 year ago

Hey @yty, thanks for reporting, this is likely due to TypeScript version (we've improved 4.8+ support here https://github.com/colyseus/schema/commit/25f9697f270f628967d7d960654cc6ef55b6cbbe)

Although it should work on previous versions, can you share with version of TypeScript are you using? Cheers!

endel commented 1 year ago

Just fixed it on https://github.com/colyseus/schema/commit/1084a6be9b9f9cabbc43425b9d4069040ffc0925, you can either upgrade TypeScript to "typescript": "^4.8.4", or/and "@colyseus/schema": "^1.0.43" 🙏

yty commented 1 year ago

Just fixed it on colyseus/schema@1084a6b, you can either upgrade TypeScript to , or/and "typescript": "^4.8.4"``"@colyseus/schema": "^1.0.43" 🙏

Thanks for your reply, follow your tips, it is already available. :+1: