Skip to content
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

Dotted type in jsdoc is not parsed correctly #16268

Closed
flaviut opened this issue Jun 5, 2017 · 4 comments
Closed

Dotted type in jsdoc is not parsed correctly #16268

flaviut opened this issue Jun 5, 2017 · 4 comments
Assignees
Labels
Bug A bug in TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation Fixed A PR has been merged for this issue

Comments

@flaviut
Copy link

flaviut commented Jun 5, 2017

TypeScript Version: 2.4.0-dev.20170605
Code

import React from 'react';

/**
 * @param {React.FormEventHandler<Checkbox>} a
 */
function foo(a) {}

Expected behavior:
The language service parses the jsdoc as documented in https://github.com/Microsoft/TypeScript/wiki/JSDoc-support-in-JavaScript

Actual behavior:
[js] '}' expected. at the <. This appears to be a problem with the dotted type, i.e. import React, {FormEventHandler} from react; …{FormEventHandler<Checkbox>} … works fine.

Reproduced using visual studio code (I don't know how to manually launch and use the language service).

@DanielRosenwasser
Copy link
Member

Does it work if you write import * as React from "react"?

@flaviut
Copy link
Author

flaviut commented Jun 6, 2017

Nope:

import * as React from 'react';

/**
 * @param {React.FormEventHandler<Checkbox>} a
 */
function foo(a) {}

'}' expected.


This error also happens, as expected, so I think that confirms that the type can be correctly resolved:

import React from 'react';

/**
 * @param {React.FormEventHandler} a
 */
function foo(a) {}

Generic type 'FormEventHandler' requires 1 type argument(s).

@mhegazy mhegazy added the Bug A bug in TypeScript label Jun 8, 2017
@mhegazy mhegazy added this to the TypeScript 2.5 milestone Jun 8, 2017
@mhegazy mhegazy added the Domain: JSDoc Relates to JSDoc parsing and type generation label Jun 8, 2017
@Volox
Copy link

Volox commented Jul 11, 2017

Is this also somehow related to #14233 ? Is there a semantic difference from namespace and dotted notation in Typescript?

@sandersn
Copy link
Member

JSDoc syntax requires a dot before the type arguments: React.FormEventHandler.<CheckBox>. Closure Compiler syntax does not, though.

#17176 should have fixed this because now JSDoc and Typescript use the same parser for all types, so this should be parsed as a normal Typescript-syntax type reference.

@sandersn sandersn added the Fixed A PR has been merged for this issue label Jul 17, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: JSDoc Relates to JSDoc parsing and type generation Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

5 participants