@public says a class member can be used from anywhere. Members are public unless marked otherwise, so the tag never changes what TypeScript allows; the handbook describes it as always implied. TypeScript 3.8 added it along with the other JSDoc property modifiers.
Some teams write it anyway in classes that mix public, @protected and @private members, so that every member states its access. It is the JavaScript spelling of TypeScript's public modifier.
At a glance
| Use | JSDoc in a .js file | TypeScript in a .ts file |
|---|---|---|
| A public member | /** @public */
owner = ""; | public owner = ""; |
Examples
export class Account {
/** @public */
owner = "";
/** @private */
balance = 0;
/** @public */
summary() {
return `${this.owner}: ${this.balance}`;
}
}
const account = new Account();
account.owner = "Jane";
account.summary();export class Account {
public owner = "";
private balance = 0;
public summary() {
return `${this.owner}: ${this.balance}`;
}
}
const account = new Account();
account.owner = "Jane";
account.summary();jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.js"]
} export class Account {
/** @public */error TS18010: An accessibility modifier cannot be used with a private identifier.
#balance = 0;
get balance() {
return this.#balance;
}
}jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.js"]
} Where it is an error
On a #private field: #balance is private by its name, and TypeScript rejects any accessibility tag on it with TS18010 ("An accessibility modifier cannot be used with a private identifier"). The error is reported on the tag itself.
Gotchas
- Like the other accessibility tags,
@publicdoes not work in constructor functions. - The
publickeyword is TypeScript syntax and an error in a.jsfile (TS8009).
Questions
Do I need @public in JSDoc?
No. Leave it out unless your team wants every member's access written down. TypeScript treats untagged members as public.
Sources
- TypeScript 3.8: JSDoc property modifiers · TypeScript release notes
- JSDoc Reference: property modifiers · TypeScript handbook
- @public · JSDoc
Last reviewed 20 October 2026.