Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fixture and test cases to make clear the interaction between @typedef, @module, and @global. #1801

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/jsdoc/test/fixtures/typedeftag3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @module m */

/** @typedef {Object} ModuleScopedTypedef */

/**
* @global
* @typedef {Object} GloballyScopedTypedef
*/
18 changes: 18 additions & 0 deletions packages/jsdoc/test/specs/tags/typedeftag.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ describe('@typedef tag', () => {
expect(calculatorBattery).toBeObject();
expect(calculatorBattery.scope).toBe('global');
});

it('When a symbol has a @typedef tag with a name, in file with module scope, the scope is `inner`.', () => {
const docSet = jsdoc.getDocSetFromFile('test/fixtures/typedeftag3.js');
const moduleScopedTypedef = docSet.getByLongname('module:m~ModuleScopedTypedef')[0];


expect(moduleScopedTypedef).toBeObject();
expect(moduleScopedTypedef.scope).toBe('inner');
});

it('When a symbol has @global on a @typedef tag with a name, in a file with module scope, the scope is `global`.', () => {
const docSet = jsdoc.getDocSetFromFile('test/fixtures/typedeftag3.js');

const globallyScopedTypedef = docSet.getByLongname('GloballyScopedTypedef')[0];

expect(globallyScopedTypedef).toBeObject();
expect(globallyScopedTypedef.scope).toBe('global');
});
});

describe('Closure Compiler tags', () => {
Expand Down