Skip to content

Circular references with TS 1.1.0-1 and 1.3 when loading file from another directory #1107

Closed
@Vadorequest

Description

@Vadorequest

Hi.

I have updated my typescript (npm install typescript -g) recently and now I have an issue with some multiple references to the same file.

It worked fine under TS 1.0.

shared/app/Sails.ts:

///<reference path='./lib/def/defLoader.d.ts'/>

import cli = require('./../../shared/app/Cli');
var Cli = cli.Cli;

export class Sails{

}

Because Cli also imports the same defLoader.d.ts, I get the following errors:

../../shared/app/lib/def/JQuery.d.ts(23,5): error TS2300: Duplicate identifier 'accepts'.
../../shared/app/lib/def/JQuery.d.ts(24,5): error TS2300: Duplicate identifier 'async'.
../../shared/app/lib/def/JQuery.d.ts(26,5): error TS2300: Duplicate identifier 'cache'.
../../shared/app/lib/def/JQuery.d.ts(28,5): error TS2300: Duplicate identifier 'contents'.
../../shared/app/lib/def/JQuery.d.ts(31,5): error TS2300: Duplicate identifier 'contentType'.
../../shared/app/lib/def/JQuery.d.ts(32,5): error TS2300: Duplicate identifier 'context'.

(much more errors but I guess you get what's the issue)

I can solve it two ways, either by removing the Cli reference (so, I don't require the file), or by removing the //<reference path at the top of the file.

I didn't have this problem in TS 1.0.

Weird thing, I have this issue only here, even if in some other files I do the same, I don't get the error there and I'm not able to understand why it works there while here it fails.

But I just figured it out while writing this issue. It is because of the path used to load my Cli module, I used require('./../../shared/app/Cli'); while I should have used require('./Cli'); and because of this somehow the compiler tried to perform the reference twice because it thought it was another file. Well, I didn't have this issue in TS 1.0, I don't know if it's on purpose, anyway my issue is solved now, just wanted to give you a feedback.

Keep up the good work, looking forward for TS 2.0!

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions