You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey @dsherret. Looks like I found another interesting one. Trying to add a type to an optional parameter marked by a question token seems to put the '?' token in the wrong place in the output code. Check out this reproduction:
importProject,{MethodDeclaration,SyntaxKind}from'ts-simple-ast';constproject=newProject();constsourceFile=project.createSourceFile('my-file.ts',` class MyClass { someMethod( param1? ) {} }`);constmethod=sourceFile.getDescendantsOfKind(SyntaxKind.MethodDeclaration)[0]asMethodDeclaration;constparam1=method.getParameters()[0];param1.setType('any');console.log('Transformed:');console.log(sourceFile.getFullText());
Basically the original source code:
classMyClass{someMethod(param1? ){}}
Gets changed into:
classMyClass{someMethod(param1: any? ){}}
Where the correct output should be:
classMyClass{someMethod(param1?: any){}}
Best,
Greg
The text was updated successfully, but these errors were encountered:
Hey @dsherret. Looks like I found another interesting one. Trying to add a type to an optional parameter marked by a question token seems to put the '?' token in the wrong place in the output code. Check out this reproduction:
Basically the original source code:
Gets changed into:
Where the correct output should be:
Best,
Greg
The text was updated successfully, but these errors were encountered: