JSDoc tag

@public

  • Checked by TypeScript
  • Since TypeScript 3.8

@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

account.js account.ts TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026: No errors. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. No errors. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. No errors. checked 21 October 2026
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();
@public spells out the default.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": ["*.js"]
}
account.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: account.js(3,7): error TS18010: An accessibility modifier cannot be used with a private identifier. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. account.js(3,7): error TS18010: An accessibility modifier cannot be used with a private identifier. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. account.js(3,7): error TS18010: An accessibility modifier cannot be used with a private identifier. checked 21 October 2026
export class Account {
  /** @public */error TS18010: An accessibility modifier cannot be used with a private identifier.
  #balance = 0;

  get balance() {
    return this.#balance;
  }
}
An accessibility tag cannot go on a #private field.
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, @public does not work in constructor functions.
  • The public keyword is TypeScript syntax and an error in a .js file (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

Last reviewed 20 October 2026.