Skip to content

Commit 730e701

Browse files
miraoclaude
andcommitted
fix(types): keep object-literal singletons visible to jsdoc for dtslint (#5635)
The previous commit wrapped the output/store/container singletons by inlining their object literal into the realmSingleton() factory call. tsd-jsdoc (npm run def) couldn't associate the `@namespace`/`@type` JSDoc with a literal nested in an arrow argument, so the regenerated typings dropped the `output` and `store` namespaces and lost the Result reference — breaking dtslint in CI. Keep the plain object literal (so jsdoc still sees it) and share it at export time via realmSingleton(() => literal), the same shape recorder.js already uses. Runtime behavior is unchanged; `npm run def` now regenerates the committed typings unchanged and dtslint passes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent e02f5fa commit 730e701

3 files changed

Lines changed: 15 additions & 13 deletions

File tree

lib/container.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,7 @@ let beforeCalledSet = new Set()
3434
export function getBeforeCalledSet() { return beforeCalledSet }
3535
export function resetBeforeCalledSet() { beforeCalledSet = new Set() }
3636

37-
// Shared across realms (see realm.js): the runner (ESM) populates this state in
38-
// Container.create(); a test/page object that does `import { container } from "codeceptjs"`
39-
// is loaded as CommonJS and would otherwise read an empty, never-populated copy. Pointing
40-
// the module variable at the shared object means the static accessors in every realm
41-
// operate on the live helpers/support/plugins.
42-
let container = realmSingleton('__codeceptjs_container_state', () => ({
37+
let container = {
4338
helpers: {},
4439
support: {},
4540
proxySupport: {},
@@ -56,7 +51,14 @@ let container = realmSingleton('__codeceptjs_container_state', () => ({
5651
result: null,
5752
sharedKeys: new Set(), // Track keys shared via share() function
5853
tsFileMapping: null, // TypeScript file mapping for error stack fixing
59-
}))
54+
}
55+
56+
// Shared across realms (see realm.js): the runner (ESM) populates this state in
57+
// Container.create(); a test/page object that does `import { container } from "codeceptjs"`
58+
// is loaded as CommonJS and would otherwise read an empty, never-populated copy. Pointing
59+
// the module variable at the shared object means the static accessors in every realm
60+
// operate on the live helpers/support/plugins.
61+
container = realmSingleton('__codeceptjs_container_state', () => container)
6062

6163
/**
6264
* Dependency Injection Container

lib/output.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let newline = true
2222
* @alias output
2323
* @namespace
2424
*/
25-
const output = realmSingleton('__codeceptjs_output', () => ({
25+
const output = {
2626
colors,
2727
styles,
2828
print,
@@ -303,9 +303,9 @@ const output = realmSingleton('__codeceptjs_output', () => ({
303303
msg += ' '
304304
print(status + style(msg) + colors.grey(` // ${duration}`))
305305
},
306-
}))
306+
}
307307

308-
export default output
308+
export default realmSingleton('__codeceptjs_output', () => output)
309309

310310
function print(...msg) {
311311
if (outputProcess) {

lib/store.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { realmSingleton } from './realm.js'
44
* Global store for current session
55
* @namespace
66
*/
7-
const store = realmSingleton('__codeceptjs_store', () => ({
7+
const store = {
88
// --- Required (set once via initialize(), immutable after) ---
99

1010
/** @type {string | null} */
@@ -112,6 +112,6 @@ const store = realmSingleton('__codeceptjs_store', () => ({
112112
this._codeceptDir = opts.codeceptDir
113113
this._outputDir = opts.outputDir
114114
},
115-
}))
115+
}
116116

117-
export default store
117+
export default realmSingleton('__codeceptjs_store', () => store)

0 commit comments

Comments
 (0)