More types

This commit is contained in:
Greg Shuflin 2021-09-12 02:07:29 -07:00
parent a9703a9529
commit 44156694a2
3 changed files with 91 additions and 78 deletions

View File

@ -20,6 +20,7 @@ module.exports = {
"@typescript-eslint"
],
rules: {
"arrow-parens": ["error", "always"]
"arrow-parens": ["error", "always"],
"indent": ["error", 4]
},
};

View File

@ -11,7 +11,8 @@
"build": "parcel build index.html --no-source-maps",
"prebuild": "yarn run typecheck",
"typecheck": "tsc --noEmit",
"lint": "eslint src/*"
"lint": "eslint src/*",
"lint-fix": "eslint src/* --fix"
},
"devDependencies": {
"@parcel/transformer-image": "2.0.0-rc.0",

View File

@ -1,6 +1,17 @@
const rootEndingPair = (str) => ({root: str.slice(0, -1), ending: str.slice(-1)});
function declineSaimiar(entry) {
type SaimiarDeclension = {
abs: string;
erg: string;
adp: string;
all: string;
loc: string;
ell: string;
inst: string;
rel: string;
};
function declineSaimiar(entry): SaimiarDeclension {
const split = entry.sai.split(' ');
const sai = split.at(-1);
const morph = entry.morph_type;
@ -26,7 +37,7 @@ function declineSaimiar(entry) {
return null;
}
function vowelDeclension(sai: string) {
function vowelDeclension(sai: string): SaimiarDeclension {
const {root, ending} = rootEndingPair(sai);
const adpEnding = ending === 'u' ? 'ys' : `${ending}s`;
@ -42,7 +53,7 @@ function vowelDeclension(sai: string) {
};
}
function aiDeclension(sai: string) {
function aiDeclension(sai: string): SaimiarDeclension {
const {root, ending} = rootEndingPair(sai);
return {
abs: `${root}${ending}`,
@ -56,7 +67,7 @@ function aiDeclension(sai: string) {
};
}
function consonantDeclension(sai: string) {
function consonantDeclension(sai: string): SaimiarDeclension {
const split = rootEndingPair(sai);
const root = split.ending === 'ø' ? split.root : sai;
const absFinal = split.ending === 'ø' ? 'ø' : '';
@ -75,7 +86,7 @@ function consonantDeclension(sai: string) {
const vowels = ['a', 'e', 'ê', 'i', 'o', 'ô', 'u', 'y'];
function initalDeclension(sai: string) {
function initalDeclension(sai: string): SaimiarDeclension {
const initial = sai.slice(0, 1);
const root = sai.slice(1);
@ -96,4 +107,4 @@ function initalDeclension(sai: string) {
};
}
export {declineSaimiar};
export {declineSaimiar, SaimiarDeclension};