Skip to content

Commit 63abb4a

Browse files
committed
refactor(ts): ensure definitions are json-compatible
- converts some interfaces to types to prevent re-opening - https://www.typescriptlang.org/docs/handbook/advanced-types.html#interfaces-vs-type-aliases Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 9a09e62 commit 63abb4a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+701
-569
lines changed

.eslintrc.cjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ const config = {
1414
overrides: [
1515
...require('./.eslintrc.base.cjs').overrides,
1616
{
17-
files: ['./src/types/__tests__/types-versions.spec-d.ts'],
17+
files: ['src/interfaces/dependency-map.ts', './src/types/imports.ts'],
1818
rules: {
19-
'sort-keys': 0
19+
'@typescript-eslint/consistent-indexed-object-style': 0
2020
}
2121
},
2222
{
23-
files: ['./src/types/imports.ts'],
23+
files: ['./src/types/__tests__/types-versions.spec-d.ts'],
2424
rules: {
25-
'@typescript-eslint/consistent-indexed-object-style': 0
25+
'sort-keys': 0
2626
}
2727
}
2828
]

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"@commitlint/cli": "17.3.0",
6262
"@commitlint/config-conventional": "17.3.0",
6363
"@flex-development/mkbuild": "1.0.0-alpha.9",
64-
"@flex-development/tutils": "6.0.0-alpha.3",
64+
"@flex-development/tutils": "6.0.0-alpha.7",
6565
"@graphql-eslint/eslint-plugin": "3.13.1",
6666
"@types/chai": "4.3.4",
6767
"@types/conventional-changelog": "3.1.1",
@@ -119,7 +119,7 @@
119119
"yaml-eslint-parser": "1.1.0"
120120
},
121121
"peerDependencies": {
122-
"@flex-development/tutils": ">=6.0.0-alpha.3"
122+
"@flex-development/tutils": ">=6.0.0-alpha.7"
123123
},
124124
"resolutions": {
125125
"@ardatan/sync-fetch": "larsgw/sync-fetch#head=worker_threads",

src/interfaces/__tests__/bugs-object.spec-d.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* @file Unit Tests - DependencyMap
3+
* @module pkg-types/interfaces/tests/DependencyMap
4+
*/
5+
6+
import type { DependencyMeta, PeerDependencyMeta } from '#src/types'
7+
import type { JsonObject } from '@flex-development/tutils'
8+
import type TestSubject from '../dependency-map'
9+
10+
describe('unit:interfaces/DependencyMap', () => {
11+
type Union = DependencyMeta | PeerDependencyMeta | string | false
12+
13+
it('should allow empty object', () => {
14+
assertType<TestSubject<Union>>({})
15+
})
16+
17+
it('should be json object', () => {
18+
expectTypeOf<TestSubject<Union>>().toMatchTypeOf<JsonObject>()
19+
})
20+
21+
it('should return Record<string, DependencyMeta>', () => {
22+
expectTypeOf<TestSubject<DependencyMeta>>().toMatchTypeOf<
23+
Record<string, DependencyMeta>
24+
>()
25+
})
26+
27+
it('should return Record<string, PeerDependencyMeta>', () => {
28+
expectTypeOf<TestSubject<PeerDependencyMeta>>().toMatchTypeOf<
29+
Record<string, PeerDependencyMeta>
30+
>()
31+
})
32+
33+
it('should return Record<string, Record<string, string[]>>', () => {
34+
expectTypeOf<TestSubject<Record<string, string[]>>>().toMatchTypeOf<
35+
Record<string, Record<string, string[]>>
36+
>()
37+
})
38+
39+
it('should return Record<string, string>', () => {
40+
expectTypeOf<TestSubject<string>>().toMatchTypeOf<Record<string, string>>()
41+
})
42+
43+
it('should return Record<string, string | false>', () => {
44+
expectTypeOf<TestSubject<string | false>>().toMatchTypeOf<
45+
Record<string, string | false>
46+
>()
47+
})
48+
})

src/interfaces/__tests__/dependency-meta.spec-d.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/interfaces/__tests__/directories.spec-d.ts

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,19 @@
33
* @module pkg-types/interfaces/tests/Directories
44
*/
55

6+
import type { JsonObject } from '@flex-development/tutils'
67
import type TestSubject from '../directories'
78

89
describe('unit:interfaces/Directories', () => {
910
it('should allow empty object', () => {
1011
assertType<TestSubject>({})
1112
})
1213

13-
it('should allow object that only has property "bin"', () => {
14-
assertType<TestSubject>({ bin: './dist/bin' })
14+
it('should be json object', () => {
15+
expectTypeOf<TestSubject>().toMatchTypeOf<JsonObject>()
1516
})
1617

17-
it('should allow object that only has property "doc"', () => {
18-
assertType<TestSubject>({ doc: './dist/docs' })
19-
})
20-
21-
it('should allow object that only has property "example"', () => {
22-
assertType<TestSubject>({ example: './dist/docs/examples' })
23-
})
24-
25-
it('should allow object that only has property "lib"', () => {
26-
assertType<TestSubject>({ lib: './dist/lib' })
27-
})
28-
29-
it('should allow object that only has property "man"', () => {
30-
assertType<TestSubject>({ man: './dist/man' })
31-
})
32-
33-
it('should allow object that only has property "src"', () => {
34-
assertType<TestSubject>({ src: './src' })
35-
})
36-
37-
it('should allow object that only has property "test"', () => {
38-
assertType<TestSubject>({ test: './__tests__' })
39-
})
40-
41-
it('should allow object with all properties', () => {
42-
assertType<Required<TestSubject>>({
43-
bin: './dist/bin',
44-
doc: './dist/docs',
45-
example: './dist/docs/examples',
46-
lib: './dist/lib',
47-
man: './dist/man',
48-
src: './src',
49-
test: './__tests__'
50-
})
51-
})
52-
53-
it('should allow object with unknown key', () => {
54-
assertType<TestSubject>({ jars: 'java' })
18+
it('should only have string values', () => {
19+
expectTypeOf<TestSubject[string]>().toBeString()
5520
})
5621
})

src/interfaces/__tests__/funding-info.spec-d.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/interfaces/__tests__/install-config.spec-d.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/interfaces/__tests__/license-object.spec-d.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/interfaces/__tests__/peer-dependency-meta.spec-d.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)