Comments (2)
Found another case where comments cause an error:
When calling node.remove()
(where node.getKind() === SyntaxKind.JSDoc), it may throw this error if JS Doc has inline comments around it:
Error: Error replacing tree: The children of the old and new trees were expected to have the same count (183:188).
at ParentFinderReplacementNodeHandler.handleChildren (ts-morph.js:1463:19)
at ParentFinderReplacementNodeHandler.handleNode (ts-morph.js:1457:18)
at ParentFinderReplacementNodeHandler.handleNode (ts-morph.js:1597:19)
at NodeHandlerHelper.handleForValues (ts-morph.js:1400:21)
at ParentFinderReplacementNodeHandler.handleChildren (ts-morph.js:1467:25)
at ParentFinderReplacementNodeHandler.handleNode (ts-morph.js:1457:18)
at ParentFinderReplacementNodeHandler.handleNode (ts-morph.js:1597:19)
at NodeHandlerHelper.handleForValues (ts-morph.js:1400:21)
at ParentFinderReplacementNodeHandler.handleChildren (ts-morph.js:1467:25)
at ParentFinderReplacementNodeHandler.handleNode (ts-morph.js:1457:18)
My workaround for this is to remove the node through calling .replaceWithText() on it's parent.
For .setOrder(), the (poor) workaround is to remove all inline comments before reordering and then try to add them back.
from ts-morph.
Similarly, fails in if you have:
class A {
a = null!; // some comment
b = null;
}
(then try to move the "b" property)
from ts-morph.
Related Issues (20)
- Override default `compilerOptions`
- `getDescendantAtStartWithWidth` does not work for reported diagnostic on exported functions
- Support the following features within the "formatting" module
- Feaure request: Ability to defer manipulations and generate TextChange[] or FileTextChanges[] HOT 2
- ImplementedKindToNodeMappings is missing some children HOT 1
- IndexSignatureDeclarationStructure::keyType can't be a WriterFunction? HOT 1
- leadingTrivia at the file level is not actually leading
- getParentIfKindOrThrow throws on CallExpression syntax
- Be able to identify unused class properties in files HOT 1
- Organize Imports with specific ending for module node16
- transform doesn't handle recursively transformed nodes (fix suggested) HOT 1
- .getChildSyntaxList() unexpectedly returns undefined for UnionTypeNode HOT 1
- _ HOT 1
- `ImplementedKindToNodeMappings` does not include some types
- perf(Node.js): Major performance bottleneck in Node.js due to fs.statSync HOT 5
- enum addMember | insertMember
- `ts.sys` is `undefined` in Deno
- How do I get a single line comment HOT 1
- `DeclarationImport.remove()` removes following new line
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ts-morph.