Exported variable <variable name> has or is using private name <private name> from external library #15947
Copy link
Copy link
Closed
Labels
Needs More InfoThe issue still hasn't been fully clarifiedThe issue still hasn't been fully clarified
Description
Hey guys not really sure what to do about this. I know this is a duplicate of #6307, but I didn't really want to comment on a closed issue. I can't really use Daniel Rosenwasser (@DanielRosenwasser)'s solution here because the class is exported from the library. I guess I could extend that class in my code and use that instead. Completely understand the issues with this, I guess I'm just looking for a recommendation and I wanted to report this for other people.
Error:
(4,1): error TS4082: Default export of the module has or is using private name 'Warning'.
My code:
import { optional } from 'rulr';
import { stringValue, mailto, sha1, iri, account } from '../factory';
export default {
objectType: optional(stringValue),
name: optional(stringValue),
mbox: optional(mailto),
mbox_sha1sum: optional(sha1),
openid: optional(iri),
account: optional(account),
};Rulr's type definitions (generated by the TypeScript compiler):
export declare type Path = string[];
export declare class Warning {
data: any;
path: Path;
constructor(data: any, path: Path);
}
export declare type Rule = (data: any, path: Path) => Warning[];
export declare const optional: (rule: Rule) => Rule;Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Needs More InfoThe issue still hasn't been fully clarifiedThe issue still hasn't been fully clarified
Activity
ryasmi commentedon May 19, 2017
Actually I can't extend the class, that makes no sense. I'd have to recreate every function in that library haha
ryasmi commentedon May 19, 2017
Ok
asto the rescue haha, I don't think this is ideal, but it does work.mhegazy commentedon May 19, 2017
I am not able to get this to repro locally using your input file. can you share more context?
mhegazy commentedon Jun 4, 2017
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
ryasmi commentedon Jun 4, 2017
Hey Mohamed Hegazy (@mhegazy), no worries, I'd do the same, I'm on holiday for a few more days, I'll get back to this when I'm home 😄
ryasmi commentedon Jun 14, 2017
Ok Mohamed Hegazy (@mhegazy), what context do you need? 😄
mhegazy commentedon Jun 15, 2017
can you share a self-contained sample that reproduces the issue?
ryasmi commentedon Jun 15, 2017
Yeah I'll give that a try.
ryasmi commentedon Jun 15, 2017
How's this Mohamed Hegazy (@mhegazy)? https://github.com/ryansmith94/ts-15947
mhegazy commentedon Jun 15, 2017
This is the same issue as #9944. The declaration emitter tried to serialize the type of the property
foobar, which isRule, which is an alias to(data: any, path: Path) => Warning[];, it tried to writeWarningbut that would be invalid, sinceWarningis not imported.The emitter does not add imports automatically to avoid divulging implementation details that the user did not intend to expose. #9944 tracks relaxing this rule.
To avoid this warning, write an explicit type annotation for the type of your property. something like this would work:
ryasmi commentedon Jun 16, 2017
Hey Mohamed Hegazy (@mhegazy), I did understand that already from other issues I'd found before creating this one, but thank you for the explanation anyway and thanks for referencing the duplicate issue (sorry I didn't find that in my search) 😄 I'll subscribe to that issue going forward.
Thanks for the fix too! 👍