Skip to content

Commit

Permalink
chore: unify jsdocs and ts types
Browse files Browse the repository at this point in the history
  • Loading branch information
Aqours committed Nov 29, 2023
1 parent e29a5fc commit 7694ffc
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ interface KeywordSearchSchema {
/**
* Union type of schema
*/
declare type RuntimeMessageSchema = KeywordSearchSchema;
declare type ServiceWorkerMessage = KeywordSearchSchema;
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"commands": {
"_execute_action": {
"suggested_key": {
"default": "Shift+Alt+Z"
"default": "Alt+Shift+Z"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { KeywordSearch } from "./background/keyword-search.js";

const keywordSearch = new KeywordSearch();

chrome.runtime.onMessage.addListener((message: RuntimeMessageSchema, sender, sendResponse) => {
chrome.runtime.onMessage.addListener((message: ServiceWorkerMessage, sender, sendResponse) => {
if (!message) return;

switch (message.type) {
Expand Down
8 changes: 4 additions & 4 deletions src/scripts/background/hanzi-to-pinyin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ class Token implements IToken {
/**
* @return {boolean}
*/
function hasChinaCollator() {
function hasChinaCollator(): boolean {
// Check if zh_CN collation data is available
const locale = Intl.Collator.supportedLocalesOf([LOCALE_CHINA]);
const hasChinaCollator = locale.some((lang) => lang === LOCALE_CHINA);
Expand All @@ -408,7 +408,7 @@ function hasChinaCollator() {
*
* @return {boolean} - true when the table looks correct.
*/
function doSelfValidation() {
function doSelfValidation(): boolean {
let lastChar = UNIHANS[0];
let lastString = lastChar.toString();
for (const c of UNIHANS) {
Expand Down Expand Up @@ -439,7 +439,7 @@ function doSelfValidation() {
* @param {string} character - The character to generate the token from.
* @returns {Token} The generated token.
*/
function getToken(character: string) {
function getToken(character: string): Token {
const token = new Token();
const letter = character.toString();

Expand Down Expand Up @@ -527,7 +527,7 @@ function addToken(sb: StringBuilder, tokens: Token[], tokenType: number) {
* @param {string} input
* @return {Token[]}
*/
export function getPinyinFromHanzi(input: string) {
export function getPinyinFromHanzi(input: string): Token[] {
if (typeof input !== "string") {
throw new Error("`input` must be string.");
}
Expand Down
4 changes: 0 additions & 4 deletions src/scripts/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ class ExtensionManager {
this.container.textContent = "";
}

/**
* @param {string} [input]
* @return {chrome.management.ExtensionInfo[]}
*/
async getTargetExtensionInfos(input = ""): Promise<chrome.management.ExtensionInfo[]> {
return Array.from(await this.fetchKeywordSearch(input)).filter(
(item) => !(item.id === chrome.runtime.id || this.excludeTypeSet.has(item.type)),
Expand Down

0 comments on commit 7694ffc

Please sign in to comment.