Skip to content

Commit 87dd2c4

Browse files
committed
Re-use validator's types
1 parent fa71af3 commit 87dd2c4

File tree

6 files changed

+22
-52
lines changed

6 files changed

+22
-52
lines changed

views/interactivity/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
22
import './App.css';
33
import { DictionaryApi } from './components/api/dictionary';
44
import SearchBox from './components/search-box/SearchBox';
5-
import { DictionaryEntry } from './types';
5+
import { DictionaryEntry } from './components/types';
66

77
function App() {
88
const [bearerToken, setBearerToken] = useState<string | null>(null);

views/interactivity/src/components/api/dictionary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Utils } from '../../lib/utils';
2-
import { DictionaryEntry } from '../../types';
32
import { AuthorizationError } from '../../error/authorization';
43
import { InternalServerError } from '../../error/server';
54
import { NotFoundError } from '../../error/not-found';
65
import { lexicalEntrySchema, responseSchema } from './dictionary.validator';
76
import { InvalidResponseError } from '../../error/invalid-response';
7+
import { DictionaryEntry } from '../types';
88

99
export class DictionaryApi {
1010
private token: string;

views/interactivity/src/components/api/dictionary.validator.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { array, date, InferType, number, object, string } from 'yup';
1+
import { array, date, number, object, string } from 'yup';
22

33
export const responseSchema = object({
44
dictionaryWord: object({
@@ -41,14 +41,3 @@ export const lexicalEntrySchema = object({
4141
meanings: array().of(meaningSchema).required(),
4242
}).required(),
4343
});
44-
45-
export type DictionaryWord = InferType<typeof lexicalEntrySchema>;
46-
export type AccessSummary = InferType<typeof responseSchema>['accessSummary'];
47-
export type DictionaryEntry = {
48-
dictionaryWord: DictionaryWord;
49-
accessSummary: AccessSummary;
50-
};
51-
export type RegionPronunciation = InferType<typeof ipaListingSchema>;
52-
export type IPAListings = DictionaryWord['entry']['ipaListings'];
53-
export type MeaningEnty = InferType<typeof meaningEntrySchema>;
54-
export type Meaning = InferType<typeof meaningSchema>;

views/interactivity/src/components/search-box/SearchBox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React, { useState } from 'react';
2-
import { DictionaryEntry } from '../../types';
32
import { DictionaryApi } from '../api/dictionary';
43
import './SearchBox.css';
54
import { NotFoundError } from '../../error/not-found';
5+
import { DictionaryEntry } from '../types';
66

77
type Props = {
88
dictionaryApi: DictionaryApi;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {
2+
lexicalEntrySchema,
3+
responseSchema,
4+
ipaListingSchema,
5+
meaningEntrySchema,
6+
meaningSchema,
7+
} from './api/dictionary.validator';
8+
9+
export type DictionaryWord = InferType<typeof lexicalEntrySchema>;
10+
export type AccessSummary = InferType<typeof responseSchema>['accessSummary'];
11+
export type DictionaryEntry = {
12+
dictionaryWord: DictionaryWord;
13+
accessSummary: AccessSummary;
14+
};
15+
export type RegionPronunciation = InferType<typeof ipaListingSchema>;
16+
export type IPAListings = DictionaryWord['entry']['ipaListings'];
17+
export type MeaningEnty = InferType<typeof meaningEntrySchema>;
18+
export type Meaning = InferType<typeof meaningSchema>;

views/interactivity/src/types.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)