Skip to content

Commit

Permalink
Tidy tsconfig and add object-overrides global type (#1407)
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyentvan7 authored Jan 3, 2024
1 parent 60b24f1 commit 2ac5566
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 10 deletions.
2 changes: 1 addition & 1 deletion apps/sr-frontend/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["node", "vite/client"]
"types": ["node", "vite/client", "object-overrides"]
},
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts", "src/**/*.tsx"]
Expand Down
2 changes: 1 addition & 1 deletion libs/pando/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["node", "vite/client"]
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["**/*.spec.ts", "vitest.config.ts"]
Expand Down
10 changes: 4 additions & 6 deletions libs/sr-db/src/Database/DataManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ export class DataManager<
> {
exportSROD(sro: Partial<ISrObjectDescription & ISroDatabase>) {
const key = this.dataKey.replace('sro_', '')
sro[key] = (Object.entries(this.data) as [CacheKey, CacheValue][]).map(
([id, value]) => ({
...this.deCache(value),
id,
})
)
sro[key] = Object.entries(this.data).map(([id, value]) => ({
...this.deCache(value),
id,
}))
}
importSROD(sro: ISrObjectDescription & ISroDatabase, _result: ImportResult) {
const entries = sro[this.dataKey]
Expand Down
2 changes: 1 addition & 1 deletion libs/sr-db/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": ["node"]
"types": ["node", "object-overrides"]
},
"include": ["src/**/*.ts"],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
Expand Down
2 changes: 1 addition & 1 deletion libs/sr-formula/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["node"]
"types": ["node", "object-overrides"]
},
"include": ["src/**/*.ts"],
"exclude": ["vitest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
Expand Down
5 changes: 5 additions & 0 deletions libs/sr-srod/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "@genshin-optimizer/sr-srod",
"version": "0.0.1",
"type": "commonjs"
}
6 changes: 6 additions & 0 deletions libs/sr-srod/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"sourceRoot": "libs/sr-srod/src",
"projectType": "library",
"targets": {
"build": {},
"build-ts": {
"options": {
"updateBuildableProjectDepsInPackageJson": true
}
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
Expand Down
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"exactOptionalPropertyTypes": true,
"strictNullChecks": true,
"allowSyntheticDefaultImports": false,
"typeRoots": ["./node_modules/@types", "./node_modules", "./types"],
"paths": {
"@genshin-optimizer/char-cards": ["libs/char-cards/src/index.ts"],
"@genshin-optimizer/consts": ["libs/consts/src/index.ts"],
Expand Down
22 changes: 22 additions & 0 deletions types/object-overrides/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
declare global {
interface ObjectConstructor {
keys<K extends string | number, V>(o: Partial<Record<K, V>>): `${K}`[]
keys<K extends string | number, V>(
o: Partial<Record<K, V>> | Record<string, never>
): `${K}`[]
values<K extends string | number, V>(
o: Partial<Record<K, V>> | Record<string, never>
): V[]
values<K extends string | number, V>(
o: Record<K, Exclude<V, undefined>>
): Exclude<V, undefined>[]
entries<K extends string | number, V>(
o: Record<K, Exclude<V, undefined>>
): [`${K}`, Exclude<V, undefined>][]
entries<K extends string | number, V>(
o: Partial<Record<K, V>> | Record<string, never>
): [`${K}`, V][]
}
}

export {}

0 comments on commit 2ac5566

Please sign in to comment.