Added typescript declerations to i18n (#16894)

refs https://github.com/TryGhost/Team/issues/3307

Added TypeScript support and a new namespace for the `i18n` module. This
enables type checking and localisation for the new signup form component and future typescript projects that may need to add i18n support.
This commit is contained in:
Ronald Langeveld 2023-05-31 10:37:21 +02:00 committed by GitHub
parent 53ed8078ca
commit c53bd499c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 3 deletions

View File

@ -39,7 +39,7 @@ const SUPPORTED_LOCALES = [
/**
* @param {string} [lng]
* @param {'ghost'|'portal'|'test'} ns
* @param {'ghost'|'portal'|'test'|'signup-form'} ns
*/
module.exports = (lng = 'en', ns = 'portal') => {
const i18nextInstance = i18next.createInstance();

View File

@ -5,8 +5,10 @@
"author": "Ghost Foundation",
"private": true,
"main": "index.js",
"types": "./build/i18n.d.ts",
"scripts": {
"dev": "echo \"Implement me!\"",
"build": "tsc",
"test:unit:base": "NODE_ENV=testing c8 --include index.js --include lib --check-coverage --100 --reporter text --reporter cobertura mocha './test/**/*.test.js'",
"test:unit": "yarn test:unit:base && yarn translate",
"test": "yarn test:unit",
@ -25,7 +27,8 @@
"devDependencies": {
"c8": "7.13.0",
"i18next-parser": "8.0.0",
"mocha": "10.2.0"
"mocha": "10.2.0",
"typescript": "5.0.4"
},
"dependencies": {
"i18next": "22.5.0"

12
ghost/i18n/tsconfig.json Normal file
View File

@ -0,0 +1,12 @@
{
"compilerOptions": {
"allowJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "./build",
"skipLibCheck": true,
"esModuleInterop": true
},
"include": ["lib/**/*.js"],
"exclude": ["node_modules", "test"]
}

View File

@ -31949,7 +31949,7 @@ typescript-memoize@^1.0.0-alpha.3, typescript-memoize@^1.0.1:
resolved "https://registry.yarnpkg.com/typescript-memoize/-/typescript-memoize-1.1.1.tgz#02737495d5df6ebf72c07ba0d002e8f4cf5ccfa0"
integrity sha512-GQ90TcKpIH4XxYTI2F98yEQYZgjNMOGPpOgdjIBhaLaWji5HPWlRnZ4AeA1hfBxtY7bCGDJsqDDHk/KaHOl5bA==
typescript@5.0.4:
typescript@5.0.4, typescript@^5.0.4:
version "5.0.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b"
integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==