Skip to content
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

Calling Decorator.getNameNode may throw an error #1214

Closed
hughfenghen opened this issue Nov 8, 2021 · 0 comments
Closed

Calling Decorator.getNameNode may throw an error #1214

hughfenghen opened this issue Nov 8, 2021 · 0 comments
Labels

Comments

@hughfenghen
Copy link

Expected the decorator expression '(OtherDecorator())' to be an identifier, but it wasn't. Please report this as a bug.

    98 |     .filter(m => m.getDecorators().some(
    99 |       d => {
> 100 |         console.log(111, d.getNameNode())
      |                            ^
  101 |         return false
  102 |       }
  103 |     ))

Version: 12.0.0


Reproduction code

test.ts

function OtherDecorator (): any {}

export class Foo {
  // Here is probably a more complex expression, wrapped in parentheses
  @(OtherDecorator())
  async bar (): Promise<string[]> {
    return []
  }
}
import { Project } from "ts-morph";

const project = new Project();
const sf = project.addSourceFileAtPath("test.ts");
const fooClass = sf.getClass('Foo')
fooClass.getMethods()
  .filter(m => m.getDecorators().some(
      d => {
          console.log(111, d.getNameNode())
          return false
      }
    ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants