GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — JSDoc: Support `@readonly` tag · Issue #17233 · microsoft/TypeScript

JSDoc: Support @readonly tag #17233

New issue
Copy link
New issue
Copy link
Closed
#35790
Closed
JSDoc: Support @readonly tag#17233
#35790
Copy link
Labels
Domain: JSDocRelates to JSDoc parsing and type generationRelates to JSDoc parsing and type generationDomain: JavaScriptThe issue relates to JavaScript specificallyThe issue relates to JavaScript specificallyIn DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript

Description

@ghost
ghost
opened on Jul 16, 2017

TypeScript Version: nightly (2.5.0-dev.20170712)

Code

class C {
	constructor() {
		/**
		 * @readonly
		 * @type {number}
		 */
		this.x = 0;
	}

	m() {
		this.x = "1"; // Error
		this.x = 1; // No error
	}
}

Expected behavior:

Both lines in m are errors.

Actual behavior:

No error when trying to write to @readonly property.

Reacted by Ian Copp, stephen, Guilherme Lepsch, Cardin Lee, Derek Sifford, Arend van Beelen jr., Matt Tingen, Rannie Peralta, Michael Schmidt, AnyhowStep and 4 more
Reacted by stephen
Reacted by stephen and Rannie Peralta

Activity

  1. ghost added
    Salsa
    on Jul 16, 2017
  2. Mohamed Hegazy (mhegazy)
    added
    Domain: JSDocRelates to JSDoc parsing and type generationRelates to JSDoc parsing and type generation
    SuggestionAn idea for TypeScriptAn idea for TypeScript
    on Aug 31, 2017
  3. niedzielski commented on Oct 14, 2018

    @niedzielski
    stephen (niedzielski)
    on Oct 14, 2018
    More actions

    This would be awesome! There's already support for Readonly and readonly in JSDoc closure syntax. E.g.:

    /** 
     * @typedef {Readonly<{
     *   foo: ReadonlyArray<Foo>
     *   bar: number
     * }>} Baz
     */
    /**
     * @typedef {{
     *   readonly foo: ReadonlyArray<Foo>
     *   readonly bar: number
     * }} Baz
     */

    Both of the above examples work as expected. However, resolving this ticket would enable readonly support for member properties too:

    /**
     * @typedef {Object} Baz
     * @prop {ReadonlyArray<Foo>} foo This syntax supports comments.
     * @prop {number} bar But there's no support for marking properties as @readonly.
     */
  4. Wesley Wigham (weswigham)
    added
    In DiscussionNot yet reached consensusNot yet reached consensus
    on Nov 6, 2018
  5. Wesley Wigham (weswigham)
    added
    Domain: JavaScriptThe issue relates to JavaScript specificallyThe issue relates to JavaScript specifically
    and removed
    Salsa
    on Nov 29, 2018
  6. Nathan Shively-Sanders (sandersn)
    closed this as completedin #35790on Dec 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: JSDocRelates to JSDoc parsing and type generationRelates to JSDoc parsing and type generationDomain: JavaScriptThe issue relates to JavaScript specificallyThe issue relates to JavaScript specificallyIn DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.