question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

addConstructor throw error when class have an JSDOC at the end

See original GitHub issue

Describe the bug

Version: latest

To Reproduce

const { Project, StructureKind } = require("ts-morph");

const project = new Project({});

const classFile = project.createSourceFile("src/MyClass.ts", `
class Foo {
/**
 * 
 */
}
`);
const classNode = classFile.getClasses()[0];
classNode.addConstructor({
  statements: "console.log('i am constructor');",
});

image

Expected behavior

no error

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dsherretcommented, Jan 15, 2020

Thanks @lazarljubenovic! I have been taking a bit of a break from working on ts-morph, but I will get back to it very soon. I’ll probably do a quick release to fix this bug over the weekend though.

1reaction
lazarljubenoviccommented, Jan 14, 2020

I’ve gotta hijack this to tell you that I love how you explain the bug when you understand it, @dsherret! Keep up the great work maintaining the lib 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use JSDoc: @throws
The @throws tag allows you to document an error that a function might throw. You can include the @throws tag more than once...
Read more >
Documenting TypeScript · Issue #272 · jsdoc/jsdoc - GitHub
I want to be able to comment the class and constructor separately, since 1) not all TypeScript classes have a constructor, and 2)...
Read more >
Class: Exception - JSDoc
Constructs an Exception object that has the message specified. Parameters: Name, Type, Description. message, String, The message.
Read more >
JSDoc document final method - javascript - Stack Overflow
Wait to create the method until your subclass constructor has already called the superclass constructor. Return an object created without using ...
Read more >
JSDoc Reference - TypeScript: Documentation
You can also specify object literal types. For example, an object with properties 'a' (string) and 'b' (number) uses the following syntax:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found