Skip to content

Support @abstract JSDoc tag #17227

Open
Open
@ghost

Description

TypeScript Version: nightly (2.5.0-dev.20170712)

Code

/** @abstract */
class C {}
new C();

Expected behavior:

Error.

Actual behavior:

No error.

Activity

added this to the TypeScript 3.2 milestone on Aug 15, 2018
tschaub

tschaub commented on Sep 1, 2018

@tschaub
Contributor

Adding a bit more to this, it would be nice if @abstract on methods were supported.

For example, with this code:

/**
 * @abstract
 */
class Integer {
  /**
   * @abstract
   * @return {number} A number.
   */
  get() {}
}
 
class FortyTwo extends Integer {
  get() {
    return 42
  }
}


/**
 * @returns {number} The return.
 */
function getFortyTwo() {
  const number = new FortyTwo();
  return number.get();
}

tsc --pretty (at 3.1.0-dev.20180901) results in this error:

main.js:8:15 - error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value.

8    * @return {number} A number.
                ~~~~~~

29 remaining items

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

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @tschaub@kohlmannj@sandersn@trusktr@a-tarasyuk

      Issue actions

        Support `@abstract` JSDoc tag · Issue #17227 · microsoft/TypeScript