Skip to content

Commit f62463d

Browse files
authored
🤖 Merge PR DefinitelyTyped#74276 Adds Kotobee Definitions by @Bashamega
1 parent b4d5a51 commit f62463d

File tree

5 files changed

+166
-0
lines changed

5 files changed

+166
-0
lines changed

types/kotobee/.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!**/*.d.ts
3+
!**/*.d.cts
4+
!**/*.d.mts
5+
!**/*.d.*.ts

types/kotobee/index.d.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
type LanguageCode =
2+
| "ar"
3+
| "de"
4+
| "es"
5+
| "hu"
6+
| "jp"
7+
| "ms"
8+
| "no"
9+
| "pt"
10+
| "ru"
11+
| "tr"
12+
| "zh-tw"
13+
| "cy"
14+
| "en"
15+
| "fr"
16+
| "it"
17+
| "ko"
18+
| "nl"
19+
| "pl"
20+
| "ro"
21+
| "sw"
22+
| "zh-cn"
23+
| "zh";
24+
25+
type Directions = "ltr" | "rtl";
26+
27+
interface KotobeeReader {
28+
/**
29+
* Clears cached local data used by the reader.
30+
*/
31+
clearCache: () => void;
32+
33+
/**
34+
* Clears all event listeners attached by the reader.
35+
*/
36+
clearListeners: () => void;
37+
38+
/**
39+
* Clears remotely fetched data (e.g., cloud sync, remote storage).
40+
*/
41+
clearRemoteData: () => void;
42+
43+
/**
44+
* Sets the active UI language of the reader.
45+
*/
46+
setLanguage: (language: LanguageCode) => void;
47+
48+
/**
49+
* Sets reading direction (left-to-right or right-to-left).
50+
*/
51+
setDirection: (direction: Directions) => void;
52+
}
53+
54+
// Declare the global variable
55+
declare const Kotobee: KotobeeReader;

types/kotobee/kotobee-tests.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// ------------------- Correct usage -------------------
2+
const validLanguages: LanguageCode[] = [
3+
"ar",
4+
"de",
5+
"es",
6+
"hu",
7+
"jp",
8+
"ms",
9+
"no",
10+
"pt",
11+
"ru",
12+
"tr",
13+
"zh-tw",
14+
"cy",
15+
"en",
16+
"fr",
17+
"it",
18+
"ko",
19+
"nl",
20+
"pl",
21+
"ro",
22+
"sw",
23+
"zh-cn",
24+
"zh",
25+
];
26+
27+
const validDirections: Directions[] = ["ltr", "rtl"];
28+
29+
// Test all valid languages
30+
validLanguages.forEach(lang => Kotobee.setLanguage(lang));
31+
32+
// Test all valid directions
33+
validDirections.forEach(dir => Kotobee.setDirection(dir));
34+
35+
// ------------------- Incorrect usage -------------------
36+
37+
// Invalid language
38+
// @ts-expect-error
39+
Kotobee.setLanguage("invalid");
40+
41+
// Invalid direction
42+
// @ts-expect-error
43+
Kotobee.setDirection("up");
44+
45+
// Calling clearCache with parameters should error
46+
// @ts-expect-error
47+
Kotobee.clearCache(123);
48+
49+
// Calling clearListeners with parameters should error
50+
// @ts-expect-error
51+
Kotobee.clearListeners("test");
52+
53+
// ------------------- Type assignments -------------------
54+
55+
// Assign valid types
56+
validLanguages.forEach(lang => {
57+
const l: LanguageCode = lang; // $ExpectType LanguageCode
58+
});
59+
60+
validDirections.forEach(dir => {
61+
const d: Directions = dir; // $ExpectType Directions
62+
});
63+
64+
// Invalid assignments
65+
// @ts-expect-error
66+
const fakeLang: LanguageCode = "madeup";
67+
// @ts-expect-error
68+
const dirCenter: Directions = "center";

types/kotobee/package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"private": true,
3+
"name": "@types/kotobee",
4+
"nonNpm": true,
5+
"nonNpmDescription": "This is an SDK for Kotobee Author application.",
6+
"version": "0.0.9999",
7+
"projects": [
8+
"https://support.kotobee.com/en/support/solutions/folders/8000082574"
9+
],
10+
"devDependencies": {
11+
"@types/kotobee": "workspace:."
12+
},
13+
"owners": [
14+
{
15+
"name": "Bashamega",
16+
"githubUsername": "Bashamega"
17+
}
18+
]
19+
}

types/kotobee/tsconfig.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"module": "node16",
4+
"lib": [
5+
"es6"
6+
],
7+
"noImplicitAny": true,
8+
"noImplicitThis": true,
9+
"strictFunctionTypes": true,
10+
"strictNullChecks": true,
11+
"types": [],
12+
"noEmit": true,
13+
"forceConsistentCasingInFileNames": true
14+
},
15+
"files": [
16+
"index.d.ts",
17+
"kotobee-tests.ts"
18+
]
19+
}

0 commit comments

Comments
 (0)