mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-10 15:25:54 -06:00
Support UMD when targeted module uses export =
This commit is contained in:
parent
34cf10542c
commit
132d75c267
@ -982,7 +982,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getTargetOfGlobalModuleExportDeclaration(node: GlobalModuleExportDeclaration): Symbol {
|
||||
return node.parent.symbol;
|
||||
const moduleSymbol = node.parent.symbol;
|
||||
if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) {
|
||||
return moduleSymbol.exports["export="].exportSymbol;
|
||||
}
|
||||
else {
|
||||
return moduleSymbol;
|
||||
}
|
||||
}
|
||||
|
||||
function getTargetOfExportSpecifier(node: ExportSpecifier): Symbol {
|
||||
|
||||
18
tests/baselines/reference/umd6.js
Normal file
18
tests/baselines/reference/umd6.js
Normal file
@ -0,0 +1,18 @@
|
||||
//// [tests/cases/conformance/externalModules/umd6.ts] ////
|
||||
|
||||
//// [foo.d.ts]
|
||||
|
||||
declare namespace Thing {
|
||||
export function fn(): number;
|
||||
}
|
||||
export = Thing;
|
||||
export as namespace Foo;
|
||||
|
||||
//// [a.ts]
|
||||
/// <reference path="foo.d.ts" />
|
||||
let y: number = Foo.fn();
|
||||
|
||||
|
||||
//// [a.js]
|
||||
/// <reference path="foo.d.ts" />
|
||||
var y = exports.Foo.fn();
|
||||
19
tests/baselines/reference/umd6.symbols
Normal file
19
tests/baselines/reference/umd6.symbols
Normal file
@ -0,0 +1,19 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
/// <reference path="foo.d.ts" />
|
||||
let y: number = Foo.fn();
|
||||
>y : Symbol(y, Decl(a.ts, 1, 3))
|
||||
>Foo : Symbol(Foo, Decl(foo.d.ts, 4, 15))
|
||||
|
||||
=== tests/cases/conformance/externalModules/foo.d.ts ===
|
||||
|
||||
declare namespace Thing {
|
||||
>Thing : Symbol(Thing, Decl(foo.d.ts, 0, 0))
|
||||
|
||||
export function fn(): number;
|
||||
>fn : Symbol(fn, Decl(foo.d.ts, 1, 25))
|
||||
}
|
||||
export = Thing;
|
||||
>Thing : Symbol(Thing, Decl(foo.d.ts, 0, 0))
|
||||
|
||||
export as namespace Foo;
|
||||
|
||||
23
tests/baselines/reference/umd6.types
Normal file
23
tests/baselines/reference/umd6.types
Normal file
@ -0,0 +1,23 @@
|
||||
=== tests/cases/conformance/externalModules/a.ts ===
|
||||
/// <reference path="foo.d.ts" />
|
||||
let y: number = Foo.fn();
|
||||
>y : number
|
||||
>Foo.fn() : any
|
||||
>Foo.fn : any
|
||||
>Foo : any
|
||||
>fn : any
|
||||
|
||||
=== tests/cases/conformance/externalModules/foo.d.ts ===
|
||||
|
||||
declare namespace Thing {
|
||||
>Thing : typeof Thing
|
||||
|
||||
export function fn(): number;
|
||||
>fn : () => number
|
||||
}
|
||||
export = Thing;
|
||||
>Thing : typeof Thing
|
||||
|
||||
export as namespace Foo;
|
||||
>Foo : any
|
||||
|
||||
13
tests/cases/conformance/externalModules/umd6.ts
Normal file
13
tests/cases/conformance/externalModules/umd6.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// @module: commonjs
|
||||
// @noImplicitReferences: true
|
||||
|
||||
// @filename: foo.d.ts
|
||||
declare namespace Thing {
|
||||
export function fn(): number;
|
||||
}
|
||||
export = Thing;
|
||||
export as namespace Foo;
|
||||
|
||||
// @filename: a.ts
|
||||
/// <reference path="foo.d.ts" />
|
||||
let y: number = Foo.fn();
|
||||
Loading…
x
Reference in New Issue
Block a user