Skip to content

Commit

Permalink
fix: turn on types linting (#10962)
Browse files Browse the repository at this point in the history
  • Loading branch information
dangreen authored Dec 15, 2022
1 parent 9d51e99 commit 185bb97
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/helpers/helpers.options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion types/tests/autogen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion types/tests/dataset_null_data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChartDataset } from '../../src/types.js';
import type { ChartDataset } from '../../src/types.js';

const dataset: ChartDataset = {
data: [10, null, 20],
Expand Down
2 changes: 1 addition & 1 deletion types/tests/extensions/scale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class TestScale<O extends TestScaleOptions = TestScaleOptions> extends Sc
}
}

declare module '../..' {
declare module '../../index.js' {
interface CartesianScaleTypeRegistry {
test: {
options: TestScaleOptions
Expand Down
2 changes: 1 addition & 1 deletion types/tests/interaction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
Chart, ChartData, ChartConfiguration, Element
} from '../../src/types';
} from '../../src/types.js';

const data: ChartData<'line'> = { datasets: [] };
const chartItem = 'item';
Expand Down
2 changes: 1 addition & 1 deletion types/tests/layout/position.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion types/tests/parsed.data.type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ParsedDataType } from '../../src/types.js';
import type { ParsedDataType } from '../../src/types.js';

interface test {
pie: ParsedDataType<'pie'>,
Expand Down
2 changes: 1 addition & 1 deletion types/tests/plugins/plugin.filler/fill_target_true.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChartDataset } from '../../../../src/types.js';
import type { ChartDataset } from '../../../../src/types.js';

const dataset: ChartDataset = {
data: [],
Expand Down
2 changes: 1 addition & 1 deletion types/tests/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
Title,
SubTitle,
Tooltip
} from '../../src/types';
} from '../../src/types.js';

Chart.register(
ArcElement,
Expand Down
2 changes: 1 addition & 1 deletion types/tests/scales/chart_options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChartOptions } from '../../../src/types.js';
import type { ChartOptions } from '../../../src/types.js';

const chartOptions: ChartOptions<'line'> = {
scales: {
Expand Down
5 changes: 2 additions & 3 deletions types/tests/scales/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
},
Expand Down
2 changes: 1 addition & 1 deletion types/tests/scriptable.ts
Original file line number Diff line number Diff line change
@@ -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'>>,
Expand Down
2 changes: 1 addition & 1 deletion types/tests/scriptable_core_chart_options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChartConfiguration } from '../../src/types.js';
import type { ChartConfiguration } from '../../src/types.js';

const getConfig = (): ChartConfiguration<'bar'> => {
return {
Expand Down
6 changes: 5 additions & 1 deletion types/tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"noEmit": true
"noEmit": true,
"rootDir": "../../"
},
"include": [
"../",
"../../src/",
"../../dist/**/*.d.ts"
],
"exclude": [
"./**/*.js"
]
}

0 comments on commit 185bb97

Please sign in to comment.