Given the following types:
export type OrderHistoryTableProps = {
data: OrderRow[];
noDataText?: string;
} & SortParams &
FilterParams &
SearchParams;
type SortParams = AllOrNone<{
sorting: SortingState;
onSortChange: (state: SortingState) => void;
}>;
type FilterParams = AllOrNone<{
filter: ColumnFiltersState;
onFilterChange: (state: ColumnFiltersState) => void;
}>;
type SearchParams = AllOrNone<{
search: string;
onSearchChange: (value: string) => void;
}>;
function OrderHistoryTable({
data,
noDataText = "No orders to display!",
onFilterChange,
onSortChange,
sorting,
filter,
search,
onSearchChange,
}: OrderHistoryTableProps): JSX.Element {
...
}
I seem to be getting a TS7006 error when calling the component and defining the onSearchChange function in-line:
<OrderHistoryTable
data={rowData}
{...{ sorting, filter, search }}
onSortChange={onSortChange}
onFilterChange={setFilter}
onSearchChange={(value) => setSearch(value)} // TS7006: Parameter 'value' implicitly has an 'any' type.
/>
However, onSearchChange is explicitely defined as onSearchChange: (value: string) => void; in the prop type. This worked fine in Typescript 4.9.5, but in 5.1.6 this seems to be an error. Can anyone help me understand why this is occurring?
tsconfig:
// apps/web/tsconfig.json
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"target": "ES6",
"lib": ["dom", "dom.iterable", "ES6"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "CommonJS",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"jsxImportSource": "@emotion/react",
"noEmitOnError": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"sourceMap": true,
"baseUrl": "./",
"composite": true,
"outDir": "./dist",
"paths": {
"@/*": ["./*"],
"@components/*": ["./src/components/*"],
"@layouts/*": ["./src/layouts/*"],
"@codegen/*": ["./@types/codegen/*"]
}
},
"ts-node": {
"compilerOptions": {
"isolatedModules": false,
"module": "CommonJS"
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"./.storybook/*",
"public/*",
"**/*.js"
],
"exclude": ["node_modules", "cypress"]
}
// <root>/tsconfig.json
{
"extends": "@tsconfig/node16/tsconfig.json",
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Node 16",
"compilerOptions": {
"allowJs": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitAny": true,
"noEmitOnError": true
},
"references": [
{ "path": "apps/web" },
{
"path": "apps/server"
}
],
"exclude": ["node_modules"]
}