fix: turn on types linting (#10962)

This commit is contained in:
Dan Onoshko 2022-12-16 03:09:14 +04:00 committed by GitHub
parent 9d51e99e80
commit 185bb97d2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 21 additions and 16 deletions

View 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);
}

View 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)) {

View 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],

View 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

View 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';

View 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';

View File

@ -1,4 +1,4 @@
import { ParsedDataType } from '../../src/types.js';
import type { ParsedDataType } from '../../src/types.js';
interface test {
pie: ParsedDataType<'pie'>,

View File

@ -1,4 +1,4 @@
import { ChartDataset } from '../../../../src/types.js';
import type { ChartDataset } from '../../../../src/types.js';
const dataset: ChartDataset = {
data: [],

View File

@ -24,7 +24,7 @@ import {
Title,
SubTitle,
Tooltip
} from '../../src/types';
} from '../../src/types.js';
Chart.register(
ArcElement,

View File

@ -1,4 +1,4 @@
import { ChartOptions } from '../../../src/types.js';
import type { ChartOptions } from '../../../src/types.js';
const chartOptions: ChartOptions<'line'> = {
scales: {

View 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'
}
},

View 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'>>,

View File

@ -1,4 +1,4 @@
import { ChartConfiguration } from '../../src/types.js';
import type { ChartConfiguration } from '../../src/types.js';
const getConfig = (): ChartConfiguration<'bar'> => {
return {

View File

@ -1,11 +1,15 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"noEmit": true
"noEmit": true,
"rootDir": "../../"
},
"include": [
"../",
"../../src/",
"../../dist/**/*.d.ts"
],
"exclude": [
"./**/*.js"
]
}