insertText() not working for namespace
See original GitHub issueVersion: 14.4.2
index.d.ts file contents:
export {}
declare global {
export interface Person { name: string }
export type People = Person[]
}
Code I’m using to insert new interface into global namespace:
const globalNode = definitionsFile.getNamespace('global')
if (!globalNode) throw new Error('globalNode not found')
globalNode.insertText(globalNode.getEnd(), 'export interface Car { model: string }')
Expected: new interface to be inserted
Actual: Error thrown: “Cannot insert or replace text outside the bounds of the node. Expected a position between [36, 41], but received 42.”
I also tried to use globalNode.getEnd() -1 - it just gives different error.
FYI, just checked, if global namespace is empty (no declared interfaces or types), it also gives this error, just with different position number.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
CommandField.InsertText Property - Microsoft Learn
The following code example demonstrates how to use the InsertText property to specify a custom caption for an Insert button displayed in a...
Read more >SubDocument.InsertText(DocumentPosition, String) Method
SubDocument.InsertText(DocumentPosition, String) Method ... Inserts the specified text at the specified position. Namespace: DevExpress.XtraRichEdit.API.Native.
Read more >c# - Insert text at cursor position - Stack Overflow
I need to insert text from a variable at the cursor position no matter in which window/program it is located, so whenever the...
Read more >What to do if insertText doesn't work, but there are no error ...
I'm trying to add text to an image I have but the insertText function isn't working. No errors show up when I run...
Read more >clang::Rewriter Class Reference
InsertText - Insert the specified string at the specified location in the original ... Referenced by clang::arcmt::MigrationProcess::applyTransform(), ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Fixed in 14.4.3.
@ihorskyi I just tried this out and you’re right that this wasn’t working properly! It should just be by doing -1 to go to the left of the close brace like you said.
It’s a little difficult because you have to handle the spacing yourself:
That doesn’t work right now, but it will be working in the next release. Thanks for reporting this!