More typecheck, lint fixes

This commit is contained in:
Greg Shuflin 2021-09-12 21:35:46 -07:00
parent cf975330f4
commit 146b8126a2

View File

@ -44,20 +44,34 @@ function makeRequest(queryString, jsonHandler) {
});
}
const Entry = (props) => {
interface EntryProps {
conlang: Conlang;
entry: SaiEntryProps | JutEntryProps;
key: string;
}
const Entry = (props: EntryProps) => {
const {conlang} = props;
if (conlang === Conlang.Saimiar) {
return <SaiEntry entry={ props.entry } />;
return <SaiEntry entry={ props.entry as SaiEntryProps } />;
}
if (conlang === Conlang.Juteyuji) {
return <JutEntry entry={ props.entry } />;
return <JutEntry entry={ props.entry as JutEntryProps } />;
}
return <div>Conlang { conlang } not yet supported</div>;
};
const SaiEntry = (props) => {
interface SaiEntryProps {
id: number;
sai: string;
eng: string;
syn_category: string;
morph_type: string;
}
const SaiEntry = (props: {entry: SaiEntryProps}) => {
const {entry} = props;
const synCategory = entry.syn_category;
const isNominal = synCategory === 'nominal';
@ -75,7 +89,15 @@ const SaiEntry = (props) => {
);
};
const JutEntry = (props) => {
interface JutEntryProps {
id: number;
jut: string;
eng: string;
syn_category: string;
gender: string;
}
const JutEntry = (props: {entry: JutEntryProps}) => {
const {entry} = props;
console.log(props);
@ -106,7 +128,14 @@ function formatMorphology(entry) {
</span>);
}
const Results = (props) => {
interface ResultsProps {
searchResults: any;
searchTerm: string;
conlang: Conlang;
direction: SearchDirection;
}
const Results = (props: ResultsProps) => {
const content = () => {
const {conlang} = props;
const num = props.searchResults.length;