Fixed es2015 imports from export=

(cherry picked from commit 9e46c180b4)
This commit is contained in:
Bill Ticehurst 2016-02-25 17:06:31 -08:00
parent 4ec4ce814d
commit b760fc0ae0
6 changed files with 82 additions and 1 deletions

View file

@ -964,8 +964,16 @@ namespace ts {
if (targetSymbol) {
const name = specifier.propertyName || specifier.name;
if (name.text) {
let symbolFromVariable: Symbol;
// First check if module was specified with "export=". If so, get the member from the resolved type
if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) {
const members = (getTypeOfSymbol(targetSymbol) as ResolvedType).members;
symbolFromVariable = members && members[name.text];
}
else {
symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text);
}
const symbolFromModule = getExportOfModule(targetSymbol, name.text);
const symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text);
const symbol = symbolFromModule && symbolFromVariable ?
combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) :
symbolFromModule || symbolFromVariable;

View file

@ -0,0 +1,13 @@
/// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: mod.js
//// function foo() { return {a: true}; }
//// module.exports = foo();
// @Filename: app.js
//// import * as mod from "./mod"
//// mod./**/
goTo.marker();
verify.completionListContains('a');

View file

@ -0,0 +1,14 @@
/// <reference path='fourslash.ts'/>
// @allowJs: true
// @module: system
// @Filename: mod.js
//// function foo() { return {a: true}; }
//// module.exports = foo();
// @Filename: app.js
//// import mod from "./mod"
//// mod./**/
goTo.marker();
verify.completionListContains('a');

View file

@ -0,0 +1,13 @@
/// <reference path='fourslash.ts'/>
// @allowJs: true
// @Filename: mod.js
//// function foo() { return {a: "hello, world"}; }
//// module.exports = foo();
// @Filename: app.js
//// import {a} from "./mod"
//// a./**/
goTo.marker();
verify.completionListContains('toString');

View file

@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>
// @Filename: mod.ts
//// var foo = {a: "test"};
//// export = foo;
// @Filename: app.ts
//// import {a} from "./mod"
//// a./**/
goTo.marker();
verify.completionListContains('toString');

View file

@ -0,0 +1,21 @@
/// <reference path='fourslash.ts'/>
// @Filename: mod.ts
//// function foo() { return 42; }
//// namespace foo {
//// export function bar (a: string) { return a; }
//// }
//// export = foo;
// @Filename: app.ts
//// import * as foo from "./mod"
//// foo/*1*/();
//// foo.bar(/*2*/"test");
goTo.marker('1');
/**** BUG: Should be an error to invoke a call signature on a namespace import ****/
//verify.errorExistsBeforeMarker('1');
verify.quickInfoIs("(alias) foo(): number\nimport foo");
goTo.marker('2');
verify.signatureHelpArgumentCountIs(1);