Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Finish TS-ifying composables and constants (#1927)

Olga Bulatcf85fd3f4f7c
diff --git a/src/composables/types.js b/src/composables/types.js
deleted file mode 100644
index 54e0d5023..000000000
--- a/src/composables/types.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * @template T
- * @typedef {import('@nuxtjs/composition-api').Ref<T>} Ref
- */
-
-/**
- * @template T
- * @typedef {import('@nuxtjs/composition-api').ToRefs<T>} ToRefs
- */
-
-/**
- * @template T
- * @typedef {import('@nuxtjs/composition-api').Ref<T> | T} MaybeRef
- */
-
-export default {}
diff --git a/src/composables/use-i18n-utilities.js b/src/composables/use-i18n-utilities.ts
similarity index 89%
rename from src/composables/use-i18n-utilities.js
rename to src/composables/use-i18n-utilities.ts
index 1364ffa4e..6bf01203f 100644
--- a/src/composables/use-i18n-utilities.js
+++ b/src/composables/use-i18n-utilities.ts
@@ -18,11 +18,7 @@ export function useI18nResultsCount() {
const i18n = useI18n()
const getLocaleFormattedNumber = useGetLocaleFormattedNumber()
- /**
- * @param {number} resultsCount
- * @returns {string}
- */
- const getI18nCount = (resultsCount) => {
+ const getI18nCount = (resultsCount: number) => {
const countKey =
resultsCount === 0
? 'noResult'
diff --git a/tsconfig.json b/tsconfig.json
index 801d262f5..c72461ae3 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -88,10 +88,15 @@
"src/components/VModal/VInputModal.vue",
"src/pages/feedback.vue",
"src/pages/search-help.vue",
- "src/composables/types.js",
- // This section cannot be converted to TypeScript because it's used in non-TS contexts (like Tailwind configuration)
- "src/constants/screens.js",
+ /**
+ * Some files from this section cannot be converted to TypeScript because they are
+ * used in non-TS contexts (like Tailwind configuration). Therefore they're left as
+ * "vanilla JavaScript" with JSDoc based type annotations. This allows us to check
+ * them with TypeScript without introducing syntax changes that are not compatible
+ * with other tools we rely on.
+ */
+ "src/constants/**/*",
"src/server-middleware/healthcheck.js"
],
"exclude": ["node_modules"],