-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
I'm in the process of trying to port the tutorial code (which I got working as js/jsx) to use Typescript (ts/tsx).
NOTE: I have little-to-no typescript knowledge.
It seems like there's some problem with the Phase class and how it relates to PhaseClass and AnyPhase.
I'm having two issues outlined below:
TicTacToeGame.childPhaseClasses = [LobbyPhase, GameInProgressPhase, GameEndedPhase];
error:
M:\GitHub\TicTacToe-Ravens\node_modules\ts-node\src\index.ts:692
return new TSError(diagnosticText, diagnosticCodes);
^
TSError: ⨯ Unable to compile TypeScript:
src/TicTacToeGame.ts(30,36): error TS2322: Type 'typeof LobbyPhase' is not assignable to type 'PhaseClass<AnyPhase>'.
Types of parameters 'parent' and 'parent' are incompatible.
Type 'AnyPhase | null' is not assignable to type 'null'.
Type 'AnyPhase' is not assignable to type 'null'.
src/TicTacToeGame.ts(30,48): error TS2322: Type 'typeof GameInProgressPhase' is not assignable to type 'PhaseClass<AnyPhase>'.
Types of parameters 'parent' and 'parent' are incompatible.
Type 'AnyPhase | null' is not assignable to type 'null'.
Type 'AnyPhase' is not assignable to type 'null'.
src/TicTacToeGame.ts(30,69): error TS2322: Type 'typeof GameEndedPhase' is not assignable to type 'PhaseClass<AnyPhase>'.
Types of parameters 'parent' and 'parent' are incompatible.
Type 'AnyPhase | null' is not assignable to type 'null'.
Type 'AnyPhase' is not assignable to type 'null'.
at createTSError (M:\GitHub\TicTacToe-Ravens\node_modules\ts-node\src\index.ts:692:12)
at reportTSError (M:\GitHub\TicTacToe-Ravens\node_modules\ts-node\src\index.ts:696:19)
at getOutput (M:\GitHub\TicTacToe-Ravens\node_modules\ts-node\src\index.ts:883:36)
at Object.compile (M:\GitHub\TicTacToe-Ravens\node_modules\ts-node\src\index.ts:1185:30)
at Module.m._compile (M:\GitHub\TicTacToe-Ravens\node_modules\ts-node\src\index.ts:1309:30)
at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Object.require.extensions.<computed> [as .ts] (M:\GitHub\TicTacToe-Ravens\node_modules\ts-node\src\index.ts:1313:12)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19) {
diagnosticText: "src/TicTacToeGame.ts(30,36): error TS2322: Type 'typeof LobbyPhase' is not assignable to type 'PhaseClass<AnyPhase>'.\r\n" +
" Types of parameters 'parent' and 'parent' are incompatible.\r\n" +
" Type 'AnyPhase | null' is not assignable to type 'null'.\r\n" +
" Type 'AnyPhase' is not assignable to type 'null'.\r\n" +
"src/TicTacToeGame.ts(30,48): error TS2322: Type 'typeof GameInProgressPhase' is not assignable to type 'PhaseClass<AnyPhase>'.\r\n" +
" Types of parameters 'parent' and 'parent' are incompatible.\r\n" +
" Type 'AnyPhase | null' is not assignable to type 'null'.\r\n" +
" Type 'AnyPhase' is not assignable to type 'null'.\r\n" +
"src/TicTacToeGame.ts(30,69): error TS2322: Type 'typeof GameEndedPhase' is not assignable to type 'PhaseClass<AnyPhase>'.\r\n" +
" Types of parameters 'parent' and 'parent' are incompatible.\r\n" +
" Type 'AnyPhase | null' is not assignable to type 'null'.\r\n" +
" Type 'AnyPhase' is not assignable to type 'null'.\r\n",
diagnosticCodes: [ 2322, 2322, 2322 ]
}
and this line:
this.setChild(LobbyPhase)
which produces a similar error:
M:\GitHub\TicTacToe-Ravens\node_modules\ts-node\src\index.ts:692
return new TSError(diagnosticText, diagnosticCodes);
^
TSError: ⨯ Unable to compile TypeScript:
src/TicTacToeGame.ts(26,19): error TS2345: Argument of type 'typeof LobbyPhase' is not assignable to parameter of type 'PhaseClass<null>'.
Types of parameters 'parent' and 'parent' are incompatible.
Type 'AnyPhase | null' is not assignable to type 'null'.
Type 'AnyPhase' is not assignable to type 'null'.
at createTSError (M:\GitHub\TicTacToe-Ravens\node_modules\ts-node\src\index.ts:692:12)
at reportTSError (M:\GitHub\TicTacToe-Ravens\node_modules\ts-node\src\index.ts:696:19)
at getOutput (M:\GitHub\TicTacToe-Ravens\node_modules\ts-node\src\index.ts:883:36)
at Object.compile (M:\GitHub\TicTacToe-Ravens\node_modules\ts-node\src\index.ts:1185:30)
at Module.m._compile (M:\GitHub\TicTacToe-Ravens\node_modules\ts-node\src\index.ts:1309:30)
at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Object.require.extensions.<computed> [as .ts] (M:\GitHub\TicTacToe-Ravens\node_modules\ts-node\src\index.ts:1313:12)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19) {
diagnosticText: "src/TicTacToeGame.ts(26,19): error TS2345: Argument of type 'typeof LobbyPhase' is not assignable to parameter of type 'PhaseClass<null>'.\r\n" +
" Types of parameters 'parent' and 'parent' are incompatible.\r\n" +
" Type 'AnyPhase | null' is not assignable to type 'null'.\r\n" +
" Type 'AnyPhase' is not assignable to type 'null'.\r\n",
diagnosticCodes: [ 2345 ]
}
Am I missing something here? It seems like the problem is that the Phase classes that we implemented in the tutorial do not inherit from or implement AnyPhase or PhaseClass.
Is this a problem with how the tutorial code was written or a fundamental problem with the core code?
Metadata
Metadata
Assignees
Labels
No labels