Skip to content

Error message related to JSDoc for non-JSDoc syntax error #29648

Description

@FabianLauer

TypeScript Version:

  • 3.4.0-dev.20190130
  • 3.2.4

Search Terms:

  • ts8020
  • "jsdoc types can only be used"
  • "JSDoc types can only be used inside documentation comments"

Code

function isString(str: string): str is string! {
  return typeof str === 'string';
}

Expected behavior:

Error message should not mention JSDoc syntax. IMHO it should be TS1144: '{' or ';' expected., which is the case with this code for example:

function isString(str: string): str is string? {
  return typeof str === 'string';
}

Actual behavior:

Error message states that this is JSDoc syntax (am not sure it even is). Full output of tsc:

> tsc test.ts
test.ts:1:40 - error TS8020: JSDoc types can only be used inside documentation comments.

1 function isString(str: string): str is string! {
                                         ~~~~~~~


Found 1 error.

Playground Link:
here

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Error MessagesThe issue relates to error messagingGood First IssueWell scoped, documented and has the green lightHelp WantedYou can do this

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions