Skip to content

Fix incorrect import/export clashes. - #38730

Merged
sandersn merged 2 commits into
masterfrom
fix-incorrect-import/export-clashes
Sep 30, 2019
Merged

Fix incorrect import/export clashes.#38730
sandersn merged 2 commits into
masterfrom
fix-incorrect-import/export-clashes

Conversation

@sandersn

@sandersn sandersn commented Sep 30, 2019

Copy link
Copy Markdown
Contributor

A new error in Typescript 3.7 forbids name clashes like this:

import { X } from 'y'
export interface X { }

Previously they were incorrectly allowed. Typescript 3.7 will have a
beta version in the next day or two. In the meantime you can try
typescript@next -- the nightly build -- to see these errors.

There were generally two fixes

  1. Remove the import -- it was unused.
  2. Rename the import -- it conflicts but is still used.

I also updated one dependency: ts-toolbelt, which recently shipped a fix for this error.
There are 3 dependencies that are still broken: react-dnd, protractor and three. I'll look at those next and send a PR to those projects if necessary.

A new error in Typescript 3.7 forbids name clashes like this:

```ts
import { X } from 'y'
export interface X { }
```

Previously they were incorrectly allowed. Typescript 3.7 will have a
beta version in the next day or two. In the meantime you can try
typescript@next -- the nightly build -- to see these errors.
@sandersn

Copy link
Copy Markdown
Contributor Author

Since these are pretty straightforward changes, and the failures cluttering up our DT tests during the 3.7 release, I'm going to merge them today barring any really bad issues.

@andrewbranch, who merged the original PR.

import { Azure as Az } from 'azure-sb';
import Dictionary = Az.ServiceBus.Dictionary;

export namespace Azure.ServiceBus.Results {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. This was merging with Azure from 'azure-sb', right? It kind of feels like that should still be allowed? The issue that the microsoft/TypeScript#31231 was supposed to fix was when an imported type completely shadowed an exported type. If they merge, and exports from both are accessible, is that a problem?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it was merging it. I'll test with an older version of Typescript.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn’t it have to in order to resolve Dictionary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, after testing, they do not merge:

// @Filename: second.ts
export namespace Azure.ServiceBus {
    export interface Dictionary<T> {
        [k: string]: T
    }
}

export namespace Azure.ServiceBus.Results {
    export interface AcsTokenResponse extends Dictionary<string | Dictionary<string>> {
        WrapAccessToken: Dictionary<string>;
        WrapAccessTokenExpiresIn: Dictionary<string>;
    }

    export interface AcsTokenResult {
        parse(acsTokenQueryString: string): AcsTokenResponse;
    }
}

// @Filename: first.ts
import { Azure } from './second';
import Dictionary = Azure.ServiceBus.Dictionary;
export namespace Azure.ServiceBus.Results {
    export interface Id {
        d: Dictionary<number>
    }
}

// @Filename: welove.ts
import { Azure as A } from './first'
import { Azure as B } from './second'
let x: A.ServiceBus.Results./*1*/
let y: B.ServiceBus.Results./*2*/

At /1/, you see only Id and at /2/ you see only AcsTokenResponse and Result. And you can't import both with the name Azure.

@sandersn sandersn Sep 30, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, was replying to the previous comment.

The old behaviour was that references to Azure referred to the imported symbol. The module exports a namespace named Azure too, but that's (1) different (2) not referred to inside the module.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂

I completely missed that the old file had import Dictionary = Azure.ServiceBus.Dictionary;. I only saw it in your added changes, so I thought that previously, Dictionary was being resolved against the current namespace scope, which would have implied that it was merged somehow. That was the source of my confusion.

This seems fine. Thanks for investigating and unconfusing me.

@typescript-bot typescript-bot added Popular package This PR affects a popular package (as counted by NPM download counts). Awaiting reviewer feedback labels Sep 30, 2019
@typescript-bot

typescript-bot commented Sep 30, 2019

Copy link
Copy Markdown
Contributor

@sandersn Thank you for submitting this PR!

🔔 @joelhegg @Azure @huan086 @mathieudutour @AndrewVetovitz @donnut @mdekrey @mrdziuban @sbking @afharo @teves-castro @1M0reBug @hojberg @samsonkeung @angeloocana @raynerd @moshensky @ethanresnick @leighman @deftomat @deptno @blimusiek @biern @rayhaneh @rgm @drewwyatt @jottenlips @minitesh @Krantisinh @pirix-gh @brekk @Nemo108 @jituanlin @iRoachie @timwangdev @robertying @forabi @kaoDev @johnnyreilly @CarsonF @aikoven @LKay @bancek @alsiola @tehbi4 @huwmartin @m-b-davis @Reggino @maddijoyce @smifun @mshaaban088 @esetnik @bwlt @mrsekut @keenondrums @tomasz-zablocki @voxmatt @alloy @ckknight @renanmav - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

import { Azure as Az } from 'azure-sb';
import Dictionary = Az.ServiceBus.Dictionary;

export namespace Azure.ServiceBus.Results {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂

I completely missed that the old file had import Dictionary = Azure.ServiceBus.Dictionary;. I only saw it in your added changes, so I thought that previously, Dictionary was being resolved against the current namespace scope, which would have implied that it was merged somehow. That was the source of my confusion.

This seems fine. Thanks for investigating and unconfusing me.

@andrewbranch

Copy link
Copy Markdown
Member

BenchmarkPR is going to time out since so many packages changed; feel free to merge any time

@sandersn

Copy link
Copy Markdown
Contributor Author

Your confusion makes sense; I think the authors of the package thought the namespaces were going to merge too.

@typescript-bot typescript-bot added the Other Approved This PR was reviewed and signed-off by a community member. label Sep 30, 2019
@sandersn
sandersn merged commit 3d6e86f into master Sep 30, 2019
@sandersn
sandersn deleted the fix-incorrect-import/export-clashes branch September 30, 2019 19:33
@typescript-bot

Copy link
Copy Markdown
Contributor

I just published @types/actions-on-google@1.10.3 to npm.

@typescript-bot

Copy link
Copy Markdown
Contributor

I just published @types/azure-sb@0.0.36 to npm.

@typescript-bot

Copy link
Copy Markdown
Contributor

I just published @types/lingui__react@2.8.1 to npm.

@typescript-bot

Copy link
Copy Markdown
Contributor

I just published @types/microrouter@3.1.1 to npm.

@typescript-bot

Copy link
Copy Markdown
Contributor

I just published @types/passport-linkedin-oauth2@1.5.1 to npm.

@typescript-bot

Copy link
Copy Markdown
Contributor

I just published @types/ramda@0.26.26 to npm.

@typescript-bot

Copy link
Copy Markdown
Contributor

I just published @types/react-native-vector-icons@6.4.4 to npm.

@typescript-bot

Copy link
Copy Markdown
Contributor

I just published @types/redux-form@8.1.6 to npm.

@typescript-bot

Copy link
Copy Markdown
Contributor

I just published @types/relay-runtime@6.0.4 to npm.

@guillaume86

Copy link
Copy Markdown

I just published @types/redux-form@8.1.6 to npm.

@RyanCavanaugh is it possible to trigger a v7 publish?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Other Approved This PR was reviewed and signed-off by a community member. Popular package This PR affects a popular package (as counted by NPM download counts).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants