-
Notifications
You must be signed in to change notification settings - Fork 43
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
Parse and ignore private members #49
Conversation
modifiers ~ propertyName ~ optionalMarker >> { | ||
case mods ~ name ~ optional => ( | ||
functionSignature ^^ (FunctionMember(name, optional, _, mods)) | ||
| typeAnnotation ^^ (PropertyMember(name, optional, _, mods)) | ||
) | ||
} | ||
} | "private" ~> propertyName ~ (functionSignature | ";") ^^^ PrivateMember |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The semi-colon must not be there. It is already present in the definition of memberBlock
.
I suggest extracting this case in a separate lazy val privateMember
, and add privateMember
as an alternative to typeMember
rather than to namedMember
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
3550b1a
to
95a6d44
Compare
@@ -262,7 +262,7 @@ class TSDefParser extends StdTokenParsers with ImplicitConversions { | |||
memberBlock ^^ ObjectType | |||
|
|||
lazy val memberBlock: Parser[List[MemberTree]] = | |||
"{" ~> rep(typeMember <~ opt(";" | ",")) <~ "}" | |||
"{" ~> rep((typeMember | privateMember) <~ opt(";" | ",")) <~ "}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Er, sorry, I meant as an alternative in the definition of lazy val typeMember
. So a typeMember
can be a callMember
, etc., or a privateMember
. typeMember
is any kind of member than kind appear in a memberBlock
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sure, totally makes sense looking more closely. So next try :)
95a6d44
to
1dff1dc
Compare
1dff1dc
to
b1b04ab
Compare
private static members can occur as well so I just added support for that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Compiler generated .d.ts files contain private methods/fields in order to avoid name collisions when subclassing in TypeScript microsoft/TypeScript#1867. The type of private fields is not included.
The approach in this PR is to just ignore them.