@knapsack/spec-utils 5.0.0--canary.6593.4738696.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.lintstagedrc.mjs +2 -2
- package/CHANGELOG.md +131 -0
- package/dist/analyze-symbol.d.ts +8 -1
- package/dist/analyze-symbol.d.ts.map +1 -1
- package/dist/analyze-symbol.js +69 -4
- package/dist/analyze-symbol.js.map +1 -1
- package/dist/analyze-type.d.ts +10 -1
- package/dist/analyze-type.d.ts.map +1 -1
- package/dist/analyze-type.js +120 -23
- package/dist/analyze-type.js.map +1 -1
- package/dist/boot.d.ts +1 -1
- package/dist/boot.d.ts.map +1 -1
- package/dist/boot.js.map +1 -1
- package/dist/convert-to-spec.d.ts +1 -1
- package/dist/convert-to-spec.d.ts.map +1 -1
- package/dist/convert-to-spec.js +1 -1
- package/dist/convert-to-spec.js.map +1 -1
- package/dist/get-ts-config.d.ts +1 -1
- package/dist/get-ts-config.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js.map +1 -1
- package/dist/test-fixtures/generic-props.d.ts +79 -0
- package/dist/test-fixtures/generic-props.d.ts.map +1 -0
- package/dist/test-fixtures/generic-props.js +46 -0
- package/dist/test-fixtures/generic-props.js.map +1 -0
- package/dist/test-fixtures/index.d.ts +2 -0
- package/dist/test-fixtures/index.d.ts.map +1 -1
- package/dist/test-fixtures/index.js +2 -0
- package/dist/test-fixtures/index.js.map +1 -1
- package/dist/test-fixtures/iterable-props.d.ts +32 -0
- package/dist/test-fixtures/iterable-props.d.ts.map +1 -0
- package/dist/test-fixtures/iterable-props.js +12 -0
- package/dist/test-fixtures/iterable-props.js.map +1 -0
- package/dist/test-fixtures/union-props.d.ts +30 -0
- package/dist/test-fixtures/union-props.d.ts.map +1 -0
- package/dist/test-fixtures/union-props.js +17 -0
- package/dist/test-fixtures/union-props.js.map +1 -0
- package/dist/types.d.ts +23 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +0 -2
- package/dist/utils.js.map +1 -1
- package/package.json +14 -14
- package/vitest.config.mts +1 -0
- package/.eslintignore +0 -1
- package/.eslintrc.cjs +0 -9
package/.lintstagedrc.mjs
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,134 @@
|
|
|
1
|
+
# v4.89.8 (Fri Feb 20 2026)
|
|
2
|
+
|
|
3
|
+
### Release Notes
|
|
4
|
+
|
|
5
|
+
#### KSP-7685: Synthetic Data for Conflict Enrichment/Resolution testing ([#7154](https://github.com/knapsack-labs/app-monorepo/pull/7154))
|
|
6
|
+
|
|
7
|
+
* **Documentation**
|
|
8
|
+
* Added synthetic multi-source test fixtures including component documentation, design tokens, and brand guidelines for comprehensive testing coverage.
|
|
9
|
+
|
|
10
|
+
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
#### 🐛 Bug Fix
|
|
15
|
+
|
|
16
|
+
- Merged latest in ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
|
|
17
|
+
- Fixed indentation erros ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
|
|
18
|
+
- merge latest in ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
|
|
19
|
+
- Merge branch 'latest' into sxa/KSP-7037-tests-v2 ([@sxalexander](https://github.com/sxalexander))
|
|
20
|
+
- fixed update spec-utils test to use .lintstagedrc.mjs instead of deleted .eslintrc.cjs ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
|
|
21
|
+
- Use node: protocol prefix in all .lintstagedrc.mjs files ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
|
|
22
|
+
- Migrated ESLint config to flat config format (ESLint 9) ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
|
|
23
|
+
|
|
24
|
+
#### 🏠 Internal
|
|
25
|
+
|
|
26
|
+
- KSP-5516 Upgraded prettier to v3.8.1 and fix async API usage [#7191](https://github.com/knapsack-labs/app-monorepo/pull/7191) ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
|
|
27
|
+
- KSP-7685: Synthetic Data for Conflict Enrichment/Resolution testing [#7154](https://github.com/knapsack-labs/app-monorepo/pull/7154) ([@sxalexander](https://github.com/sxalexander))
|
|
28
|
+
- KSP-5524 Migrated ESLint config to flat config format (ESLint 9) [#7162](https://github.com/knapsack-labs/app-monorepo/pull/7162) ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
|
|
29
|
+
|
|
30
|
+
#### Authors: 2
|
|
31
|
+
|
|
32
|
+
- [@EmmanuelVelez](https://github.com/EmmanuelVelez)
|
|
33
|
+
- Sam Alexander ([@sxalexander](https://github.com/sxalexander))
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
# v4.89.7 (Fri Feb 06 2026)
|
|
38
|
+
|
|
39
|
+
#### 🐛 Bug Fix
|
|
40
|
+
|
|
41
|
+
- Merge branch 'latest' into feature/ksp-6555-remove-app-client-watchers-for-files-in-data-directory ([@EvanLovely](https://github.com/EvanLovely))
|
|
42
|
+
- Merge branch 'latest' into feature/ksp-6555-remove-app-client-watchers-for-files-in-data-directory ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
|
|
43
|
+
|
|
44
|
+
#### 🏠 Internal
|
|
45
|
+
|
|
46
|
+
- KSP-6106 Added consistent-type-imports rule with inline type syntax [#7128](https://github.com/knapsack-labs/app-monorepo/pull/7128) ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
|
|
47
|
+
- KSP-7692: expand server actions body size limit [#7097](https://github.com/knapsack-labs/app-monorepo/pull/7097) ([@illepic](https://github.com/illepic))
|
|
48
|
+
- KSP-7623 resolved some of react-hooks/set-state-in-effect lint errors and enab… [#7077](https://github.com/knapsack-labs/app-monorepo/pull/7077) ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
|
|
49
|
+
|
|
50
|
+
#### Authors: 3
|
|
51
|
+
|
|
52
|
+
- [@EmmanuelVelez](https://github.com/EmmanuelVelez)
|
|
53
|
+
- Christopher Bloom ([@illepic](https://github.com/illepic))
|
|
54
|
+
- Evan Lovely ([@EvanLovely](https://github.com/EvanLovely))
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
# v4.89.4 (Mon Jan 05 2026)
|
|
59
|
+
|
|
60
|
+
#### 🏠 Internal
|
|
61
|
+
|
|
62
|
+
- KSP-6086 normalize error and log metadata for api domains [#6997](https://github.com/knapsack-labs/app-monorepo/pull/6997) ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
|
|
63
|
+
|
|
64
|
+
#### Authors: 1
|
|
65
|
+
|
|
66
|
+
- [@EmmanuelVelez](https://github.com/EmmanuelVelez)
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
# v4.89.3 (Thu Dec 11 2025)
|
|
71
|
+
|
|
72
|
+
#### 🐛 Bug Fix
|
|
73
|
+
|
|
74
|
+
- KSP-6536 Fixed align token metrics counting with UI logic for variables and collections [#6778](https://github.com/knapsack-labs/app-monorepo/pull/6778) ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
|
|
75
|
+
- Merge branch 'latest' into feature/ksp-6536-metrics-not-computing-tokens-and-variables-correctly ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
|
|
76
|
+
- Merge remote-tracking branch 'origin/feature/ksp-6536-metrics-not-computing-tokens-and-variables-correctly' into feature/ksp-6536-metrics-not-computing-tokens-and-variables-correctly ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
|
|
77
|
+
|
|
78
|
+
#### Authors: 1
|
|
79
|
+
|
|
80
|
+
- [@EmmanuelVelez](https://github.com/EmmanuelVelez)
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
# v4.89.1 (Wed Dec 10 2025)
|
|
85
|
+
|
|
86
|
+
#### 🐛 Bug Fix
|
|
87
|
+
|
|
88
|
+
- Merge remote-tracking branch 'origin/latest' into KSP-6900_mcp_onboarding_pages ([@brittanysmart](https://github.com/brittanysmart))
|
|
89
|
+
|
|
90
|
+
#### Authors: 1
|
|
91
|
+
|
|
92
|
+
- Brittany Smart ([@brittanysmart](https://github.com/brittanysmart))
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
# v4.87.9 (Thu Nov 20 2025)
|
|
97
|
+
|
|
98
|
+
#### 🏠 Internal
|
|
99
|
+
|
|
100
|
+
- fix(deps): update dependency @types/node to ^20.19.25 [#6803](https://github.com/knapsack-labs/app-monorepo/pull/6803) ([@renovate[bot]](https://github.com/renovate[bot]))
|
|
101
|
+
|
|
102
|
+
#### Authors: 1
|
|
103
|
+
|
|
104
|
+
- [@renovate[bot]](https://github.com/renovate[bot])
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
# v4.87.7 (Mon Nov 10 2025)
|
|
109
|
+
|
|
110
|
+
#### 🏠 Internal
|
|
111
|
+
|
|
112
|
+
- fix(deps): update typescript [#6863](https://github.com/knapsack-labs/app-monorepo/pull/6863) ([@renovate[bot]](https://github.com/renovate[bot]))
|
|
113
|
+
|
|
114
|
+
#### Authors: 1
|
|
115
|
+
|
|
116
|
+
- [@renovate[bot]](https://github.com/renovate[bot])
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
# v4.87.6 (Wed Nov 05 2025)
|
|
121
|
+
|
|
122
|
+
#### 🏠 Internal
|
|
123
|
+
|
|
124
|
+
- Add comprehensive testing for remaining frameworks and MUI lib [#6876](https://github.com/knapsack-labs/app-monorepo/pull/6876) ([@mabry1985](https://github.com/mabry1985))
|
|
125
|
+
|
|
126
|
+
#### Authors: 1
|
|
127
|
+
|
|
128
|
+
- Josh Mabry ([@mabry1985](https://github.com/mabry1985))
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
1
132
|
# v4.87.4 (Fri Oct 31 2025)
|
|
2
133
|
|
|
3
134
|
#### 🏠 Internal
|
package/dist/analyze-symbol.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { SymbolInfo } from './types.js';
|
|
2
|
+
import { type SymbolDeclaringInterface, type SymbolInfo } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Returns where the property was declared. `isReactDomInterface` is `true`
|
|
5
|
+
* only when **every** declaration of the symbol lives inside a React DOM
|
|
6
|
+
* interface — so a user-overridden prop (declared on the user's own interface
|
|
7
|
+
* alongside an inherited one) is treated as user-defined and preserved.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getDeclaringInterface(symbol: ts.Symbol): SymbolDeclaringInterface | undefined;
|
|
3
10
|
export declare function analyzeSymbol({ symbol, checker, symbolsVisited, depth, maxDepth, }: {
|
|
4
11
|
symbol: ts.Symbol;
|
|
5
12
|
checker: ts.TypeChecker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze-symbol.d.ts","sourceRoot":"","sources":["../src/analyze-symbol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,
|
|
1
|
+
{"version":3,"file":"analyze-symbol.d.ts","sourceRoot":"","sources":["../src/analyze-symbol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,UAAU,EAEhB,MAAM,YAAY,CAAC;AA6CpB;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,EAAE,CAAC,MAAM,GAChB,wBAAwB,GAAG,SAAS,CAWtC;AAED,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,OAAO,EACP,cAA0B,EAC1B,KAAS,EACT,QAAY,GACb,EAAE;IACD,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC;IAClB,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC;IACxB,wCAAwC;IACxC,cAAc,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IAChC,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,UAAU,CAiRb"}
|
package/dist/analyze-symbol.js
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { analyzeType } from './analyze-type.js';
|
|
2
|
+
import { analyzeType, isNonArrayIterable } from './analyze-type.js';
|
|
3
3
|
import { getSetFlags } from './utils.js';
|
|
4
|
+
/**
|
|
5
|
+
* React DOM type interfaces whose properties are flattened into a component's
|
|
6
|
+
* inferred prop list. Used to detect inherited DOM-attribute props so
|
|
7
|
+
* renderers can filter them out (the 150+ `aria-*`/`on*`/element-attr deluge).
|
|
8
|
+
*
|
|
9
|
+
* Keep in sync with `@types/react`'s exported interfaces. Not exhaustive of
|
|
10
|
+
* every element variant — anything ending in `HTMLAttributes` is also matched.
|
|
11
|
+
*/
|
|
12
|
+
const REACT_DOM_INTERFACE_NAMES = new Set([
|
|
13
|
+
'AriaAttributes',
|
|
14
|
+
'DOMAttributes',
|
|
15
|
+
'HTMLAttributes',
|
|
16
|
+
'AllHTMLAttributes',
|
|
17
|
+
'SVGAttributes',
|
|
18
|
+
'WebViewHTMLAttributes',
|
|
19
|
+
'Attributes',
|
|
20
|
+
'ClassAttributes',
|
|
21
|
+
'RefAttributes',
|
|
22
|
+
'DataHTMLAttributes',
|
|
23
|
+
'DetailedHTMLProps',
|
|
24
|
+
]);
|
|
25
|
+
function isReactDomInterfaceName(name) {
|
|
26
|
+
if (!name)
|
|
27
|
+
return false;
|
|
28
|
+
if (REACT_DOM_INTERFACE_NAMES.has(name))
|
|
29
|
+
return true;
|
|
30
|
+
// ButtonHTMLAttributes, AnchorHTMLAttributes, InputHTMLAttributes, etc.
|
|
31
|
+
return name.endsWith('HTMLAttributes');
|
|
32
|
+
}
|
|
33
|
+
function findDeclaringInterfaceName(declaration) {
|
|
34
|
+
let node = declaration?.parent;
|
|
35
|
+
while (node) {
|
|
36
|
+
if (ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) {
|
|
37
|
+
return node.name?.getText();
|
|
38
|
+
}
|
|
39
|
+
node = node.parent;
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns where the property was declared. `isReactDomInterface` is `true`
|
|
45
|
+
* only when **every** declaration of the symbol lives inside a React DOM
|
|
46
|
+
* interface — so a user-overridden prop (declared on the user's own interface
|
|
47
|
+
* alongside an inherited one) is treated as user-defined and preserved.
|
|
48
|
+
*/
|
|
49
|
+
export function getDeclaringInterface(symbol) {
|
|
50
|
+
const declarations = symbol.declarations ?? [];
|
|
51
|
+
if (declarations.length === 0)
|
|
52
|
+
return undefined;
|
|
53
|
+
const interfaceNames = declarations.map(findDeclaringInterfaceName);
|
|
54
|
+
// Pick the first non-undefined name for display.
|
|
55
|
+
const interfaceName = interfaceNames.find(Boolean);
|
|
56
|
+
if (!interfaceName)
|
|
57
|
+
return undefined;
|
|
58
|
+
const isReactDomInterface = interfaceNames.every((n) => isReactDomInterfaceName(n));
|
|
59
|
+
return { interfaceName, isReactDomInterface };
|
|
60
|
+
}
|
|
4
61
|
export function analyzeSymbol({ symbol, checker, symbolsVisited = new Set(), depth = 0, maxDepth = 6, }) {
|
|
5
62
|
// Early termination if max depth reached
|
|
6
63
|
if (depth >= maxDepth) {
|
|
@@ -91,6 +148,7 @@ export function analyzeSymbol({ symbol, checker, symbolsVisited = new Set(), dep
|
|
|
91
148
|
}
|
|
92
149
|
: undefined,
|
|
93
150
|
name: symbol.getName(),
|
|
151
|
+
declaredIn: getDeclaringInterface(symbol),
|
|
94
152
|
};
|
|
95
153
|
// Data I have seen in debugger, but am not sure how to safely access:
|
|
96
154
|
// type.members - reliably indicates an "object" by providing a Map of Symbols of its properties. The check for Object below is not as reliable since everything in JS is an object.
|
|
@@ -127,7 +185,7 @@ export function analyzeSymbol({ symbol, checker, symbolsVisited = new Set(), dep
|
|
|
127
185
|
maxDepth,
|
|
128
186
|
});
|
|
129
187
|
}),
|
|
130
|
-
typeParameters: typeParameters
|
|
188
|
+
typeParameters: typeParameters?.map((typeParameter) => {
|
|
131
189
|
return analyzeType({ type: typeParameter, checker });
|
|
132
190
|
}),
|
|
133
191
|
// returnType: returnType
|
|
@@ -188,7 +246,9 @@ export function analyzeSymbol({ symbol, checker, symbolsVisited = new Set(), dep
|
|
|
188
246
|
type: constructSignature.getReturnType(),
|
|
189
247
|
checker,
|
|
190
248
|
}),
|
|
191
|
-
constructorParameters: constructSignature
|
|
249
|
+
constructorParameters: constructSignature
|
|
250
|
+
?.getParameters()
|
|
251
|
+
.map((constructParam) => {
|
|
192
252
|
return analyzeSymbol({
|
|
193
253
|
symbol: constructParam,
|
|
194
254
|
checker,
|
|
@@ -203,7 +263,12 @@ export function analyzeSymbol({ symbol, checker, symbolsVisited = new Set(), dep
|
|
|
203
263
|
// this check could be better: lots of things are `ts.TypeFlags.Object`
|
|
204
264
|
typeFlags.includes('Object') &&
|
|
205
265
|
// here we exclude things that are technically `ts.TypeFlags.Object` but are not "objects" in JS
|
|
206
|
-
!isArray
|
|
266
|
+
!isArray &&
|
|
267
|
+
// Non-array iterables (Set, Iterable<T>, etc.) carry the Object flag and a
|
|
268
|
+
// `[Symbol.iterator]` member; without this they'd be walked as objects and
|
|
269
|
+
// emit a spurious `__@iterator` property. Delegate them to analyzeType,
|
|
270
|
+
// which represents them as arrays of their element type.
|
|
271
|
+
!isNonArrayIterable(type)) {
|
|
207
272
|
typeInfo = {
|
|
208
273
|
type: 'object',
|
|
209
274
|
tsRawType: checker.typeToString(type, undefined, ts.TypeFormatFlags.NoTruncation),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze-symbol.js","sourceRoot":"","sources":["../src/analyze-symbol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"analyze-symbol.js","sourceRoot":"","sources":["../src/analyze-symbol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAMpE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAS;IAChD,gBAAgB;IAChB,eAAe;IACf,gBAAgB;IAChB,mBAAmB;IACnB,eAAe;IACf,uBAAuB;IACvB,YAAY;IACZ,iBAAiB;IACjB,eAAe;IACf,oBAAoB;IACpB,mBAAmB;CACpB,CAAC,CAAC;AAEH,SAAS,uBAAuB,CAAC,IAAwB;IACvD,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACxB,IAAI,yBAAyB,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACrD,wEAAwE;IACxE,OAAO,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,0BAA0B,CACjC,WAAuC;IAEvC,IAAI,IAAI,GAAwB,WAAW,EAAE,MAAM,CAAC;IACpD,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,EAAE,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,CAAC;YACvE,OAAO,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;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YACb,CAAC,EACD,EAAyD,CAC1D;YACD,UAAU;YACV,UAAU,EAAE;gBACV,SAAS,EAAE,WAAW,CAAC;oBACrB,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,UAAU,EAAE,EAAE,CAAC,SAAS;iBACzB,CAAC;aACH;SACF,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,QAAQ,GAAG,WAAW,CAAC;YACrB,IAAI;YACJ,OAAO;YACP,UAAU;SACX,CAAC,CAAC;IACL,CAAC;IACD,OAAO;QACL,GAAG,cAAc;QACjB,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
package/dist/analyze-type.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
import { TypeInfo } from './types.js';
|
|
2
|
+
import { type TypeInfo } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* True when a type is iterable (exposes a `[Symbol.iterator]` member) but is not
|
|
5
|
+
* an array/array-like — e.g. `Set`, `Iterable<T>`, `IterableIterator<T>`, and the
|
|
6
|
+
* `Set` arm of react-stately's `Selection`. Arrays reach the dedicated array
|
|
7
|
+
* branch first, and primitives like `string` never reach here, so this only
|
|
8
|
+
* matches non-array iterables. Without it these fall through to the object
|
|
9
|
+
* branch and emit a bogus `__@iterator` property ("should be object").
|
|
10
|
+
*/
|
|
11
|
+
export declare function isNonArrayIterable(type: ts.Type): boolean;
|
|
3
12
|
/**
|
|
4
13
|
* Analyzes a TypeScript type and returns a structured TypeInfo representation
|
|
5
14
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze-type.d.ts","sourceRoot":"","sources":["../src/analyze-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"analyze-type.d.ts","sourceRoot":"","sources":["../src/analyze-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EACL,KAAK,QAAQ,EAGd,MAAM,YAAY,CAAC;AA6CpB;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CAyBzD;AAkBD;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,OAAO,EACP,UAAU,EACV,YAA0C,EAC1C,KAAS;AACT;;;GAGG;AACH,QAAY,GACb,EAAE;IACD,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IACd,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,QAAQ,CA0VX"}
|
package/dist/analyze-type.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
+
import { getDeclaringInterface } from './analyze-symbol.js';
|
|
2
3
|
import { getSetFlags } from './utils.js';
|
|
3
4
|
// Cache for type IDs to improve performance
|
|
4
5
|
const typeIdMap = new WeakMap();
|
|
@@ -14,9 +15,7 @@ function getTypeId(type, checker) {
|
|
|
14
15
|
}
|
|
15
16
|
// Generate a new ID based on the type's string representation
|
|
16
17
|
// This ensures identical types get the same ID
|
|
17
|
-
const typeString = checker.typeToString(type, undefined,
|
|
18
|
-
// eslint-disable-next-line no-bitwise
|
|
19
|
-
ts.TypeFormatFlags.NoTruncation);
|
|
18
|
+
const typeString = checker.typeToString(type, undefined, ts.TypeFormatFlags.NoTruncation);
|
|
20
19
|
// Add some additional information to help distinguish types
|
|
21
20
|
// that might have the same string representation
|
|
22
21
|
const idComponents = [typeString];
|
|
@@ -31,6 +30,47 @@ function getTypeId(type, checker) {
|
|
|
31
30
|
typeIdMap.set(type, newId);
|
|
32
31
|
return newId;
|
|
33
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* True when a type is iterable (exposes a `[Symbol.iterator]` member) but is not
|
|
35
|
+
* an array/array-like — e.g. `Set`, `Iterable<T>`, `IterableIterator<T>`, and the
|
|
36
|
+
* `Set` arm of react-stately's `Selection`. Arrays reach the dedicated array
|
|
37
|
+
* branch first, and primitives like `string` never reach here, so this only
|
|
38
|
+
* matches non-array iterables. Without it these fall through to the object
|
|
39
|
+
* branch and emit a bogus `__@iterator` property ("should be object").
|
|
40
|
+
*/
|
|
41
|
+
export function isNonArrayIterable(type) {
|
|
42
|
+
// Known iterable built-ins by symbol name…
|
|
43
|
+
const name = type.getSymbol()?.getName();
|
|
44
|
+
if (name &&
|
|
45
|
+
[
|
|
46
|
+
'Set',
|
|
47
|
+
'ReadonlySet',
|
|
48
|
+
'Map',
|
|
49
|
+
'ReadonlyMap',
|
|
50
|
+
'Iterable',
|
|
51
|
+
'IterableIterator',
|
|
52
|
+
'Generator',
|
|
53
|
+
'AsyncIterable',
|
|
54
|
+
'AsyncIterableIterator',
|
|
55
|
+
].includes(name)) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
// …plus any other type exposing a `[Symbol.iterator]` member (custom
|
|
59
|
+
// iterables). Callers must check array-like types first, since arrays also
|
|
60
|
+
// expose an iterator member.
|
|
61
|
+
return type
|
|
62
|
+
.getProperties()
|
|
63
|
+
.some((symbol) => symbol.getName().includes('@iterator'));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Best-effort element type for an iterable: its first type argument
|
|
67
|
+
* (`Set<T>` / `Iterable<T>` → `T`). Returns undefined when none is resolvable,
|
|
68
|
+
* in which case callers fall back to a `misc` item type.
|
|
69
|
+
*/
|
|
70
|
+
function getIterableElementType({ type, checker, }) {
|
|
71
|
+
const typeArgs = checker.getTypeArguments(type);
|
|
72
|
+
return typeArgs && typeArgs.length > 0 ? typeArgs[0] : undefined;
|
|
73
|
+
}
|
|
34
74
|
/**
|
|
35
75
|
* Analyzes a TypeScript type and returns a structured TypeInfo representation
|
|
36
76
|
*/
|
|
@@ -40,16 +80,13 @@ export function analyzeType({ type, checker, isOptional, visitedTypes = new Map(
|
|
|
40
80
|
* This is used to avoid infinite recursion.
|
|
41
81
|
*/
|
|
42
82
|
maxDepth = 3, }) {
|
|
43
|
-
var _a;
|
|
44
83
|
// Generate a unique key for the type
|
|
45
84
|
const typeId = getTypeId(type, checker);
|
|
46
85
|
// Check if we've already analyzed this type
|
|
47
86
|
if (visitedTypes.has(typeId)) {
|
|
48
87
|
return visitedTypes.get(typeId);
|
|
49
88
|
}
|
|
50
|
-
const tsRawType = checker.typeToString(type, undefined,
|
|
51
|
-
// eslint-disable-next-line no-bitwise
|
|
52
|
-
ts.TypeFormatFlags.MultilineObjectLiterals |
|
|
89
|
+
const tsRawType = checker.typeToString(type, undefined, ts.TypeFormatFlags.MultilineObjectLiterals |
|
|
53
90
|
ts.TypeFormatFlags.NoTruncation);
|
|
54
91
|
const typeFlags = getSetFlags({
|
|
55
92
|
flags: type.flags,
|
|
@@ -62,21 +99,18 @@ maxDepth = 3, }) {
|
|
|
62
99
|
},
|
|
63
100
|
isOptional,
|
|
64
101
|
};
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return result;
|
|
73
|
-
}
|
|
74
|
-
let result;
|
|
102
|
+
// Classify leaf types BEFORE the max-depth guard. Primitives and literals
|
|
103
|
+
// are terminal (they never recurse), so resolving them at any depth is safe
|
|
104
|
+
// and cannot cause runaway recursion. Doing this first ensures string/number
|
|
105
|
+
// literal unions nested past `maxDepth` are still recognized: e.g. a
|
|
106
|
+
// component whose props is a union type (`A | B`) pushes its enum literals an
|
|
107
|
+
// extra level deep, and if the guard ran first they'd collapse to `misc` and
|
|
108
|
+
// later degrade to a plain `string` instead of an enum.
|
|
75
109
|
// Handle primitive types first
|
|
76
110
|
if (tsRawType === 'number' ||
|
|
77
111
|
tsRawType === 'boolean' ||
|
|
78
112
|
tsRawType === 'string') {
|
|
79
|
-
result = {
|
|
113
|
+
const result = {
|
|
80
114
|
type: tsRawType,
|
|
81
115
|
...typeInfoCommon,
|
|
82
116
|
};
|
|
@@ -85,7 +119,7 @@ maxDepth = 3, }) {
|
|
|
85
119
|
}
|
|
86
120
|
// Handle literal types
|
|
87
121
|
if (type.isStringLiteral()) {
|
|
88
|
-
result = {
|
|
122
|
+
const result = {
|
|
89
123
|
type: 'stringLiteral',
|
|
90
124
|
value: type.value,
|
|
91
125
|
...typeInfoCommon,
|
|
@@ -94,7 +128,7 @@ maxDepth = 3, }) {
|
|
|
94
128
|
return result;
|
|
95
129
|
}
|
|
96
130
|
if (type.isNumberLiteral()) {
|
|
97
|
-
result = {
|
|
131
|
+
const result = {
|
|
98
132
|
type: 'numberLiteral',
|
|
99
133
|
value: type.value,
|
|
100
134
|
...typeInfoCommon,
|
|
@@ -102,6 +136,47 @@ maxDepth = 3, }) {
|
|
|
102
136
|
visitedTypes.set(typeId, result);
|
|
103
137
|
return result;
|
|
104
138
|
}
|
|
139
|
+
// Resolve generic type parameters — and the constraint-dependent types that hinge on
|
|
140
|
+
// them (indexed-access `Obj[T]`, conditional `T extends … ? … : …`) — to their base
|
|
141
|
+
// constraint. Without this, props on a GENERIC component reach the fallthrough as
|
|
142
|
+
// `misc` and get dropped from the spec. e.g. `Badge<T extends BadgeTypes>` exposing
|
|
143
|
+
// `type?: T` and `color?: BadgeColor<T>` (= `…Map[T]`): the constraint of `T` is the
|
|
144
|
+
// `BadgeTypes` union, and the constraint of `…Map[T]` is the union of the map's value
|
|
145
|
+
// types — so both surface as a string-literal union, which `convert-to-spec` renders
|
|
146
|
+
// as an enum ("options") field. Placed before the max-depth guard for the same reason
|
|
147
|
+
// literals are: the union it unwraps to may sit a level deeper than `maxDepth`.
|
|
148
|
+
if (
|
|
149
|
+
// eslint-disable-next-line no-bitwise
|
|
150
|
+
type.flags &
|
|
151
|
+
(ts.TypeFlags.TypeParameter |
|
|
152
|
+
ts.TypeFlags.IndexedAccess |
|
|
153
|
+
ts.TypeFlags.Conditional)) {
|
|
154
|
+
const constraint = checker.getBaseConstraintOfType(type);
|
|
155
|
+
if (constraint && constraint !== type) {
|
|
156
|
+
const resolved = analyzeType({
|
|
157
|
+
type: constraint,
|
|
158
|
+
checker,
|
|
159
|
+
isOptional,
|
|
160
|
+
visitedTypes,
|
|
161
|
+
depth,
|
|
162
|
+
maxDepth,
|
|
163
|
+
});
|
|
164
|
+
visitedTypes.set(typeId, resolved);
|
|
165
|
+
return resolved;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// If we've reached max depth, return a simplified type. This now only bounds
|
|
169
|
+
// the recursive/composite branches below (union, array, intersection,
|
|
170
|
+
// object); leaf types are already handled above.
|
|
171
|
+
if (depth >= maxDepth) {
|
|
172
|
+
const result = {
|
|
173
|
+
type: 'misc',
|
|
174
|
+
...typeInfoCommon,
|
|
175
|
+
};
|
|
176
|
+
visitedTypes.set(typeId, result);
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
let result;
|
|
105
180
|
// Create a placeholder to avoid infinite recursion
|
|
106
181
|
const placeholder = {
|
|
107
182
|
type: 'misc',
|
|
@@ -130,7 +205,29 @@ maxDepth = 3, }) {
|
|
|
130
205
|
type: 'array',
|
|
131
206
|
items: indexInfos.length === 1
|
|
132
207
|
? analyzeType({
|
|
133
|
-
type:
|
|
208
|
+
type: indexInfos[0]?.type,
|
|
209
|
+
checker,
|
|
210
|
+
isOptional,
|
|
211
|
+
visitedTypes,
|
|
212
|
+
depth: depth + 1,
|
|
213
|
+
maxDepth,
|
|
214
|
+
})
|
|
215
|
+
: { type: 'misc', ...typeInfoCommon },
|
|
216
|
+
...typeInfoCommon,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
// Handle non-array iterables (Set, Iterable<T>, the Set arm of react-stately's
|
|
220
|
+
// Selection, etc.). These carry the `Object` flag and a `[Symbol.iterator]`
|
|
221
|
+
// member but no numeric index signature, so without this branch they fall
|
|
222
|
+
// through to the object handler and emit a spurious `__@iterator` property.
|
|
223
|
+
// Represent them as arrays of their element type instead.
|
|
224
|
+
else if (isNonArrayIterable(type)) {
|
|
225
|
+
const elementType = getIterableElementType({ type, checker });
|
|
226
|
+
result = {
|
|
227
|
+
type: 'array',
|
|
228
|
+
items: elementType
|
|
229
|
+
? analyzeType({
|
|
230
|
+
type: elementType,
|
|
134
231
|
checker,
|
|
135
232
|
isOptional,
|
|
136
233
|
visitedTypes,
|
|
@@ -158,7 +255,6 @@ maxDepth = 3, }) {
|
|
|
158
255
|
const propAnalysis = analyzeType({
|
|
159
256
|
type: propType,
|
|
160
257
|
checker,
|
|
161
|
-
// eslint-disable-next-line no-bitwise
|
|
162
258
|
isOptional: !!(prop.flags & ts.SymbolFlags.Optional),
|
|
163
259
|
visitedTypes,
|
|
164
260
|
depth: depth + 1,
|
|
@@ -173,6 +269,7 @@ maxDepth = 3, }) {
|
|
|
173
269
|
enumObject: ts.SymbolFlags,
|
|
174
270
|
}),
|
|
175
271
|
},
|
|
272
|
+
declaredIn: getDeclaringInterface(prop),
|
|
176
273
|
};
|
|
177
274
|
}
|
|
178
275
|
}
|
|
@@ -241,7 +338,6 @@ maxDepth = 3, }) {
|
|
|
241
338
|
const propAnalysis = analyzeType({
|
|
242
339
|
type: propType,
|
|
243
340
|
checker,
|
|
244
|
-
// eslint-disable-next-line no-bitwise
|
|
245
341
|
isOptional: !!(prop.flags & ts.SymbolFlags.Optional),
|
|
246
342
|
visitedTypes,
|
|
247
343
|
depth: depth + 1,
|
|
@@ -256,6 +352,7 @@ maxDepth = 3, }) {
|
|
|
256
352
|
enumObject: ts.SymbolFlags,
|
|
257
353
|
}),
|
|
258
354
|
},
|
|
355
|
+
declaredIn: getDeclaringInterface(prop),
|
|
259
356
|
};
|
|
260
357
|
}
|
|
261
358
|
}
|
package/dist/analyze-type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze-type.js","sourceRoot":"","sources":["../src/analyze-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"analyze-type.js","sourceRoot":"","sources":["../src/analyze-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAM5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,4CAA4C;AAC5C,MAAM,SAAS,GAAG,IAAI,OAAO,EAAmB,CAAC;AAEjD;;;GAGG;AACH,SAAS,SAAS,CAAC,IAAa,EAAE,OAAuB;IACvD,+CAA+C;IAC/C,MAAM,UAAU,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,8DAA8D;IAC9D,+CAA+C;IAC/C,MAAM,UAAU,GAAG,OAAO,CAAC,YAAY,CACrC,IAAI,EACJ,SAAS,EAET,EAAE,CAAC,eAAe,CAAC,YAAY,CAChC,CAAC;IAEF,4DAA4D;IAC5D,iDAAiD;IACjD,MAAM,YAAY,GAAG,CAAC,UAAU,CAAC,CAAC;IAElC,+BAA+B;IAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IAChC,IAAI,MAAM,EAAE,CAAC;QACX,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,2CAA2C;IAC3C,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAEtC,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CA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AAC;oBACJ,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CACX,4BAA4B,IAAI,CAAC,OAAO,EAAE,KAAK,KAAK,EAAE,CACvD,CAAC;gBACJ,CAAC;gBACD,OAAO,GAAG,CAAC;YACb,CAAC,EACD,EAAgC,CACjC,CAAC;YAEF,IAAI,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC/C,MAAM,GAAG;oBACP,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE,kBAAkB;oBAC9B,GAAG,cAAc;iBAClB,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,WAAW,CAAC;YACvB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,WAAW,CAAC;QACvB,CAAC;IACH,CAAC;IACD,8DAA8D;SACzD,CAAC;QACJ,MAAM,GAAG,WAAW,CAAC;IACvB,CAAC;IAED,0CAA0C;IAC1C,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/boot.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Program } from 'typescript';
|
|
1
|
+
import { type Program } from 'typescript';
|
|
2
2
|
import { getTsConfigCompilerOptions } from './get-ts-config.js';
|
|
3
3
|
export declare function prepTypeScriptBoot({ configSrc, }: {
|
|
4
4
|
configSrc: Parameters<typeof getTsConfigCompilerOptions>[0];
|
package/dist/boot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,GACV,EAAE;IACD,SAAS,EAAE,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC;CAC7D;;;EAIA;AAED,wBAAgB,cAAc,CAAC,EAC7B,SAAS,EACT,SAAS,EACT,UAAU,GACX,EAAE;IACD,SAAS,EAAE,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;;;;;EASA"}
|
package/dist/boot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot.js","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"boot.js","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAgB,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAEhE,MAAM,UAAU,kBAAkB,CAAC,EACjC,SAAS,GAGV;IACC,MAAM,eAAe,GAAG,0BAA0B,CAAC,SAAS,CAAC,CAAC;IAC9D,MAAM,YAAY,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACzD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAC7B,SAAS,EACT,SAAS,EACT,UAAU,GAKX;IACC,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE,GAAG,kBAAkB,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;IAC5E,MAAM,OAAO,GAAG,aAAa,CAAC;QAC5B,OAAO,EAAE,eAAe;QACxB,SAAS,EAAE,SAAS;QACpB,UAAU;KACX,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IACzC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC7D,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PropertyTypes } from '@knapsack/types';
|
|
2
|
-
import { TypeInfo } from './types.js';
|
|
2
|
+
import { type TypeInfo } from './types.js';
|
|
3
3
|
export declare function convertToSpec({ typeInfo, trustRequiredProps, }: {
|
|
4
4
|
typeInfo: TypeInfo;
|
|
5
5
|
trustRequiredProps: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-to-spec.d.ts","sourceRoot":"","sources":["../src/convert-to-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAMd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"convert-to-spec.d.ts","sourceRoot":"","sources":["../src/convert-to-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAMd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,kBAAkB,GACnB,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,kBAAkB,EAAE,OAAO,CAAC;CAC7B,GAAG;IACF,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,OAAO,CAAC;CACrB,CAqLA"}
|
package/dist/convert-to-spec.js
CHANGED
|
@@ -17,7 +17,7 @@ export function convertToSpec({ typeInfo, trustRequiredProps, }) {
|
|
|
17
17
|
if (!details.prop)
|
|
18
18
|
return acc;
|
|
19
19
|
acc[propName] = details.prop;
|
|
20
|
-
if (jsDoc
|
|
20
|
+
if (jsDoc?.description) {
|
|
21
21
|
acc[propName].description = jsDoc.description;
|
|
22
22
|
}
|
|
23
23
|
if (!details.isOptional && trustRequiredProps) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-to-spec.js","sourceRoot":"","sources":["../src/convert-to-spec.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,aAAa,CAAC,EAC5B,QAAQ,EACR,kBAAkB,GAInB;IAIC,MAAM,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,QAAQ,CAAC;IAExC,QAAQ,QAAQ,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC;YAChC,MAAM,QAAQ,GAAa,EAAE,CAAC;YAC9B,OAAO;gBACL,UAAU;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,QAAQ;oBACR,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,CAC3C,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;wBACrD,MAAM,OAAO,GAAG,aAAa,CAAC;4BAC5B,QAAQ,EAAE,YAAY;4BACtB,kBAAkB;yBACnB,CAAC,CAAC;wBACH,IAAI,CAAC,OAAO,CAAC,IAAI;4BAAE,OAAO,GAAG,CAAC;wBAE9B,GAAG,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;wBAC7B,IAAI,KAAK,
|
|
1
|
+
{"version":3,"file":"convert-to-spec.js","sourceRoot":"","sources":["../src/convert-to-spec.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,aAAa,CAAC,EAC5B,QAAQ,EACR,kBAAkB,GAInB;IAIC,MAA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;YAED,OAAO;gBACL,UAAU;gBACV,IAAI,EAAE,IAAI;aACX,CAAC;QACJ,CAAC;QACD,KAAK,eAAe,CAAC;QACrB,KAAK,eAAe,CAAC;QACrB,KAAK,OAAO,CAAC;QACb,KAAK,SAAS,CAAC;QACf,KAAK,KAAK,CAAC,CAAC,CAAC;YACX,OAAO;gBACL,UAAU;gBACV,IAAI,EAAE,IAAI;aACX,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,gBAAgB,GAAU,QAAQ,CAAC;YAEzC,OAAO;gBACL,UAAU;gBACV,IAAI,EAAE,IAAI;aACX,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/get-ts-config.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-ts-config.d.ts","sourceRoot":"","sources":["../src/get-ts-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAMT,eAAe,
|
|
1
|
+
{"version":3,"file":"get-ts-config.d.ts","sourceRoot":"","sources":["../src/get-ts-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAMT,KAAK,eAAe,EACrB,MAAM,YAAY,CAAC;AAGpB,wBAAgB,eAAe,CAAC,EAC9B,QAAwB,GACzB,GAAE;IACD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACd;;;EA8BL;AAED,wBAAgB,0BAA0B,CACxC,SAAS,EACL;IACE,IAAI,EAAE,qBAAqB,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;CACzB,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CAC1C,GACJ,eAAe,CAmCjB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getTsConfigCompilerOptions } from './get-ts-config.js';
|
|
2
2
|
export { resolveTsModule } from './resolve.js';
|
|
3
3
|
export { analyzeExport, analyzeExports } from './analyze-exports.js';
|
|
4
|
-
export type { TypeInfo, SymbolInfo } from './types.js';
|
|
4
|
+
export type { TypeInfo, SymbolInfo, SymbolDeclaringInterface, } from './types.js';
|
|
5
5
|
export { convertToSpec } from './convert-to-spec.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACrE,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACrE,YAAY,EACV,QAAQ,EACR,UAAU,EACV,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAMrE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/resolve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,MAAM,YAAY,CAAC;AAenD,wBAAgB,eAAe,CAAC,EAC9B,cAAc,EACd,UAAU,EACV,cAAmB,GACpB,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC,yBAiCA"}
|
package/dist/resolve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,SAAS,qBAAqB,CAAC,cAAsC;IACnE,IAAI,CAAC,cAAc;QAAE,OAAO,SAAS,CAAC;IACtC,OAAO,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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;IACH,MAAM,EAAE,cAAc,EAAE,GAAG,iBAAiB,CAC1C,UAAU,EACV,cAAc,EACd,eAAe,EACf,YAAY,CACb,CAAC;IACF,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,6BAA6B,UAAU,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fixtures for GENERIC components whose props are typed THROUGH the component's own type
|
|
3
|
+
* parameter. This is the `Badge<T extends BadgeTypes>` shape, where `type?: T` and
|
|
4
|
+
* `color?: BadgeColor<T>` (= `…Map[T]`) were silently dropped: the analyzer had no branch
|
|
5
|
+
* for type parameters or the constraint-dependent types (indexed-access, conditional)
|
|
6
|
+
* that hinge on them, so they fell through to `misc`. Resolving each to its base
|
|
7
|
+
* constraint turns it into a string-literal union → an `enum` ("options") field.
|
|
8
|
+
*
|
|
9
|
+
* Each export below isolates one way a generic can carry an enum, plus the unconstrained
|
|
10
|
+
* case that must degrade gracefully (no enum, no crash).
|
|
11
|
+
*/
|
|
12
|
+
type Size = 'sm' | 'md' | 'lg';
|
|
13
|
+
type BadgeKind = 'pill-color' | 'color' | 'modern';
|
|
14
|
+
type ColorByKind = {
|
|
15
|
+
'pill-color': 'gray' | 'brand' | 'error';
|
|
16
|
+
color: 'gray' | 'brand' | 'error';
|
|
17
|
+
modern: 'gray';
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Bare type parameter (`kind?: T`) + indexed-access (`color?: ColorByKind[T]`), alongside
|
|
21
|
+
* a plain union control (`size`). Mirrors `Badge` most directly.
|
|
22
|
+
*/
|
|
23
|
+
export declare function GenericBadge<T extends BadgeKind>(props: {
|
|
24
|
+
/** Bare type parameter — constraint is the BadgeKind union. */
|
|
25
|
+
kind?: T;
|
|
26
|
+
/** Plain union (control — always worked). */
|
|
27
|
+
size?: Size;
|
|
28
|
+
/** Indexed-access into a map, keyed by the type parameter. */
|
|
29
|
+
color?: ColorByKind[T];
|
|
30
|
+
}): {
|
|
31
|
+
/** Bare type parameter — constraint is the BadgeKind union. */
|
|
32
|
+
kind?: T;
|
|
33
|
+
/** Plain union (control — always worked). */
|
|
34
|
+
size?: Size;
|
|
35
|
+
/** Indexed-access into a map, keyed by the type parameter. */
|
|
36
|
+
color?: ColorByKind[T];
|
|
37
|
+
};
|
|
38
|
+
/** Conditional type that depends on the type parameter. */
|
|
39
|
+
export declare function ConditionalBadge<T extends 'in' | 'out'>(props: {
|
|
40
|
+
dir?: T;
|
|
41
|
+
placement?: T extends 'in' ? 'top' | 'bottom' : 'left' | 'right';
|
|
42
|
+
}): {
|
|
43
|
+
dir?: T;
|
|
44
|
+
placement?: T extends "in" ? "top" | "bottom" : "left" | "right";
|
|
45
|
+
};
|
|
46
|
+
/** Multiple, independently-constrained type parameters. */
|
|
47
|
+
export declare function MultiGenericBadge<A extends 'a1' | 'a2', B extends 'b1' | 'b2' | 'b3'>(props: {
|
|
48
|
+
a?: A;
|
|
49
|
+
b?: B;
|
|
50
|
+
}): {
|
|
51
|
+
a?: A;
|
|
52
|
+
b?: B;
|
|
53
|
+
};
|
|
54
|
+
declare const badgeTypes: {
|
|
55
|
+
readonly pillColor: "pill-color";
|
|
56
|
+
readonly badgeColor: "color";
|
|
57
|
+
readonly badgeModern: "modern";
|
|
58
|
+
};
|
|
59
|
+
type BadgeTypesFromConst = (typeof badgeTypes)[keyof typeof badgeTypes];
|
|
60
|
+
/**
|
|
61
|
+
* Type parameter whose constraint is derived from a `const` object's values — the exact
|
|
62
|
+
* `BadgeTypes = (typeof badgeTypes)[keyof typeof badgeTypes]` shape used in some component libraries.
|
|
63
|
+
*/
|
|
64
|
+
export declare function ConstDerivedBadge<T extends BadgeTypesFromConst>(props: {
|
|
65
|
+
type?: T;
|
|
66
|
+
}): {
|
|
67
|
+
type?: T;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Unconstrained type parameter — there is no enum to recover, so this must degrade
|
|
71
|
+
* gracefully (NOT become a union/enum, and never throw).
|
|
72
|
+
*/
|
|
73
|
+
export declare function UnconstrainedGeneric<T>(props: {
|
|
74
|
+
value?: T;
|
|
75
|
+
}): {
|
|
76
|
+
value?: T;
|
|
77
|
+
};
|
|
78
|
+
export {};
|
|
79
|
+
//# sourceMappingURL=generic-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic-props.d.ts","sourceRoot":"","sources":["../../src/test-fixtures/generic-props.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC/B,KAAK,SAAS,GAAG,YAAY,GAAG,OAAO,GAAG,QAAQ,CAAC;AACnD,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;IACzC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE;IACvD,+DAA+D;IAC/D,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,6CAA6C;IAC7C,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,8DAA8D;IAC9D,KAAK,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;CACxB;IANC,+DAA+D;WACxD,CAAC;IACR,6CAA6C;WACtC,IAAI;IACX,8DAA8D;YACtD,WAAW,CAAC,CAAC,CAAC;EAGvB;AAED,2DAA2D;AAC3D,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,IAAI,GAAG,KAAK,EAAE,KAAK,EAAE;IAC9D,GAAG,CAAC,EAAE,CAAC,CAAC;IACR,SAAS,CAAC,EAAE,CAAC,SAAS,IAAI,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;CAClE;UAFO,CAAC;gBACK,CAAC,SAAS,IAAI,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO;EAGjE;AAED,2DAA2D;AAC3D,wBAAgB,iBAAiB,CAC/B,CAAC,SAAS,IAAI,GAAG,IAAI,EACrB,CAAC,SAAS,IAAI,GAAG,IAAI,GAAG,IAAI,EAC5B,KAAK,EAAE;IAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAAC,CAAC,CAAC,EAAE,CAAC,CAAA;CAAE;QAAV,CAAC;QAAM,CAAC;EAEtB;AAED,QAAA,MAAM,UAAU;;;;CAIN,CAAC;AACX,KAAK,mBAAmB,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAExE;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,mBAAmB,EAAE,KAAK,EAAE;IACtE,IAAI,CAAC,EAAE,CAAC,CAAC;CACV;WADQ,CAAC;EAGT;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,KAAK,EAAE;IAAE,KAAK,CAAC,EAAE,CAAC,CAAA;CAAE;YAAH,CAAC;EAEzD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fixtures for GENERIC components whose props are typed THROUGH the component's own type
|
|
3
|
+
* parameter. This is the `Badge<T extends BadgeTypes>` shape, where `type?: T` and
|
|
4
|
+
* `color?: BadgeColor<T>` (= `…Map[T]`) were silently dropped: the analyzer had no branch
|
|
5
|
+
* for type parameters or the constraint-dependent types (indexed-access, conditional)
|
|
6
|
+
* that hinge on them, so they fell through to `misc`. Resolving each to its base
|
|
7
|
+
* constraint turns it into a string-literal union → an `enum` ("options") field.
|
|
8
|
+
*
|
|
9
|
+
* Each export below isolates one way a generic can carry an enum, plus the unconstrained
|
|
10
|
+
* case that must degrade gracefully (no enum, no crash).
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Bare type parameter (`kind?: T`) + indexed-access (`color?: ColorByKind[T]`), alongside
|
|
14
|
+
* a plain union control (`size`). Mirrors `Badge` most directly.
|
|
15
|
+
*/
|
|
16
|
+
export function GenericBadge(props) {
|
|
17
|
+
return props;
|
|
18
|
+
}
|
|
19
|
+
/** Conditional type that depends on the type parameter. */
|
|
20
|
+
export function ConditionalBadge(props) {
|
|
21
|
+
return props;
|
|
22
|
+
}
|
|
23
|
+
/** Multiple, independently-constrained type parameters. */
|
|
24
|
+
export function MultiGenericBadge(props) {
|
|
25
|
+
return props;
|
|
26
|
+
}
|
|
27
|
+
const badgeTypes = {
|
|
28
|
+
pillColor: 'pill-color',
|
|
29
|
+
badgeColor: 'color',
|
|
30
|
+
badgeModern: 'modern',
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Type parameter whose constraint is derived from a `const` object's values — the exact
|
|
34
|
+
* `BadgeTypes = (typeof badgeTypes)[keyof typeof badgeTypes]` shape used in some component libraries.
|
|
35
|
+
*/
|
|
36
|
+
export function ConstDerivedBadge(props) {
|
|
37
|
+
return props;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Unconstrained type parameter — there is no enum to recover, so this must degrade
|
|
41
|
+
* gracefully (NOT become a union/enum, and never throw).
|
|
42
|
+
*/
|
|
43
|
+
export function UnconstrainedGeneric(props) {
|
|
44
|
+
return props;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=generic-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic-props.js","sourceRoot":"","sources":["../../src/test-fixtures/generic-props.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAUH;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAsB,KAOjD;IACC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,gBAAgB,CAAyB,KAGxD;IACC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,iBAAiB,CAG/B,KAAuB;IACvB,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,GAAG;IACjB,SAAS,EAAE,YAAY;IACvB,UAAU,EAAE,OAAO;IACnB,WAAW,EAAE,QAAQ;CACb,CAAC;AAGX;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAgC,KAEhE;IACC,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAI,KAAoB;IAC1D,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-fixtures/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-fixtures/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test-fixtures/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test-fixtures/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fixtures for components with ITERABLE-typed props — the react-aria collection
|
|
3
|
+
* shape (`disabledKeys?: Iterable<Key>`, `selectedKeys?: Selection`). These carry
|
|
4
|
+
* the `Object` flag plus a `[Symbol.iterator]` member but no numeric index, so
|
|
5
|
+
* without a dedicated iterable branch the analyzer emitted them as objects with a
|
|
6
|
+
* spurious `__@iterator` property (rendered in Knapsack as "should be object").
|
|
7
|
+
* They should resolve to ARRAY fields of their element type instead.
|
|
8
|
+
*/
|
|
9
|
+
type Key = string | number;
|
|
10
|
+
/** Mirrors react-stately's `Selection = 'all' | Set<Key>`. */
|
|
11
|
+
type Selection = 'all' | Set<Key>;
|
|
12
|
+
export declare function CollectionComponent(props: {
|
|
13
|
+
/** react-aria's `disabledKeys?: Iterable<Key>`. */
|
|
14
|
+
disabledKeys?: Iterable<Key>;
|
|
15
|
+
/** A plain `Set<string>`. */
|
|
16
|
+
tags?: Set<string>;
|
|
17
|
+
/** `ReadonlySet<number>`. */
|
|
18
|
+
ids?: ReadonlySet<number>;
|
|
19
|
+
/** react-stately `Selection` (`'all' | Set<Key>`). */
|
|
20
|
+
selectedKeys?: Selection;
|
|
21
|
+
}): {
|
|
22
|
+
/** react-aria's `disabledKeys?: Iterable<Key>`. */
|
|
23
|
+
disabledKeys?: Iterable<Key>;
|
|
24
|
+
/** A plain `Set<string>`. */
|
|
25
|
+
tags?: Set<string>;
|
|
26
|
+
/** `ReadonlySet<number>`. */
|
|
27
|
+
ids?: ReadonlySet<number>;
|
|
28
|
+
/** react-stately `Selection` (`'all' | Set<Key>`). */
|
|
29
|
+
selectedKeys?: Selection;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=iterable-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iterable-props.d.ts","sourceRoot":"","sources":["../../src/test-fixtures/iterable-props.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,KAAK,GAAG,GAAG,MAAM,GAAG,MAAM,CAAC;AAE3B,8DAA8D;AAC9D,KAAK,SAAS,GAAG,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;AAElC,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,mDAAmD;IACnD,YAAY,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC7B,6BAA6B;IAC7B,IAAI,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnB,6BAA6B;IAC7B,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1B,sDAAsD;IACtD,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B;IARC,mDAAmD;mBACpC,QAAQ,CAAC,GAAG,CAAC;IAC5B,6BAA6B;WACtB,GAAG,CAAC,MAAM,CAAC;IAClB,6BAA6B;UACvB,WAAW,CAAC,MAAM,CAAC;IACzB,sDAAsD;mBACvC,SAAS;EAGzB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fixtures for components with ITERABLE-typed props — the react-aria collection
|
|
3
|
+
* shape (`disabledKeys?: Iterable<Key>`, `selectedKeys?: Selection`). These carry
|
|
4
|
+
* the `Object` flag plus a `[Symbol.iterator]` member but no numeric index, so
|
|
5
|
+
* without a dedicated iterable branch the analyzer emitted them as objects with a
|
|
6
|
+
* spurious `__@iterator` property (rendered in Knapsack as "should be object").
|
|
7
|
+
* They should resolve to ARRAY fields of their element type instead.
|
|
8
|
+
*/
|
|
9
|
+
export function CollectionComponent(props) {
|
|
10
|
+
return props;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=iterable-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iterable-props.js","sourceRoot":"","sources":["../../src/test-fixtures/iterable-props.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,MAAM,UAAU,mBAAmB,CAAC,KASnC;IACC,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fixtures reproducing the "component whose props is a union type" shape.
|
|
3
|
+
*
|
|
4
|
+
* When a component's props parameter is a union of interfaces (`A | B`) that
|
|
5
|
+
* share enum props, the shared enum literals sit one level deeper than usual
|
|
6
|
+
* (`function → props-union → interface → prop-union → literal`). This is the
|
|
7
|
+
* exact shape of GSK's `Button` (`ButtonVariantProps | LinkVariantProps`) and
|
|
8
|
+
* previously caused `size`/`color` to infer as a plain `string` instead of an
|
|
9
|
+
* enum, because the literals were nested past `maxDepth`.
|
|
10
|
+
*/
|
|
11
|
+
interface UnionButtonCommonProps {
|
|
12
|
+
/** The size variant */
|
|
13
|
+
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
14
|
+
/** The color variant */
|
|
15
|
+
color?: 'primary' | 'secondary' | 'tertiary';
|
|
16
|
+
isDisabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface UnionButtonVariantProps extends UnionButtonCommonProps {
|
|
19
|
+
type?: 'button' | 'submit' | 'reset';
|
|
20
|
+
}
|
|
21
|
+
interface UnionLinkVariantProps extends UnionButtonCommonProps {
|
|
22
|
+
href?: string;
|
|
23
|
+
}
|
|
24
|
+
export type UnionButtonProps = UnionButtonVariantProps | UnionLinkVariantProps;
|
|
25
|
+
/**
|
|
26
|
+
* A button-like component whose props is a union type.
|
|
27
|
+
*/
|
|
28
|
+
export declare function UnionPropsButton(props: UnionButtonProps): UnionButtonProps;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=union-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"union-props.d.ts","sourceRoot":"","sources":["../../src/test-fixtures/union-props.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,UAAU,sBAAsB;IAC9B,uBAAuB;IACvB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACjC,wBAAwB;IACxB,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;IAC7C,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,uBAAwB,SAAQ,sBAAsB;IAC9D,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;CACtC;AAED,UAAU,qBAAsB,SAAQ,sBAAsB;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,gBAAgB,GAAG,uBAAuB,GAAG,qBAAqB,CAAC;AAE/E;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,oBAEvD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fixtures reproducing the "component whose props is a union type" shape.
|
|
3
|
+
*
|
|
4
|
+
* When a component's props parameter is a union of interfaces (`A | B`) that
|
|
5
|
+
* share enum props, the shared enum literals sit one level deeper than usual
|
|
6
|
+
* (`function → props-union → interface → prop-union → literal`). This is the
|
|
7
|
+
* exact shape of GSK's `Button` (`ButtonVariantProps | LinkVariantProps`) and
|
|
8
|
+
* previously caused `size`/`color` to infer as a plain `string` instead of an
|
|
9
|
+
* enum, because the literals were nested past `maxDepth`.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* A button-like component whose props is a union type.
|
|
13
|
+
*/
|
|
14
|
+
export function UnionPropsButton(props) {
|
|
15
|
+
return props;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=union-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"union-props.js","sourceRoot":"","sources":["../../src/test-fixtures/union-props.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAoBH;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAuB;IACtD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
1
|
+
import type ts from 'typescript';
|
|
2
2
|
export type TypeInfoCommon = {
|
|
3
3
|
tsRawType: string;
|
|
4
4
|
isOptional?: boolean;
|
|
@@ -42,6 +42,23 @@ export type TypeInfo = ({
|
|
|
42
42
|
} & TypeInfoCommon) | ({
|
|
43
43
|
type: 'misc';
|
|
44
44
|
} & TypeInfoCommon);
|
|
45
|
+
/**
|
|
46
|
+
* Where a property symbol was declared. `getDeclaringInterface` only returns
|
|
47
|
+
* this object when it could resolve a containing interface or type alias —
|
|
48
|
+
* absent declarations get `undefined` instead, so both fields here are
|
|
49
|
+
* guaranteed present whenever the value exists.
|
|
50
|
+
*/
|
|
51
|
+
export type SymbolDeclaringInterface = {
|
|
52
|
+
/** Name of the interface/type-alias that declares this symbol. */
|
|
53
|
+
interfaceName: string;
|
|
54
|
+
/**
|
|
55
|
+
* True when every declaration of this symbol lives inside a known React DOM
|
|
56
|
+
* type interface (`HTMLAttributes`, `*HTMLAttributes`, `DOMAttributes`,
|
|
57
|
+
* `AriaAttributes`, `SVGAttributes`, etc.). Used by renderers to filter the
|
|
58
|
+
* inherited DOM-attribute deluge from inferred specs.
|
|
59
|
+
*/
|
|
60
|
+
isReactDomInterface: boolean;
|
|
61
|
+
};
|
|
45
62
|
export type SymbolInfo = {
|
|
46
63
|
name: string;
|
|
47
64
|
jsDoc?: {
|
|
@@ -57,5 +74,10 @@ export type SymbolInfo = {
|
|
|
57
74
|
type?: ts.Type;
|
|
58
75
|
symbolFlags: Array<keyof typeof ts.SymbolFlags>;
|
|
59
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Where this symbol is declared. Populated only for properties of object
|
|
79
|
+
* types (i.e. component props). Absent for synthetic or unresolvable symbols.
|
|
80
|
+
*/
|
|
81
|
+
declaredIn?: SymbolDeclaringInterface;
|
|
60
82
|
};
|
|
61
83
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,C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,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACvC,qBAAqB,EAAE,UAAU,EAAE,CAAC;IACpC,qBAAqB,EAAE,QAAQ,CAAC;IAChC,SAAS,EAAE,UAAU,CAAC;CACvB,GAAG,cAAc,CAAC,GACnB,CAAC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG,cAAc,CAAC,GACtC,CAAC;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,GAAG,cAAc,CAAC,GAClC,CAAC;IACC,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,cAAc,CAAC,CAAC;AAExB;;;;;GAKG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,kEAAkE;IAClE,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE;QACN,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACnD,CAAC;IACF,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE;QACV,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC;QACf,WAAW,EAAE,KAAK,CAAC,MAAM,OAAO,EAAE,CAAC,WAAW,CAAC,CAAC;KACjD,CAAC;IACF;;;OAGG;IACH,UAAU,CAAC,EAAE,wBAAwB,CAAC;CACvC,CAAC"}
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC7D,KAAK,EACL,UAAU,GACX,EAAE;IACD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,UAAU,EAAE,CAAC,CAAC;CACf,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAqBjB;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,EACvD,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,CAAC,GACN,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,CAKpD"}
|
package/dist/utils.js
CHANGED
|
@@ -27,11 +27,9 @@ export function getSetFlags({ flags, enumObject, }) {
|
|
|
27
27
|
return Object.entries(enumObject)
|
|
28
28
|
.filter(([, value]) => {
|
|
29
29
|
// Only consider power of 2 values (single flags)
|
|
30
|
-
// eslint-disable-next-line no-bitwise
|
|
31
30
|
if ((value & (value - 1)) !== 0)
|
|
32
31
|
return false;
|
|
33
32
|
// Check if the flag is set
|
|
34
|
-
// eslint-disable-next-line no-bitwise
|
|
35
33
|
return (flags & value) !== 0;
|
|
36
34
|
})
|
|
37
35
|
.map(([key]) => key);
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,WAAW,CAAoC,EAC7D,KAAK,EACL,UAAU,GAUX;IACC;;;;;;;;;OASG;IACH,OAAQ,MAAM,CAAC,OAAO,CAAC,UAAU,CAA8B;SAC5D,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE;QACpB,iDAAiD;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,WAAW,CAAoC,EAC7D,KAAK,EACL,UAAU,GAUX;IACC;;;;;;;;;OASG;IACH,OAAQ,MAAM,CAAC,OAAO,CAAC,UAAU,CAA8B;SAC5D,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE;QACpB,iDAAiD;QAEjD,IAAI,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QAC9C,2BAA2B;QAE3B,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC,CAAC;SACD,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,QAAkB,EAClB,IAAO;IAEP,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QAC3B,MAAM,GAAG,GAAG,wBAAwB,IAAI,WAAW,QAAQ,CAAC,IAAI,GAAG,CAAC;QACpE,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knapsack/spec-utils",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "5.0.0
|
|
4
|
+
"version": "5.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -20,23 +20,23 @@
|
|
|
20
20
|
"test": "vitest run"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@knapsack/utils": "5.0.0
|
|
23
|
+
"@knapsack/utils": "5.0.0",
|
|
24
24
|
"json-stable-stringify": "^1.3.0",
|
|
25
25
|
"quick-lru": "^7.3.0",
|
|
26
|
-
"typescript": "^5.9.
|
|
26
|
+
"typescript": "^5.9.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@knapsack/angular-sandbox-components": "5.0.0
|
|
30
|
-
"@knapsack/eslint-config-starter": "5.0.0
|
|
31
|
-
"@knapsack/file-utils": "5.0.0
|
|
32
|
-
"@knapsack/prettier-config": "5.0.0
|
|
33
|
-
"@knapsack/sandbox-components": "5.0.0
|
|
34
|
-
"@knapsack/types": "5.0.0
|
|
35
|
-
"@knapsack/typescript-config-starter": "5.0.0
|
|
29
|
+
"@knapsack/angular-sandbox-components": "5.0.0",
|
|
30
|
+
"@knapsack/eslint-config-starter": "5.0.0",
|
|
31
|
+
"@knapsack/file-utils": "5.0.0",
|
|
32
|
+
"@knapsack/prettier-config": "5.0.0",
|
|
33
|
+
"@knapsack/sandbox-components": "5.0.0",
|
|
34
|
+
"@knapsack/types": "5.0.0",
|
|
35
|
+
"@knapsack/typescript-config-starter": "5.0.0",
|
|
36
36
|
"@mui/material": "^5.18.0",
|
|
37
|
-
"@types/node": "^
|
|
38
|
-
"eslint": "^
|
|
39
|
-
"vitest": "^
|
|
37
|
+
"@types/node": "^22.19.11",
|
|
38
|
+
"eslint": "^9.20.0",
|
|
39
|
+
"vitest": "^4.1.9"
|
|
40
40
|
},
|
|
41
41
|
"license": "GPL-2.0-or-later",
|
|
42
42
|
"publishConfig": {
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"directory": "apps/client/libs/spec-utils",
|
|
48
48
|
"type": "git"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "31e09ba72245b95bef52e73ce5076de51936286c"
|
|
51
51
|
}
|
package/vitest.config.mts
CHANGED
|
@@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config';
|
|
|
3
3
|
// https://vitest.dev/config/
|
|
4
4
|
export default defineConfig({
|
|
5
5
|
test: {
|
|
6
|
+
testTimeout: 30_000,
|
|
6
7
|
// Ava uses `*.test.*` so we use a different pattern
|
|
7
8
|
include: ['src/**/*.{vtest,vitest}.{ts,tsx}'],
|
|
8
9
|
includeSource: ['src/**/*.{ts,tsx}'],
|
package/.eslintignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
dist
|