Skip to content

Commit

Permalink
Merge pull request #10930 from RyanCavanaugh/release-2.0
Browse files Browse the repository at this point in the history
Cherry-pick #10929 to release-2.0
  • Loading branch information
RyanCavanaugh committed Sep 14, 2016
2 parents 4ce2280 + d37391f commit bca3493
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -909,8 +909,8 @@ namespace ts {
}
}

// If we're in an external module, we can't reference symbols created from UMD export declarations
if (result && isInExternalModule) {
// If we're in an external module, we can't reference value symbols created from UMD export declarations
if (result && isInExternalModule && (meaning & SymbolFlags.Value) === SymbolFlags.Value) {
const decls = result.declarations;
if (decls && decls.length === 1 && decls[0].kind === SyntaxKind.NamespaceExportDeclaration) {
error(errorLocation, Diagnostics.Identifier_0_must_be_imported_from_a_module, name);
Expand Down
25 changes: 25 additions & 0 deletions tests/baselines/reference/umd8.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
tests/cases/conformance/externalModules/a.ts(7,14): error TS2686: Identifier 'Foo' must be imported from a module


==== tests/cases/conformance/externalModules/a.ts (1 errors) ====
/// <reference path="foo.d.ts" />
import * as ff from './foo';

let y: Foo; // OK in type position
y.foo();
let z: Foo.SubThing; // OK in ns position
let x: any = Foo; // Not OK in value position
~~~
!!! error TS2686: Identifier 'Foo' must be imported from a module

==== tests/cases/conformance/externalModules/foo.d.ts (0 errors) ====

declare class Thing {
foo(): number;
}
declare namespace Thing {
interface SubThing { }
}
export = Thing;
export as namespace Foo;

16 changes: 12 additions & 4 deletions tests/baselines/reference/umd8.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@
declare class Thing {
foo(): number;
}
declare namespace Thing {
interface SubThing { }
}
export = Thing;
export as namespace Foo;

//// [a.ts]
/// <reference path="foo.d.ts" />
let y: Foo;
y.foo();
import * as ff from './foo';

let y: Foo; // OK in type position
y.foo();
let z: Foo.SubThing; // OK in ns position
let x: any = Foo; // Not OK in value position


//// [a.js]
/// <reference path="foo.d.ts" />
var y;
"use strict";
var y; // OK in type position
y.foo();
var z; // OK in ns position
var x = Foo; // Not OK in value position
10 changes: 8 additions & 2 deletions tests/cases/conformance/externalModules/umd8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
declare class Thing {
foo(): number;
}
declare namespace Thing {
interface SubThing { }
}
export = Thing;
export as namespace Foo;

// @filename: a.ts
/// <reference path="foo.d.ts" />
let y: Foo;
y.foo();
import * as ff from './foo';

let y: Foo; // OK in type position
y.foo();
let z: Foo.SubThing; // OK in ns position
let x: any = Foo; // Not OK in value position

0 comments on commit bca3493

Please sign in to comment.