-
Notifications
You must be signed in to change notification settings - Fork 194
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
Error: Unexpected! Inserting syntax kind of PropertyDeclaration, but Parameter was inserted. #57
Comments
Also, the variables get declared after the constructor. Wouldn't it be better before it? |
Thanks, I'm able to reproduce this and I've fixed the problem. Sorry about that! It was related to a change in behaviour I made in #39. When fixing this, it also made me notice an issue related to inserting. I'll fix that tonight as part of this and then do a new patch release. #26 will deal with member ordering when calling an |
Also, something helpful, I cannot recover properties in an existing If you want to modify an existing constructor, you can't. Only remove and add a new one. |
… exists overloads. Also changed Node.getAllChildren() to Node.getDescendants().
@gp187 this is fixed in 0.49.0 so I'm going to close this. Let me know if you encounter any issues. -- You should be able to get the parameters properties from a constructor by filtering the parameters for ones that are parameter properties: const ctorProps = ctor.getParameters().filter(p => p.isParameterProperty())
// p.isParameterProperty() == p.getScope() != null || p.isReadonly() Is that what you mean? Otherwise, from a class declaration you can get them by calling: const ctorProps = classDeclaration.getInstanceProperties()
.filter(p => p instanceof ParameterDeclaration) as ParameterDeclaration[]; -- Unfortunately, right now removing nodes isn't possible. Removing a constructor is a bit of an exception. I'm working on that slowly in #47 (it's the highest priority feature right now) |
The simplest
const property = classDeclaration.addProperty({ isStatic: true, name: "prop", type: "string" });
triggers this on latest version when ever a non-empty constructor is present
constructor( private serv: MyLocalService ) {}
if no constructor then it works.
The text was updated successfully, but these errors were encountered: