From 951175a0dc4f2f031d05657f3b8781f04051e70c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Balet?= Date: Mon, 23 Sep 2024 21:11:59 +0200 Subject: [PATCH] refactor: types --- package-lock.json | 29 ++++++++++++------- package.json | 4 +-- projects/multi-http-loader/package.json | 2 +- .../src/lib/multi-http-loader.ts | 7 +++-- projects/multi-http-loader/tsconfig.lib.json | 7 +++-- tsconfig.json | 22 ++++++++++---- 6 files changed, 47 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index aec1cef..adb139e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ngx-translate-multi-http-loader", - "version": "18.0.0", + "version": "18.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ngx-translate-multi-http-loader", - "version": "18.0.0", + "version": "18.2.0", "license": "MIT", "dependencies": { "@angular/common": "^18.2.3", @@ -43,7 +43,7 @@ "karma-jasmine": "^5.1.0", "karma-jasmine-html-reporter": "^2.1.0", "ng-packagr": "^18.1.0", - "typescript": "5.4.5" + "typescript": "^5.5.4" } }, "node_modules/@ampproject/remapping": { @@ -10181,6 +10181,7 @@ "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.5.tgz", "integrity": "sha512-+W/5efTR7y5HRD7gACw9yQjqMVvEMLBHmboM/kPWam+H+Hmyrgjh6YncVKK122YZkXrLudzTuAukUw9FnMf7IQ==", "dev": true, + "peer": true, "dependencies": { "string-width": "^4.2.0" }, @@ -10195,13 +10196,15 @@ "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "dev": true, + "peer": true }, "node_modules/cli-table3/node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true, + "peer": true, "engines": { "node": ">=8" } @@ -10211,6 +10214,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, + "peer": true, "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -10499,6 +10503,7 @@ "resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.13.tgz", "integrity": "sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ==", "dev": true, + "peer": true, "dependencies": { "ini": "^1.3.4", "proto-list": "~1.2.1" @@ -10508,7 +10513,8 @@ "version": "1.3.8", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", - "dev": true + "dev": true, + "peer": true }, "node_modules/connect": { "version": "3.7.0", @@ -14338,7 +14344,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", - "dev": true + "dev": true, + "peer": true }, "node_modules/json-parse-even-better-errors": { "version": "3.0.2", @@ -22461,7 +22468,8 @@ "version": "1.2.4", "resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz", "integrity": "sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA==", - "dev": true + "dev": true, + "peer": true }, "node_modules/proxy-addr": { "version": "2.0.7", @@ -25590,10 +25598,11 @@ "dev": true }, "node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/package.json b/package.json index 86e5745..fab54dc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-translate-multi-http-loader", - "version": "18.2.0", + "version": "18.3.0", "license": "MIT", "author": "Raphael Balet", "maintainers": [ @@ -47,7 +47,7 @@ "karma-jasmine": "^5.1.0", "karma-jasmine-html-reporter": "^2.1.0", "ng-packagr": "^18.1.0", - "typescript": "5.4.5" + "typescript": "^5.5.4" }, "release": { "extends": "@semantic-release/apm-config" diff --git a/projects/multi-http-loader/package.json b/projects/multi-http-loader/package.json index ed872ae..6dff7fd 100644 --- a/projects/multi-http-loader/package.json +++ b/projects/multi-http-loader/package.json @@ -1,6 +1,6 @@ { "name": "ngx-translate-multi-http-loader", - "version": "18.2.0", + "version": "18.3.0", "license": "MIT", "author": { "name": "Raphaƫl Balet", diff --git a/projects/multi-http-loader/src/lib/multi-http-loader.ts b/projects/multi-http-loader/src/lib/multi-http-loader.ts index a8ee5d4..add533e 100644 --- a/projects/multi-http-loader/src/lib/multi-http-loader.ts +++ b/projects/multi-http-loader/src/lib/multi-http-loader.ts @@ -19,12 +19,13 @@ export class MultiTranslateHttpLoader implements TranslateLoader { public getTranslation(lang: string): Observable { const requests: Observable[] = this._resourcesPrefix.map((resource) => { let path: string - if (resource.prefix) path = `${resource.prefix}${lang}${resource.suffix || '.json'}` - else path = `${resource}${lang}.json` + + if (typeof resource === 'string') path = `${resource}${lang}.json` + else path = `${resource.prefix}${lang}${resource.suffix || '.json'}` return new HttpClient(this._handler).get(path).pipe( catchError((res) => { - if (!resource.optional) { + if (typeof resource !== 'string' && !resource.optional) { console.group() console.error('Something went wrong for the following translation file:', path) console.error(res) diff --git a/projects/multi-http-loader/tsconfig.lib.json b/projects/multi-http-loader/tsconfig.lib.json index c754a25..2548382 100644 --- a/projects/multi-http-loader/tsconfig.lib.json +++ b/projects/multi-http-loader/tsconfig.lib.json @@ -1,11 +1,10 @@ -/* To learn more about this file see: https://angular.io/config/tsconfig. */ { "extends": "../../tsconfig.json", "compilerOptions": { "outDir": "../../out-tsc/lib", - "target": "es2015", - "declaration": true, "declarationMap": true, + "target": "es2020", + "declaration": true, "inlineSources": true, "types": [], "lib": ["dom", "es2018"] @@ -13,6 +12,8 @@ "angularCompilerOptions": { "skipTemplateCodegen": true, "strictMetadataEmit": true, + "fullTemplateTypeCheck": true, + "strictInjectionParameters": true, "enableResourceInlining": true }, "exclude": ["src/test.ts", "**/*.spec.ts"] diff --git a/tsconfig.json b/tsconfig.json index 94070be..c16c685 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,28 @@ { + "compileOnSave": false, "compilerOptions": { "baseUrl": "./", "outDir": "./dist/out-tsc", - "noImplicitOverride": true, - "noUnusedParameters": true, + "sourceMap": true, + "declaration": false, + "strict": true, + "module": "ES2022", "moduleResolution": "node", - "module": "es2020", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "importHelpers": true, "target": "ES2022", - "declaration": false, - "useDefineForClassFields": false + "typeRoots": ["node_modules/@types"], + "lib": ["ES2022", "dom"], + "paths": { + "ngx-mat-input-tel": ["dist/ngx-mat-input-tel"], + "ngx-mat-input-tel/*": ["dist/ngx-mat-input-tel/*"] + } }, "angularCompilerOptions": { + "enableI18nLegacyMessageIdFormat": false, + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, "strictTemplates": true } }