Skip to content

chore: ts options grooming #1020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sandboxes/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"react-chartjs-2": ["../src"]
}
},
"include": ["./"]
"include": ["."]
}
43 changes: 23 additions & 20 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,30 @@ export function setDatasets<
) {
const addedDatasets: ChartDataset<TType, TData>[] = [];

currentData.datasets = nextDatasets.map(nextDataset => {
// given the new set, find it's current match
const currentDataset = currentData.datasets.find(
dataset => dataset[datasetIdKey] === nextDataset[datasetIdKey]
);

// There is no original to update, so simply add new one
if (
!currentDataset ||
!nextDataset.data ||
addedDatasets.includes(currentDataset)
) {
return { ...nextDataset };
currentData.datasets = nextDatasets.map(
(nextDataset: Record<string, unknown>) => {
// given the new set, find it's current match
const currentDataset = currentData.datasets.find(
(dataset: Record<string, unknown>) =>
dataset[datasetIdKey] === nextDataset[datasetIdKey]
);

// There is no original to update, so simply add new one
if (
!currentDataset ||
!nextDataset.data ||
addedDatasets.includes(currentDataset)
) {
return { ...nextDataset } as ChartDataset<TType, TData>;
}

addedDatasets.push(currentDataset);

Object.assign(currentDataset, nextDataset);

return currentDataset;
}

addedDatasets.push(currentDataset);

Object.assign(currentDataset, nextDataset);

return currentDataset;
});
);
}

export function cloneData<
Expand Down
48 changes: 28 additions & 20 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
{
"compilerOptions": {
"outDir": "dist",
"module": "esnext",
"lib": ["dom", "esnext"],
"moduleResolution": "node",
"jsx": "react",
"sourceMap": true,
"declaration": true,
"esModuleInterop": true,
/* Type Checking */
"strict": true,
"strictBindCallApply": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
/* Modules */
"baseUrl": ".",
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
/* Emit */
"declaration": true,
"declarationMap": true,
"inlineSourceMap": true,
"outDir": "dist",
/* Interop Constraints */
"allowSyntheticDefaultImports": true,
"isolatedModules": true,
/* Language and Environment */
"jsx": "react",
"lib": [
"dom",
"esnext"
],
"target": "esnext",
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"isolatedModules": true
/* Completeness */
"skipLibCheck": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
"include": [
"src"
]
}