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

Double definitions not recognized #7743

Closed
andevsoftware opened this issue Mar 31, 2016 · 4 comments
Closed

Double definitions not recognized #7743

andevsoftware opened this issue Mar 31, 2016 · 4 comments
Labels
External Relates to another program, environment, or user action which we cannot control. @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped

Comments

@andevsoftware
Copy link

TypeScript Version:

1.8.9

Code

import Item from "./Models/Item";
import ModelCollection from "ts-core/lib/Data/ModelCollection";

var modelCollection = new ModelCollection<Item>(Item, []);

Expected behavior:

Compilation without errors.

Actual behavior:

screen shot 2016-03-31 at 09 18 08

In order to replicate:

clone https://github.com/redound/exp-typings.git
cd exp-typings
typings install
tsc

NOTE: I'm not sure if this is a TypeScript or Typings problem so I've also issued it here:
typings/typings#380

@mhegazy
Copy link
Contributor

mhegazy commented Mar 31, 2016

The first EventEmitter, referred to in the definition of Item is in exp-typings\typings\main\definitions\ts-data\index.d.ts line 109. The other EventEmitter used in Model comes from exp-typings\typings\main\definitions\ts-core\index.d.ts line 477.

the two classes seem identical, but they have a private member. from the compiler perspective these are different files.

Are the files ts-core\index.d.ts and ts-data\index.d.ts auto generated by typings?

@mhegazy mhegazy added the External Relates to another program, environment, or user action which we cannot control. label Mar 31, 2016
@andevsoftware
Copy link
Author

@mhegazy Thanks for your reply.

the definition files inside https://github.com/redound/ts-core/tree/dev-package/lib get generated after the tsc executes:
https://github.com/redound/ts-core/blob/dev-package/tsconfig.json

the definition files inside https://github.com/redound/ts-data/tree/dev-package/lib get generated after the tsc executes:
https://github.com/redound/ts-data/blob/dev-package/tsconfig.json

Typings then goes ahead and alters them resulting in the index.d.ts files inside the typings folder. I think the reason the EventEmitter referred to in the definition Item is caused by Typings actually including the definitions of ts-core also in the definition of ts-data itself. That's because ts-data has ts-core as a dependency. I believe I don't have any control whatsoever over the way typings does this. What do you think?

@mhegazy
Copy link
Contributor

mhegazy commented Mar 31, 2016

If there is a shared dependency, it should be factored out to a different component. ts-core-eventemitter. the other option, is make the contract of these declaration safe to use across different versions of your library, i.e. do not use private properties.

@unional
Copy link
Contributor

unional commented Mar 31, 2016

How about protected properties? Should they be shared? Sounds like a touchy subject. 😏

@mhegazy mhegazy closed this as completed Apr 5, 2016
@mhegazy mhegazy added the @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped label Apr 5, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
External Relates to another program, environment, or user action which we cannot control. @types Relates to working with .d.ts files (declaration/definition files) from DefinitelyTyped
Projects
None yet
Development

No branches or pull requests

3 participants