Skip to content
This repository has been archived by the owner on Oct 15, 2018. It is now read-only.

Decorator Namespaces #220

Closed
calebboyd opened this issue Jan 2, 2017 · 6 comments
Closed

Decorator Namespaces #220

calebboyd opened this issue Jan 2, 2017 · 6 comments
Labels
Milestone

Comments

@calebboyd
Copy link

Great Project. It reminds me a little of Roslyn.

Found a possible issue if a decorator is accessed through a namespace. Reading and writing changes the declaration, eg.

import { DecoratorNamespace } from './my-decorators'

class Foo {
  @DecoratorNamespace.DecoratorFactory('argument')
  bar () { }
}

writes as

import { DecoratorNamespace } from './my-decorators'

class Foo {
  @DecoratorNamespace('argument')
  bar () {}
}

On an unrelated note. Is there a way to maintain the contents (code) of the file/classes methods when reading and writing? eg. Keeping the contents of bar through the read/write operation.

Cheers!

@dsherret dsherret added the bug label Jan 2, 2017
@dsherret
Copy link
Owner

dsherret commented Jan 2, 2017

Thanks Caleb! I'll try to think of a solution to this soon.

In response to your other question, it's not currently easy to do that... you have to do what's shown in this issue. Originally, this library was just created to get basic information about the code so it doesn't support a lot of scenarios; however, I'm thinking about moving writing to use the typescript emitter so that I don't have to maintain this stuff and it can be a lot more reliable.

@calebboyd
Copy link
Author

That makes sense. (the project scope). I'd been tracking the compiler emit API as well before I found your project. Thanks for the help.

@calebboyd
Copy link
Author

microsoft/TypeScript#13940

@dsherret
Copy link
Owner

@calebboyd thanks for letting me know about that. It opens the door to new possibilities.

I've been busy working on something else the past month, but I'm going to get back to this tomorrow.

@dsherret dsherret added this to the Version 7.0 milestone Feb 17, 2017
@dsherret
Copy link
Owner

Sorry for the extremely long time fixing this. I've changed decorators to always use the fully qualified name.

@calebboyd
Copy link
Author

No worries thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants