Skip to content

Commit ae5cc99

Browse files
authored
chore: ts options grooming (#1020)
1 parent 99e7cab commit ae5cc99

File tree

3 files changed

+53
-41
lines changed

3 files changed

+53
-41
lines changed

sandboxes/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"extends": "../tsconfig.json",
33
"compilerOptions": {
4+
"baseUrl": ".",
45
"paths": {
56
"react-chartjs-2": ["../src"]
67
}
78
},
8-
"include": ["./"]
9+
"include": ["."]
910
}

src/utils.ts

+23-20
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,30 @@ export function setDatasets<
5050
) {
5151
const addedDatasets: ChartDataset<TType, TData>[] = [];
5252

53-
currentData.datasets = nextDatasets.map(nextDataset => {
54-
// given the new set, find it's current match
55-
const currentDataset = currentData.datasets.find(
56-
dataset => dataset[datasetIdKey] === nextDataset[datasetIdKey]
57-
);
58-
59-
// There is no original to update, so simply add new one
60-
if (
61-
!currentDataset ||
62-
!nextDataset.data ||
63-
addedDatasets.includes(currentDataset)
64-
) {
65-
return { ...nextDataset };
53+
currentData.datasets = nextDatasets.map(
54+
(nextDataset: Record<string, unknown>) => {
55+
// given the new set, find it's current match
56+
const currentDataset = currentData.datasets.find(
57+
(dataset: Record<string, unknown>) =>
58+
dataset[datasetIdKey] === nextDataset[datasetIdKey]
59+
);
60+
61+
// There is no original to update, so simply add new one
62+
if (
63+
!currentDataset ||
64+
!nextDataset.data ||
65+
addedDatasets.includes(currentDataset)
66+
) {
67+
return { ...nextDataset } as ChartDataset<TType, TData>;
68+
}
69+
70+
addedDatasets.push(currentDataset);
71+
72+
Object.assign(currentDataset, nextDataset);
73+
74+
return currentDataset;
6675
}
67-
68-
addedDatasets.push(currentDataset);
69-
70-
Object.assign(currentDataset, nextDataset);
71-
72-
return currentDataset;
73-
});
76+
);
7477
}
7578

7679
export function cloneData<

tsconfig.json

+28-20
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
11
{
22
"compilerOptions": {
3-
"outDir": "dist",
4-
"module": "esnext",
5-
"lib": ["dom", "esnext"],
6-
"moduleResolution": "node",
7-
"jsx": "react",
8-
"sourceMap": true,
9-
"declaration": true,
10-
"esModuleInterop": true,
3+
/* Type Checking */
4+
"strict": true,
5+
"strictBindCallApply": true,
6+
"noFallthroughCasesInSwitch": true,
7+
"noImplicitOverride": true,
118
"noImplicitReturns": true,
12-
"noImplicitThis": true,
13-
"noImplicitAny": true,
14-
"strictNullChecks": true,
15-
"suppressImplicitAnyIndexErrors": true,
169
"noUnusedLocals": true,
1710
"noUnusedParameters": true,
11+
/* Modules */
12+
"baseUrl": ".",
13+
"module": "esnext",
14+
"moduleResolution": "node",
15+
"resolveJsonModule": true,
16+
/* Emit */
17+
"declaration": true,
18+
"declarationMap": true,
19+
"inlineSourceMap": true,
20+
"outDir": "dist",
21+
/* Interop Constraints */
1822
"allowSyntheticDefaultImports": true,
23+
"isolatedModules": true,
24+
/* Language and Environment */
25+
"jsx": "react",
26+
"lib": [
27+
"dom",
28+
"esnext"
29+
],
1930
"target": "esnext",
20-
"allowJs": true,
21-
"skipLibCheck": true,
22-
"strict": true,
23-
"forceConsistentCasingInFileNames": true,
24-
"resolveJsonModule": true,
25-
"isolatedModules": true
31+
/* Completeness */
32+
"skipLibCheck": true
2633
},
27-
"include": ["src"],
28-
"exclude": ["node_modules", "dist"]
34+
"include": [
35+
"src"
36+
]
2937
}

0 commit comments

Comments
 (0)