Fixed es2015 imports from export=
(cherry picked from commit 9e46c180b4
)
This commit is contained in:
parent
4ec4ce814d
commit
b760fc0ae0
|
@ -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;
|
||||
|
|
13
tests/cases/fourslash/javascriptModules20.ts
Normal file
13
tests/cases/fourslash/javascriptModules20.ts
Normal 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');
|
14
tests/cases/fourslash/javascriptModules21.ts
Normal file
14
tests/cases/fourslash/javascriptModules21.ts
Normal 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');
|
13
tests/cases/fourslash/javascriptModules22.ts
Normal file
13
tests/cases/fourslash/javascriptModules22.ts
Normal 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');
|
12
tests/cases/fourslash/javascriptModules23.ts
Normal file
12
tests/cases/fourslash/javascriptModules23.ts
Normal 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');
|
21
tests/cases/fourslash/javascriptModules24.ts
Normal file
21
tests/cases/fourslash/javascriptModules24.ts
Normal 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);
|
Loading…
Reference in a new issue