-
-
Notifications
You must be signed in to change notification settings - Fork 75
Handle AsExpression in TS when treated as type hint #25
Comments
This is expected because we haven't started implementing TypeScript-specific syntax yet. Happy to get a PR, though. :) |
In order to address this, we need to determine what type of AST node should represent this construct. If I understand this correctly, the
The syntax for Flow type casts looks more like
Unfortunately, we haven't yet defined what See #13 for the current status of the development plan. |
Typescript has several ways of type hinting
thing is I want get it working fast at least for what is used in angular 2 so must probably I will have to use mine repo :( |
@valorkin sorry, we just can't skip ahead to do this. What you have will make the parser continue without error, but you're producing a correct AST, so it will likely cause unexpected errors when used with ESLint. |
I am not yet AST maniac, I see some wrong tokens so If you can say precise what is wrong with it, actually AST for |
@valorkin please see my previous comment. Even we create a node type for casting, we still need to create the node types for all types and be able to parse all types. We just aren't there yet, so I'm afraid you'll need to wait until we get to phase 4 of the development plan. |
what if can just remove them from AST from now? |
@nzakas It seems that I moved you to some misconception this is how type annotations looks in TS interface Point {
x: number;
y: number;
}
function getX(p: Point) {
return p.x;
}
class CPoint {
x: number;
y: number;
constructor(x: number, y: number) {
this.x = x;
this.y = y;
}
}
something like this |
class Test {}
interface Point {
y: Test;
} part for |
@valorkin this project is not ready to be used (the readme says it's experimental), so I'm not willing to begin making changes like this yet. You can feel free to make whatever changes you want in your own fork, we just can't start forcing syntax in at this point. Creating the correct AST is important for ESLint to work correctly, which is why we have to take the time to do it right. |
@nzakas roger that |
In typescript you can give a hint to tsc about variable type
using keyword
as
currently it throws an exception
The text was updated successfully, but these errors were encountered: