Question: Got this error: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.ts ( 7 0 0 9 ) Argument of type

Got this error:
'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.ts(7009)
Argument of type 'Syllable[][]' is not assignable to parameter of type 'PuzzleProps'.
Property 'initialConfig' is missing in type 'Syllable[][]' but required in type 'PuzzleProps'.ts(2345)
boundary.tsx(7,5): 'initialConfig' is declared here.
(parameter) initialConfig: Syllable[][] ;
On fololwoing code, how to resolve it:
import React,{useState} from "react";
import {PuzzleController} from "./controller";
import { Syllable } from "./model";
interface PuzzleProps {
initialConfig: Syllable[][];
}
const Puzzle: React.FC =({ initialConfig })=>{
const [puzzleController, setPuzzleController]= useState(new PuzzleController(new Puzzle(initialConfig)));
const [selected, setSelected]= useState<{ row: number, col: number }| null>(null);
const handleSyllableClick =(row: number, col: number)=>{
if (selected){
puzzleController.handleSwap(selected.row, selected.col, row, col);
setSelected(null); // Reset selection after swap
} else {
setSelected({ row, col }); // Select first syllable
}
};
const handleReset =()=>{
puzzleController.handleReset();
setSelected(null);
};
const board = puzzleController.getPuzzleState();
return (
Swaps: {puzzleController.getSwaps()}Score: {puzzleController.getScore()}Swaps: {puzzleController.getSwaps()}Score: {puzzleController.getScore()}Swaps: {puzzleController.getSwaps()}Score: {puzzleController.getScore()}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!