Skip to content

typescript type, java script shows: Assigned expression type string is not assignable... #1313

@deadmann

Description

@deadmann

I'm using typescript side by Javascript... on Webstorm, and IntelliJ depend on the cases, and i found that it returns error, maybe it's due to one of these reasons lack of their implementation, or maybe i need to know something i do not know about JS Doc, or maybe it's lack of JsDoc for such cases....

the code i use in my TS:
type X='a'|'b'|'c';
and somewhere in my js, i say,

/**
  * @param z {X}
  */
function f(z){
    if(z =='a')
        ....
}

and when i go over the equality signs, it show a message:
"Assigned expression type string is not assignable to type IterationOption, which IterationOption is my X in above case
Anyway, the IDE does not understand that i use type, and it doesn't understand it if i put Js Doc '@type' on it's head even if i do that.

Please Refer to These Links, as I Followed Them Myself:
http://stackoverflow.com/questions/15490560/create-an-enum-with-string-values-in-typescript
https://basarat.gitbooks.io/typescript/content/docs/types/literal-types.html

YouTrack Link:
https://youtrack.jetbrains.com/issue/IDEA-166433

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions