Skip to content

Commit 8228181

Browse files
committed
Clean up column types
1 parent d994091 commit 8228181

15 files changed

+29
-31
lines changed

src/DSVImport.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ColumnsType } from './models/column';
1+
import { ColumnType } from './models/column';
22
import { DSVImport } from '.';
33
import React from 'react';
44
import { render, fireEvent } from '@testing-library/react';
@@ -8,7 +8,7 @@ import { ValidationError } from './models/validation';
88
describe('DSVImport', () => {
99
type TestType = { forename: string; surname: string; email: string };
1010

11-
const columns: ColumnsType<TestType> = [
11+
const columns: ColumnType<TestType>[] = [
1212
{ key: 'forename', label: 'Forename' },
1313
{ key: 'surname', label: 'Surname' },
1414
{ key: 'email', label: 'Email', rules: [{ constraint: { unique: true }, message: 'Contains duplicates' }] }
@@ -17,7 +17,7 @@ describe('DSVImport', () => {
1717
interface Props<T> {
1818
onChange?: (value: T[]) => void;
1919
onValidation?: (errors: ValidationError<T>[]) => void;
20-
columns: ColumnsType<T>;
20+
columns: ColumnType<T>[];
2121
}
2222

2323
const MinimalTextareaInput: React.FC = () => {

src/DSVImport.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { PropsWithChildren, useReducer, useEffect } from 'react';
2-
import { ColumnsType } from './models/column';
2+
import { ColumnType } from './models/column';
33
import { getDSVImportContext, useDSVImport, createReducer } from './features/context';
44
import { createParserMiddleware } from './middlewares/parserMiddleware';
55
import { State } from './models/state';
@@ -33,7 +33,7 @@ const EventListener = <T extends { [key: string]: string }>(props: EventListener
3333
};
3434

3535
export interface Props<T> {
36-
columns: ColumnsType<T>;
36+
columns: ColumnType<T>[];
3737
onChange?: (value: T[]) => void;
3838
onValidation?: (errors: ValidationError<T>[]) => void;
3939
transformers?: Transformer[];

src/components/inputs/TextareaInput.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { render, fireEvent } from '@testing-library/react';
22
import { TextareaInput } from './TextareaInput';
33
import React from 'react';
4-
import { ColumnsType } from '../../models/column';
4+
import { ColumnType } from '../../models/column';
55
import { getDSVImportContext } from '../../features/context';
66
import { State } from '../../models/state';
77

88
describe('TextareaInput', () => {
9-
type TestType = {};
10-
const columns: ColumnsType<TestType> = [];
9+
type TestType = unknown;
10+
const columns: ColumnType<TestType>[] = [];
1111
const state: State<TestType> = { columns };
1212
const Context = getDSVImportContext<TestType>();
1313

src/components/previews/TablePreview.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { render } from '@testing-library/react';
22
import React from 'react';
3-
import { ColumnsType } from '../../models/column';
3+
import { ColumnType } from '../../models/column';
44
import { TablePreview } from './TablePreview';
55
import { State } from '../../models/state';
66
import { getDSVImportContext } from '../../features/context';
77

88
describe('TablePreview', () => {
99
type TestType = { forename: string; surname: string; email: string };
10-
const columns: ColumnsType<TestType> = [
10+
const columns: ColumnType<TestType>[] = [
1111
{ key: 'forename', label: 'Forename' },
1212
{ key: 'surname', label: 'Surname' },
1313
{ key: 'email', label: 'Email' }

src/features/context.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useContext } from 'react';
44
import { renderHook } from '@testing-library/react-hooks';
55

66
describe('context', () => {
7-
type TestType = {};
7+
type TestType = unknown;
88
const defaultState: State<TestType> = { columns: [] };
99

1010
it('should reduce raw data action to state', () => {

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function DSVImport<T extends { [key: string]: string }>(props: PropsWithC
1010
DSVImport.TextareaInput = TextareaInput;
1111
DSVImport.TablePreview = TablePreview;
1212

13-
export { ColumnType, ColumnsType } from './models/column';
13+
export { ColumnType } from './models/column';
1414
export { useDSVImport } from './features/context';
1515
export { Rule } from './models/rule';
1616
export { Transformer } from './models/transformer';

src/middlewares/middleware.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { ColumnsType } from '../models/column';
1+
import { ColumnType } from '../models/column';
22
import { State } from '../models/state';
33
import { applyMiddlewares } from './middleware';
44

55
describe('middleware', () => {
66
type TestType = { forename: string; surname: string; email: string };
7-
const columns: ColumnsType<TestType> = [
7+
const columns: ColumnType<TestType>[] = [
88
{ key: 'forename', label: 'Forename' },
99
{ key: 'surname', label: 'Surname' },
1010
{ key: 'email', label: 'Email' }

src/middlewares/parserMiddleware.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { createParserMiddleware } from './parserMiddleware';
22
import { State } from '../models/state';
3-
import { ColumnsType } from '../models/column';
3+
import { ColumnType } from '../models/column';
44
import { Delimiter } from '../models/delimiter';
55

66
describe('parserMiddleware', () => {
77
type TestType = { forename: string; surname: string; email: string };
8-
const columns: ColumnsType<TestType> = [
8+
const columns: ColumnType<TestType>[] = [
99
{ key: 'forename', label: 'Forename' },
1010
{ key: 'surname', label: 'Surname' },
1111
{ key: 'email', label: 'Email' }

src/middlewares/parserMiddleware.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { State } from '../models/state';
22
import { Delimiter } from '../models/delimiter';
3-
import { ColumnsType } from '../models/column';
3+
import { ColumnType } from '../models/column';
44
import { Dispatch } from 'react';
55
import { Actions } from '../models/actions';
66

@@ -17,7 +17,7 @@ const detectDelimiterFromValue = (value: string, defaultDelimiter: Delimiter) =>
1717
return currentDelimiter;
1818
};
1919

20-
const parseData = <T>(value: string, columns: ColumnsType<T>, delimiter: Delimiter) => {
20+
const parseData = <T>(value: string, columns: ColumnType<T>[], delimiter: Delimiter) => {
2121
const lines = value.split('\n');
2222
return lines.map((line) => {
2323
const lineValues = line.split(delimiter);

src/middlewares/transformerMiddleware.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { ColumnsType } from '../models/column';
1+
import { ColumnType } from '../models/column';
22
import { State } from '../models/state';
33
import { createTransformerMiddleware } from './transformerMiddleware';
44

55
describe('validatorMiddleware', () => {
66
type TestType = { forename: string; surname: string; email: string };
7-
const defaultColumns: ColumnsType<TestType> = [
7+
const defaultColumns: ColumnType<TestType>[] = [
88
{ key: 'forename', label: 'Forename' },
99
{ key: 'surname', label: 'Surname' },
1010
{ key: 'email', label: 'Email' }

0 commit comments

Comments
 (0)