Skip to content
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

test: turn on types linting #10962

Merged
merged 1 commit into from Dec 15, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/helpers/helpers.options.ts
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) {
LeeLenaleee marked this conversation as resolved.
Show resolved Hide resolved
return Object.assign(Object.create(parentContext), context);
}
2 changes: 1 addition & 1 deletion types/tests/autogen.js
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
@@ -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
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
@@ -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
@@ -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
@@ -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
@@ -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
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
@@ -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
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
@@ -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
@@ -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
@@ -1,11 +1,15 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"noEmit": true
"noEmit": true,
"rootDir": "../../"
},
"include": [
"../",
"../../src/",
"../../dist/**/*.d.ts"
],
"exclude": [
"./**/*.js"
]
}