Skip to content

jsdoc failure in .ts file  #20774

Description

@shynome

TypeScript Version: 2.6.2
VSCode Version: 1.19.0

Code

/**
 * @param {string} nonPrimitive
 */
function test(nonPrimitive) {}

test(1)

tsconfig.json

{
  "compilerOptions": {
    "checkJs": true,
    "allowJs": true,
    "target": "es5",
    "moduleResolution": "node",
    "module": "es2015",
    "strict": true,
    "noImplicitThis": true
  }
}

Expected behavior:
image

Actual behavior:
image

Activity

  1. ajafff commented on Dec 19, 2017

    @ajafff
    Contributor

    Since you can add type annotations in typescript, it does not use JSDoc for types. This is by design.
    You need to use nonPrimitive: string instead.

    IIRC there's a quickfix that converts JSDoc types to type annotations.

  2. shynome commented on Dec 19, 2017

    @shynome
    Author

    In some cases my project team can't use the compile tools , And now I have a problem in vue typescript component , in .ts file the vue component this type is right, but if I rename the extname .ts to .js, this vue component this type is any.
    Because typescript is a superset of javascript, so only write javascript is good, but I found I can't define type by jsdoc, it bothered me and make me write javascript without typescript help as before .

    Expected behavior:

    image

    Actual behavior:

    image

    The git url is can report my problem
    https://github.com/shynome/typescript-vue-component-this-type-lost-in-js-sandbox

  3. shynome commented on Dec 19, 2017

    @shynome
    Author

    yeah, I find out jsdoc since begin is design for js not ts , so ts file can't use jsdoc to define type .

  4. locked and limited conversation to collaborators on Jun 21, 2018
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

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions