Skip to content

Disable import fix for method of 'export =' value#20208

Merged
4 commits merged into
masterfrom
importCodeFix_notForExportEqualsMethod
Nov 28, 2017
Merged

Disable import fix for method of 'export =' value#20208
4 commits merged into
masterfrom
importCodeFix_notForExportEqualsMethod

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Nov 21, 2017

Fixes #20191

@ghost ghost requested a review from DanielRosenwasser November 21, 2017 21:41
Comment thread src/services/codefixes/importFixes.ts Outdated
if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) {
if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)
// Don't auto-import a method of an `export =` module (See GH#20191)
&& !(exportSymbolWithIdenticalName.flags & SymbolFlags.Method)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is going to break many of the dt definitions.. for instance, JQuery: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/jquery/index.d.ts#L28

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.

Instead of just relying on the meaning, I think what's more correct is to check is if the symbol's declarations is part of the global Object, String, Number , or Symbol declaration, right? I think you could probably check using our current internal checker APIs by doing something like

exportSymbolWithIdenticalName.valueDeclaration && checker.getPropertyOfType(checker.getStringType(), exportSymbolWithIdenticalName.name).valueDeclaration === exportSymbolWithIdenticalName.valueDeclaration // repeat for number, symbol, object

@ghost
Copy link
Copy Markdown
Author

ghost commented Nov 28, 2017

@weswigham @mhegazy Please re-review

Comment thread src/compiler/checker.ts Outdated

const type = getTypeOfSymbol(exportEquals);
// If the apparent type is different, this is a primitive, so let's not treat that as an exported symbol.
return getApparentType(type) === type ? getPropertyOfType(type, memberName) : undefined;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why not just type && type.typeFlags & TypeFlags.Primitive ?

Comment thread src/compiler/checker.ts Outdated
}

const type = getTypeOfSymbol(exportEquals);
// If the apparent type is different, this is a primitive, so let's not treat that as an exported symbol.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

comment is outdated.

@ghost ghost merged commit 94ea388 into master Nov 28, 2017
@ghost ghost deleted the importCodeFix_notForExportEqualsMethod branch November 28, 2017 22:46
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants