diff --git a/sandboxes/tsconfig.json b/sandboxes/tsconfig.json index 1acab88d8..890f59b3e 100644 --- a/sandboxes/tsconfig.json +++ b/sandboxes/tsconfig.json @@ -1,9 +1,10 @@ { "extends": "../tsconfig.json", "compilerOptions": { + "baseUrl": ".", "paths": { "react-chartjs-2": ["../src"] } }, - "include": ["./"] + "include": ["."] } diff --git a/src/utils.ts b/src/utils.ts index 53c44a895..c7a8d3e89 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -50,27 +50,30 @@ export function setDatasets< ) { const addedDatasets: ChartDataset[] = []; - 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) => { + // given the new set, find it's current match + const currentDataset = currentData.datasets.find( + (dataset: Record) => + 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; + } + + addedDatasets.push(currentDataset); + + Object.assign(currentDataset, nextDataset); + + return currentDataset; } - - addedDatasets.push(currentDataset); - - Object.assign(currentDataset, nextDataset); - - return currentDataset; - }); + ); } export function cloneData< diff --git a/tsconfig.json b/tsconfig.json index c48a91b60..1b80ef926 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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" + ] }