Skip to content

Commit 185bb97

Browse files
authored
fix: turn on types linting (chartjs#10962)
1 parent 9d51e99 commit 185bb97

14 files changed

+21
-16
lines changed

src/helpers/helpers.options.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ export function _addGrace(minmax: { min: number; max: number; }, grace: number |
203203
* @param context
204204
* @returns
205205
*/
206-
export function createContext<P extends T, T extends object>(parentContext: P, context: T): P extends null ? T : P & T {
206+
export function createContext<T extends object>(parentContext: null, context: T): T;
207+
export function createContext<T extends object, P extends T>(parentContext: P, context: T): P & T;
208+
export function createContext(parentContext: object, context: object) {
207209
return Object.assign(Object.create(parentContext), context);
208210
}

types/tests/autogen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let fd;
1010
try {
1111
const fn = path.resolve(__dirname, 'autogen_helpers.ts');
1212
fd = fs.openSync(fn, 'w+');
13-
fs.writeSync(fd, 'import * as helpers from \'../../dist/helpers\';\n\n');
13+
fs.writeSync(fd, 'import * as helpers from \'../../dist/helpers/index.js\';\n\n');
1414

1515
fs.writeSync(fd, 'const testKeys: unknown[] = [];\n');
1616
for (const key of Object.keys(helpers)) {

types/tests/dataset_null_data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChartDataset } from '../../src/types.js';
1+
import type { ChartDataset } from '../../src/types.js';
22

33
const dataset: ChartDataset = {
44
data: [10, null, 20],

types/tests/extensions/scale.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class TestScale<O extends TestScaleOptions = TestScaleOptions> extends Sc
1717
}
1818
}
1919

20-
declare module '../..' {
20+
declare module '../../index.js' {
2121
interface CartesianScaleTypeRegistry {
2222
test: {
2323
options: TestScaleOptions

types/tests/interaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
Chart, ChartData, ChartConfiguration, Element
3-
} from '../../src/types';
3+
} from '../../src/types.js';
44

55
const data: ChartData<'line'> = { datasets: [] };
66
const chartItem = 'item';

types/tests/layout/position.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LayoutPosition } from '../../../src/types.js';
1+
import type { LayoutPosition } from '../../../src/types.js';
22

33
const left: LayoutPosition = 'left';
44
const right: LayoutPosition = 'right';

types/tests/parsed.data.type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ParsedDataType } from '../../src/types.js';
1+
import type { ParsedDataType } from '../../src/types.js';
22

33
interface test {
44
pie: ParsedDataType<'pie'>,

types/tests/plugins/plugin.filler/fill_target_true.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChartDataset } from '../../../../src/types.js';
1+
import type { ChartDataset } from '../../../../src/types.js';
22

33
const dataset: ChartDataset = {
44
data: [],

types/tests/register.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
Title,
2525
SubTitle,
2626
Tooltip
27-
} from '../../src/types';
27+
} from '../../src/types.js';
2828

2929
Chart.register(
3030
ArcElement,

types/tests/scales/chart_options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChartOptions } from '../../../src/types.js';
1+
import type { ChartOptions } from '../../../src/types.js';
22

33
const chartOptions: ChartOptions<'line'> = {
44
scales: {

types/tests/scales/options.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ const chart = new Chart('test', {
1919
unit: 'year'
2020
},
2121
ticks: {
22-
stepSzie: 1
22+
stepSize: 1
2323
}
2424
},
2525
x1: {
26-
// @ts-expect-error Type '"linear"' is not assignable to type '"timeseries" | undefined'.
2726
type: 'linear',
27+
// @ts-expect-error 'time' does not exist in 'linear' options
2828
time: {
29-
// @ts-expect-error Type 'string' is not assignable to type 'false | "millisecond" | "second" | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year" | undefined'.
3029
unit: 'year'
3130
}
3231
},

types/tests/scriptable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChartType, Scriptable, ScriptableContext } from '../../src/types.js';
1+
import type { ChartType, Scriptable, ScriptableContext } from '../../src/types.js';
22

33
interface test {
44
pie?: Scriptable<number, ScriptableContext<'pie'>>,

types/tests/scriptable_core_chart_options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChartConfiguration } from '../../src/types.js';
1+
import type { ChartConfiguration } from '../../src/types.js';
22

33
const getConfig = (): ChartConfiguration<'bar'> => {
44
return {

types/tests/tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
{
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
4-
"noEmit": true
4+
"noEmit": true,
5+
"rootDir": "../../"
56
},
67
"include": [
78
"../",
89
"../../src/",
910
"../../dist/**/*.d.ts"
11+
],
12+
"exclude": [
13+
"./**/*.js"
1014
]
1115
}

0 commit comments

Comments
 (0)