]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
fix: turn on types linting (#10962)
authorDan Onoshko <danon0404@gmail.com>
Thu, 15 Dec 2022 23:09:14 +0000 (03:09 +0400)
committerGitHub <noreply@github.com>
Thu, 15 Dec 2022 23:09:14 +0000 (01:09 +0200)
14 files changed:
src/helpers/helpers.options.ts
types/tests/autogen.js
types/tests/dataset_null_data.ts
types/tests/extensions/scale.ts
types/tests/interaction.ts
types/tests/layout/position.ts
types/tests/parsed.data.type.ts
types/tests/plugins/plugin.filler/fill_target_true.ts
types/tests/register.ts
types/tests/scales/chart_options.ts
types/tests/scales/options.ts
types/tests/scriptable.ts
types/tests/scriptable_core_chart_options.ts
types/tests/tsconfig.json

index 3ee1b55f21aae04575d58b794efb83911fa1edc6..0cd38e4d7d6d8f418e4563e850744a24a8bf6bc4 100644 (file)
@@ -203,6 +203,8 @@ export function _addGrace(minmax: { min: number; max: number; }, grace: number |
  * @param context
  * @returns
  */
-export function createContext<P extends T, T extends object>(parentContext: P, context: T): P extends null ? T : P & T {
+export function createContext<T extends object>(parentContext: null, context: T): T;
+export function createContext<T extends object, P extends T>(parentContext: P, context: T): P & T;
+export function createContext(parentContext: object, context: object) {
   return Object.assign(Object.create(parentContext), context);
 }
index e347983413626f8dc9e53cb034334626da34c87e..cd8768a7330c532b005afdd76336c90a2c92f1df 100644 (file)
@@ -10,7 +10,7 @@ let fd;
 try {
   const fn = path.resolve(__dirname, 'autogen_helpers.ts');
   fd = fs.openSync(fn, 'w+');
-  fs.writeSync(fd, 'import * as helpers from \'../../dist/helpers\';\n\n');
+  fs.writeSync(fd, 'import * as helpers from \'../../dist/helpers/index.js\';\n\n');
 
   fs.writeSync(fd, 'const testKeys: unknown[] = [];\n');
   for (const key of Object.keys(helpers)) {
index b63344db17d8c0d5320663500da23004f2d8b2cd..9b02635ad5b156c49e98f633620a762f6a177347 100644 (file)
@@ -1,4 +1,4 @@
-import { ChartDataset } from '../../src/types.js';
+import type { ChartDataset } from '../../src/types.js';
 
 const dataset: ChartDataset = {
   data: [10, null, 20],
index c02871c4eb8eb9d77f7ae1c73187d7b2fe329ba5..712b3f15ca5160052f4fea5b3364656c57fd3cf1 100644 (file)
@@ -17,7 +17,7 @@ export class TestScale<O extends TestScaleOptions = TestScaleOptions> extends Sc
   }
 }
 
-declare module '../..' {
+declare module '../../index.js' {
   interface CartesianScaleTypeRegistry {
     test: {
       options: TestScaleOptions
index 46de29b6c4d3ef9b717ef4485fcde2b2c901cc44..234a98bda98c7b3b26a52623a3cf26a316a227f8 100644 (file)
@@ -1,6 +1,6 @@
 import {
   Chart, ChartData, ChartConfiguration, Element
-} from '../../src/types';
+} from '../../src/types.js';
 
 const data: ChartData<'line'> = { datasets: [] };
 const chartItem = 'item';
index cc0e8be67eefaf101ab2e96a7053c5262b343c0a..10233d681a7638724033c9e2a82f3a925fc2c1a4 100644 (file)
@@ -1,4 +1,4 @@
-import { LayoutPosition } from '../../../src/types.js';
+import type { LayoutPosition } from '../../../src/types.js';
 
 const left: LayoutPosition = 'left';
 const right: LayoutPosition = 'right';
index a4de0aaf3059d22dd6a88b37a90020f01f9ce3c5..86f34c102a584795ed8b36158fa7993ed6d6e091 100644 (file)
@@ -1,4 +1,4 @@
-import { ParsedDataType } from '../../src/types.js';
+import type { ParsedDataType } from '../../src/types.js';
 
 interface test {
   pie: ParsedDataType<'pie'>,
index 6e9553da9d79e5ac074b94988cbe7c3b3969d879..057dbecf7df92a9208b2800e3cc9631d7fe9764e 100644 (file)
@@ -1,4 +1,4 @@
-import { ChartDataset } from '../../../../src/types.js';
+import type { ChartDataset } from '../../../../src/types.js';
 
 const dataset: ChartDataset = {
   data: [],
index ddc5f5e24dc66d7d11f1b621a0fb23fcde6fed3c..e844ab8a4a72b6a27dec933b68fdc5c120a7f903 100644 (file)
@@ -24,7 +24,7 @@ import {
   Title,
   SubTitle,
   Tooltip
-} from '../../src/types';
+} from '../../src/types.js';
 
 Chart.register(
   ArcElement,
index 8694aa9f7e3446f22a1c3bc0165da80a2ac372a6..fc5c20e688691e9ef227c824a1d0ea6c8f97e83e 100644 (file)
@@ -1,4 +1,4 @@
-import { ChartOptions } from '../../../src/types.js';
+import type { ChartOptions } from '../../../src/types.js';
 
 const chartOptions: ChartOptions<'line'> = {
   scales: {
index 086435b6e7bd014e5bc958994ed97a6d33893e86..2b186d79917592acf45dbbcdb78484536dc74420 100644 (file)
@@ -19,14 +19,13 @@ const chart = new Chart('test', {
           unit: 'year'
         },
         ticks: {
-          stepSzie: 1
+          stepSize: 1
         }
       },
       x1: {
-        // @ts-expect-error Type '"linear"' is not assignable to type '"timeseries" | undefined'.
         type: 'linear',
+        // @ts-expect-error 'time' does not exist in 'linear' options
         time: {
-          // @ts-expect-error Type 'string' is not assignable to type 'false | "millisecond" | "second" | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year" | undefined'.
           unit: 'year'
         }
       },
index 607fe8cffb4f1bc93cd41cc5f349e4cf0c6e6c61..89c40d894b8e66f666d0c655b9c500e7a0606454 100644 (file)
@@ -1,4 +1,4 @@
-import { ChartType, Scriptable, ScriptableContext } from '../../src/types.js';
+import type { ChartType, Scriptable, ScriptableContext } from '../../src/types.js';
 
 interface test {
   pie?: Scriptable<number, ScriptableContext<'pie'>>,
index 87b3bbe5e081d9e3f62746e19300a80ce54b8740..b638505525c90bcd9c7e74e2e5570afac6ffd27e 100644 (file)
@@ -1,4 +1,4 @@
-import { ChartConfiguration } from '../../src/types.js';
+import type { ChartConfiguration } from '../../src/types.js';
 
 const getConfig = (): ChartConfiguration<'bar'> => {
   return {
index 48c8ae8c3608339c4a414039709b1489aa3de4c1..438b3b48fd06077ad6c88ec4df9e38033f80eea2 100644 (file)
@@ -1,11 +1,15 @@
 {
   "extends": "../../tsconfig.json",
   "compilerOptions": {
-    "noEmit": true
+    "noEmit": true,
+    "rootDir": "../../"
   },
   "include": [
     "../",
     "../../src/",
     "../../dist/**/*.d.ts"
+  ],
+  "exclude": [
+    "./**/*.js"
   ]
 }