danielearwicker / doop

Succint immutable record classes for TypeScript
MIT License
12 stars 0 forks source link

Readme example does not work with 'export' #3

Closed doopuser closed 8 years ago

doopuser commented 8 years ago

Love the project - the only sensible typed-immutability I've seen. I just wanted to share that the readme example throws an error if you export the class because of doop vs Doop.

import {doop, Doop} from "../doop" solves the issue.

danielearwicker commented 8 years ago

Thanks! What do you do to get the error? I just tried a simple npm install doop and made a test.ts with the readme example pasted into it, and then tried exporting Animal and using it from another module - all seems fine...

doopuser commented 8 years ago

TypeScript spits out a compile-time error:

Return type of public property getter from exported class has or is using name 'Doop' from external module "<path>" but cannot be named.

I have something like:

import {doop} from "doop";

@doop
export default class Animal{

     @doop
      get color() { return doop<string, this>();}
}

It seems I need to add Doop to the imports as well.

danielearwicker commented 8 years ago

I tried that exact code with the current version of TS (1.8.10) and the previous mainstream (1.7.5) and it's fine.

Another issue reported on doop was due to a WebStorm bug - which IDE are you using? Do you get the issue with the command line compiler?

doopuser commented 8 years ago

I'm using Visual Studio Enterprise 2015 - Update 1. I get the same error from the IDE as I do from the command line. If it doesn't repro for you, perhaps my environment has a quirk in it's configuration. Feel free to close the issue, I can keep using {doop, Doop} without much hassle. Thanks for following up!

danielearwicker commented 8 years ago

Strange! Would be good to know what's happening, just for my understanding. Doop (uppercase) is just an interface - if you don't refer to Doop in your source then you should be able to forget it exists.