Skip to content

jsdoc failure in .ts file #20774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shynome opened this issue Dec 19, 2017 · 3 comments
Closed

jsdoc failure in .ts file #20774

shynome opened this issue Dec 19, 2017 · 3 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@shynome
Copy link

shynome commented Dec 19, 2017

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

@ajafff
Copy link
Contributor

ajafff commented Dec 19, 2017

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.

@shynome
Copy link
Author

shynome commented Dec 19, 2017

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

@shynome
Copy link
Author

shynome commented Dec 19, 2017

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

@shynome shynome closed this as completed Dec 19, 2017
@RyanCavanaugh RyanCavanaugh added the Question An issue which isn't directly actionable in code label Dec 19, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

3 participants