Skip to content

Commit

Permalink
refactor: types
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphaël Balet committed Sep 23, 2024
1 parent a7ef772 commit 951175a
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 24 deletions.
29 changes: 19 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-translate-multi-http-loader",
"version": "18.2.0",
"version": "18.3.0",
"license": "MIT",
"author": "Raphael Balet",
"maintainers": [
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion projects/multi-http-loader/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 4 additions & 3 deletions projects/multi-http-loader/src/lib/multi-http-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ export class MultiTranslateHttpLoader implements TranslateLoader {
public getTranslation(lang: string): Observable<any> {
const requests: Observable<Object | {}>[] = 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)
Expand Down
7 changes: 4 additions & 3 deletions projects/multi-http-loader/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
/* 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"]
},
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
},
"exclude": ["src/test.ts", "**/*.spec.ts"]
Expand Down
22 changes: 17 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 951175a

Please sign in to comment.