address PR feedback

This commit is contained in:
Vladimir Matveev
2016-01-14 16:07:26 -08:00
parent e90db461ce
commit 36c489c8db
34 changed files with 135 additions and 117 deletions
+9 -10
View File
@@ -2490,7 +2490,7 @@ namespace ts {
// Every class automatically contains a static property member named 'prototype',
// the type of which is an instantiation of the class type with type Any supplied as a type argument for each type parameter.
// It is an error to explicitly declare a static property member with the name 'prototype'.
const classType = <InterfaceType>getDeclaredTypeOfSymbol(prototype.parent);
const classType = <InterfaceType>getDeclaredTypeOfSymbol(getMergedSymbol(prototype.parent));
return classType.typeParameters ? createTypeReference(<GenericType>classType, map(classType.typeParameters, _ => anyType)) : classType;
}
@@ -14364,9 +14364,6 @@ namespace ts {
reportError = symbol.parent !== undefined;
}
else {
// this symbol contains only merged content from external modules and augmentations so it should always be exported (parent !== undefined)
// and parent should have value side (valueDeclaration !== undefined)
Debug.assert(symbol.parent !== undefined && symbol.parent.valueDeclaration !== undefined);
// symbol should not originate in augmentation
reportError = isExternalModuleAugmentation(symbol.parent.valueDeclaration);
}
@@ -15714,20 +15711,22 @@ namespace ts {
bindSourceFile(file, compilerOptions);
});
let mergeAugmentations = false;
let augmentations: LiteralExpression[][];
// Initialize global symbol table
forEach(host.getSourceFiles(), file => {
if (!isExternalOrCommonJsModule(file)) {
mergeSymbolTable(globals, file.locals);
}
mergeAugmentations = mergeAugmentations || file.moduleAugmentations.length > 0;
if (file.moduleAugmentations) {
(augmentations || (augmentations = [])).push(file.moduleAugmentations);
}
});
if (mergeAugmentations) {
if (augmentations) {
// merge module augmentations.
// this needs to be done after global symbol table is initialized to make sure that all ambient modules are indexed
for (const file of host.getSourceFiles()) {
for (const augmentation of file.moduleAugmentations) {
// this needs to be done after global symbol table is initialized to make sure that all ambient modules are indexed
for (const list of augmentations) {
for (const augmentation of list) {
mergeModuleAugmentation(augmentation);
}
}
@@ -13,7 +13,7 @@ export class B {
import {A} from "./f1";
import {B} from "./f2";
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
declare module "./f1" {
interface A {
foo(): B;
@@ -46,7 +46,7 @@ exports.B = B;
//// [f3.js]
"use strict";
var f1_1 = require("./f1");
f1_1.A.prototype.foo = function () { };
f1_1.A.prototype.foo = function () { return undefined; };
//// [f4.js]
"use strict";
require("./f3");
@@ -18,10 +18,13 @@ import {A} from "./f1";
import {B} from "./f2";
>B : Symbol(B, Decl(f3.ts, 1, 8))
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
>A.prototype.foo : Symbol(A.foo, Decl(f3.ts, 5, 17))
>A.prototype : Symbol(A.prototype)
>A : Symbol(A, Decl(f3.ts, 0, 8))
>prototype : Symbol(A.prototype)
>foo : Symbol(A.foo, Decl(f3.ts, 5, 17))
>undefined : Symbol(undefined)
declare module "./f1" {
interface A {
@@ -18,16 +18,15 @@ import {A} from "./f1";
import {B} from "./f2";
>B : typeof B
(<any>A.prototype).foo = function () {}
>(<any>A.prototype).foo = function () {} : () => void
>(<any>A.prototype).foo : any
>(<any>A.prototype) : any
><any>A.prototype : any
A.prototype.foo = function () { return undefined; }
>A.prototype.foo = function () { return undefined; } : () => any
>A.prototype.foo : () => B
>A.prototype : A
>A : typeof A
>prototype : A
>foo : any
>function () {} : () => void
>foo : () => B
>function () { return undefined; } : () => any
>undefined : undefined
declare module "./f1" {
interface A {
@@ -1,3 +1,4 @@
tests/cases/compiler/f3.ts(3,13): error TS2339: Property 'foo' does not exist on type 'A'.
tests/cases/compiler/f3.ts(11,5): error TS2667: Imports are not permitted in module augmentations. Consider moving them to the enclosing external module.
tests/cases/compiler/f3.ts(11,21): error TS2307: Cannot find module './f2'.
tests/cases/compiler/f3.ts(12,5): error TS2666: Exports and export assignments are not permitted in module augmentations.
@@ -19,10 +20,12 @@ tests/cases/compiler/f4.ts(5,11): error TS2339: Property 'foo' does not exist on
n: number;
}
==== tests/cases/compiler/f3.ts (9 errors) ====
==== tests/cases/compiler/f3.ts (10 errors) ====
import {A} from "./f1";
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
~~~
!!! error TS2339: Property 'foo' does not exist on type 'A'.
namespace N {
export interface Ifc { a }
@@ -12,7 +12,7 @@ export class B {
//// [f3.ts]
import {A} from "./f1";
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
namespace N {
export interface Ifc { a }
@@ -58,7 +58,7 @@ exports.B = B;
//// [f3.js]
"use strict";
var f1_1 = require("./f1");
f1_1.A.prototype.foo = function () { };
f1_1.A.prototype.foo = function () { return undefined; };
//// [f4.js]
"use strict";
require("./f3");
@@ -18,7 +18,7 @@ tests/cases/compiler/f3.ts(13,16): error TS4000: Import declaration 'C' is using
==== tests/cases/compiler/f3.ts (6 errors) ====
import {A} from "./f1";
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
namespace N {
export interface Ifc { a }
@@ -12,7 +12,7 @@ export class B {
//// [f3.ts]
import {A} from "./f1";
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
namespace N {
export interface Ifc { a }
@@ -56,7 +56,7 @@ exports.B = B;
//// [f3.js]
"use strict";
var f1_1 = require("./f1");
f1_1.A.prototype.foo = function () { };
f1_1.A.prototype.foo = function () { return undefined; };
//// [f4.js]
"use strict";
require("./f3");
@@ -13,7 +13,7 @@ export class B {
import {A} from "./f1";
import {B} from "./f2";
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
namespace N {
export interface Ifc { a: number; }
@@ -58,7 +58,7 @@ exports.B = B;
//// [f3.js]
"use strict";
var f1_1 = require("./f1");
f1_1.A.prototype.foo = function () { };
f1_1.A.prototype.foo = function () { return undefined; };
//// [f4.js]
"use strict";
require("./f3");
@@ -18,13 +18,16 @@ import {A} from "./f1";
import {B} from "./f2";
>B : Symbol(B, Decl(f3.ts, 1, 8))
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
>A.prototype.foo : Symbol(A.foo, Decl(f3.ts, 13, 17))
>A.prototype : Symbol(A.prototype)
>A : Symbol(A, Decl(f3.ts, 0, 8))
>prototype : Symbol(A.prototype)
>foo : Symbol(A.foo, Decl(f3.ts, 13, 17))
>undefined : Symbol(undefined)
namespace N {
>N : Symbol(N, Decl(f3.ts, 3, 39))
>N : Symbol(N, Decl(f3.ts, 3, 51))
export interface Ifc { a: number; }
>Ifc : Symbol(Ifc, Decl(f3.ts, 5, 13))
@@ -36,12 +39,12 @@ namespace N {
}
import I = N.Ifc;
>I : Symbol(I, Decl(f3.ts, 8, 1))
>N : Symbol(N, Decl(f3.ts, 3, 39))
>N : Symbol(N, Decl(f3.ts, 3, 51))
>Ifc : Symbol(I, Decl(f3.ts, 5, 13))
import C = N.Cls;
>C : Symbol(C, Decl(f3.ts, 9, 17))
>N : Symbol(N, Decl(f3.ts, 3, 39))
>N : Symbol(N, Decl(f3.ts, 3, 51))
>Cls : Symbol(C, Decl(f3.ts, 6, 39))
declare module "./f1" {
@@ -18,16 +18,15 @@ import {A} from "./f1";
import {B} from "./f2";
>B : typeof B
(<any>A.prototype).foo = function () {}
>(<any>A.prototype).foo = function () {} : () => void
>(<any>A.prototype).foo : any
>(<any>A.prototype) : any
><any>A.prototype : any
A.prototype.foo = function () { return undefined; }
>A.prototype.foo = function () { return undefined; } : () => any
>A.prototype.foo : () => B
>A.prototype : A
>A : typeof A
>prototype : A
>foo : any
>function () {} : () => void
>foo : () => B
>function () { return undefined; } : () => any
>undefined : undefined
namespace N {
>N : any
@@ -15,7 +15,7 @@ tests/cases/compiler/f3.ts(11,12): error TS4000: Import declaration 'C' is using
import {A} from "./f1";
import {B} from "./f2";
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
namespace N {
export interface Ifc { a: number; }
@@ -13,7 +13,7 @@ export class B {
import {A} from "./f1";
import {B} from "./f2";
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
namespace N {
export interface Ifc { a: number; }
@@ -58,7 +58,7 @@ exports.B = B;
//// [f3.js]
"use strict";
var f1_1 = require("./f1");
f1_1.A.prototype.foo = function () { };
f1_1.A.prototype.foo = function () { return undefined; };
//// [f4.js]
"use strict";
require("./f3");
@@ -13,7 +13,7 @@ export class B {
import {A} from "./f1";
import {B} from "./f2";
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
export namespace N {
export interface Ifc { a: number; }
@@ -58,7 +58,7 @@ exports.B = B;
//// [f3.js]
"use strict";
var f1_1 = require("./f1");
f1_1.A.prototype.foo = function () { };
f1_1.A.prototype.foo = function () { return undefined; };
//// [f4.js]
"use strict";
require("./f3");
@@ -18,13 +18,16 @@ import {A} from "./f1";
import {B} from "./f2";
>B : Symbol(B, Decl(f3.ts, 1, 8))
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
>A.prototype.foo : Symbol(A.foo, Decl(f3.ts, 13, 17))
>A.prototype : Symbol(A.prototype)
>A : Symbol(A, Decl(f3.ts, 0, 8))
>prototype : Symbol(A.prototype)
>foo : Symbol(A.foo, Decl(f3.ts, 13, 17))
>undefined : Symbol(undefined)
export namespace N {
>N : Symbol(N, Decl(f3.ts, 3, 39))
>N : Symbol(N, Decl(f3.ts, 3, 51))
export interface Ifc { a: number; }
>Ifc : Symbol(Ifc, Decl(f3.ts, 5, 20))
@@ -36,12 +39,12 @@ export namespace N {
}
import I = N.Ifc;
>I : Symbol(I, Decl(f3.ts, 8, 1))
>N : Symbol(N, Decl(f3.ts, 3, 39))
>N : Symbol(N, Decl(f3.ts, 3, 51))
>Ifc : Symbol(I, Decl(f3.ts, 5, 20))
import C = N.Cls;
>C : Symbol(C, Decl(f3.ts, 9, 17))
>N : Symbol(N, Decl(f3.ts, 3, 39))
>N : Symbol(N, Decl(f3.ts, 3, 51))
>Cls : Symbol(C, Decl(f3.ts, 6, 39))
declare module "./f1" {
@@ -18,16 +18,15 @@ import {A} from "./f1";
import {B} from "./f2";
>B : typeof B
(<any>A.prototype).foo = function () {}
>(<any>A.prototype).foo = function () {} : () => void
>(<any>A.prototype).foo : any
>(<any>A.prototype) : any
><any>A.prototype : any
A.prototype.foo = function () { return undefined; }
>A.prototype.foo = function () { return undefined; } : () => any
>A.prototype.foo : () => B
>A.prototype : A
>A : typeof A
>prototype : A
>foo : any
>function () {} : () => void
>foo : () => B
>function () { return undefined; } : () => any
>undefined : undefined
export namespace N {
>N : any
@@ -19,8 +19,8 @@ import {A} from "./a";
import {B} from "./b";
import {Cls} from "C";
(<any>A.prototype).getB = function () {};
(<any>A.prototype).getCls = function () {}
A.prototype.getB = function () { return undefined; }
A.prototype.getCls = function () { return undefined; }
declare module "./a" {
interface A {
@@ -64,8 +64,8 @@ define("b", ["require", "exports"], function (require, exports) {
/// <reference path="c.d.ts"/>
define("d", ["require", "exports", "a"], function (require, exports, a_1) {
"use strict";
a_1.A.prototype.getB = function () { };
a_1.A.prototype.getCls = function () { };
a_1.A.prototype.getB = function () { return undefined; };
a_1.A.prototype.getCls = function () { return undefined; };
});
define("main", ["require", "exports", "d"], function (require, exports) {
"use strict";
@@ -27,15 +27,21 @@ import {B} from "./b";
import {Cls} from "C";
>Cls : Symbol(Cls, Decl(d.ts, 4, 8))
(<any>A.prototype).getB = function () {};
A.prototype.getB = function () { return undefined; }
>A.prototype.getB : Symbol(A.getB, Decl(d.ts, 10, 17))
>A.prototype : Symbol(A.prototype)
>A : Symbol(A, Decl(d.ts, 2, 8))
>prototype : Symbol(A.prototype)
>getB : Symbol(A.getB, Decl(d.ts, 10, 17))
>undefined : Symbol(undefined)
(<any>A.prototype).getCls = function () {}
A.prototype.getCls = function () { return undefined; }
>A.prototype.getCls : Symbol(A.getCls, Decl(d.ts, 16, 17))
>A.prototype : Symbol(A.prototype)
>A : Symbol(A, Decl(d.ts, 2, 8))
>prototype : Symbol(A.prototype)
>getCls : Symbol(A.getCls, Decl(d.ts, 16, 17))
>undefined : Symbol(undefined)
declare module "./a" {
interface A {
@@ -27,27 +27,25 @@ import {B} from "./b";
import {Cls} from "C";
>Cls : typeof Cls
(<any>A.prototype).getB = function () {};
>(<any>A.prototype).getB = function () {} : () => void
>(<any>A.prototype).getB : any
>(<any>A.prototype) : any
><any>A.prototype : any
A.prototype.getB = function () { return undefined; }
>A.prototype.getB = function () { return undefined; } : () => any
>A.prototype.getB : () => B
>A.prototype : A
>A : typeof A
>prototype : A
>getB : any
>function () {} : () => void
>getB : () => B
>function () { return undefined; } : () => any
>undefined : undefined
(<any>A.prototype).getCls = function () {}
>(<any>A.prototype).getCls = function () {} : () => void
>(<any>A.prototype).getCls : any
>(<any>A.prototype) : any
><any>A.prototype : any
A.prototype.getCls = function () { return undefined; }
>A.prototype.getCls = function () { return undefined; } : () => any
>A.prototype.getCls : () => Cls
>A.prototype : A
>A : typeof A
>prototype : A
>getCls : any
>function () {} : () => void
>getCls : () => Cls
>function () { return undefined; } : () => any
>undefined : undefined
declare module "./a" {
interface A {
@@ -18,7 +18,7 @@ declare module "C" {
import {A} from "./a";
import {B} from "./b";
(<any>A.prototype).getB = function () {};
A.prototype.getB = function () { return undefined; }
declare module "./a" {
interface A {
@@ -30,7 +30,7 @@ declare module "./a" {
import {A} from "./a";
import {Cls} from "C";
(<any>A.prototype).getCls = function () {}
A.prototype.getCls = function () { return undefined; }
declare module "./a" {
interface A {
@@ -69,11 +69,11 @@ define("b", ["require", "exports"], function (require, exports) {
/// <reference path="c.d.ts"/>
define("d", ["require", "exports", "a"], function (require, exports, a_1) {
"use strict";
a_1.A.prototype.getB = function () { };
a_1.A.prototype.getB = function () { return undefined; };
});
define("e", ["require", "exports", "a"], function (require, exports, a_2) {
"use strict";
a_2.A.prototype.getCls = function () { };
a_2.A.prototype.getCls = function () { return undefined; };
});
define("main", ["require", "exports", "d", "e"], function (require, exports) {
"use strict";
@@ -24,10 +24,13 @@ import {A} from "./a";
import {B} from "./b";
>B : Symbol(B, Decl(d.ts, 3, 8))
(<any>A.prototype).getB = function () {};
A.prototype.getB = function () { return undefined; }
>A.prototype.getB : Symbol(A.getB, Decl(d.ts, 8, 17))
>A.prototype : Symbol(A.prototype)
>A : Symbol(A, Decl(d.ts, 2, 8))
>prototype : Symbol(A.prototype)
>getB : Symbol(A.getB, Decl(d.ts, 8, 17))
>undefined : Symbol(undefined)
declare module "./a" {
interface A {
@@ -46,10 +49,13 @@ import {A} from "./a";
import {Cls} from "C";
>Cls : Symbol(Cls, Decl(e.ts, 1, 8))
(<any>A.prototype).getCls = function () {}
A.prototype.getCls = function () { return undefined; }
>A.prototype.getCls : Symbol(A.getCls, Decl(e.ts, 6, 17))
>A.prototype : Symbol(A.prototype)
>A : Symbol(A, Decl(e.ts, 0, 8))
>prototype : Symbol(A.prototype)
>getCls : Symbol(A.getCls, Decl(e.ts, 6, 17))
>undefined : Symbol(undefined)
declare module "./a" {
interface A {
@@ -24,16 +24,15 @@ import {A} from "./a";
import {B} from "./b";
>B : typeof B
(<any>A.prototype).getB = function () {};
>(<any>A.prototype).getB = function () {} : () => void
>(<any>A.prototype).getB : any
>(<any>A.prototype) : any
><any>A.prototype : any
A.prototype.getB = function () { return undefined; }
>A.prototype.getB = function () { return undefined; } : () => any
>A.prototype.getB : () => B
>A.prototype : A
>A : typeof A
>prototype : A
>getB : any
>function () {} : () => void
>getB : () => B
>function () { return undefined; } : () => any
>undefined : undefined
declare module "./a" {
interface A {
@@ -52,16 +51,15 @@ import {A} from "./a";
import {Cls} from "C";
>Cls : typeof Cls
(<any>A.prototype).getCls = function () {}
>(<any>A.prototype).getCls = function () {} : () => void
>(<any>A.prototype).getCls : any
>(<any>A.prototype) : any
><any>A.prototype : any
A.prototype.getCls = function () { return undefined; }
>A.prototype.getCls = function () { return undefined; } : () => any
>A.prototype.getCls : () => Cls
>A.prototype : A
>A : typeof A
>prototype : A
>getCls : any
>function () {} : () => void
>getCls : () => Cls
>function () { return undefined; } : () => any
>undefined : undefined
declare module "./a" {
interface A {
@@ -28,7 +28,7 @@ declare module "D" {
import {A} from "./a";
import {Cls} from "C";
(<any>A.prototype).getCls = function () {}
A.prototype.getCls = function () { return undefined; }
declare module "./a" {
interface A {
@@ -67,7 +67,7 @@ define("b", ["require", "exports"], function (require, exports) {
});
define("e", ["require", "exports", "a"], function (require, exports, a_1) {
"use strict";
a_1.A.prototype.getCls = function () { };
a_1.A.prototype.getCls = function () { return undefined; };
});
define("main", ["require", "exports", "D", "e"], function (require, exports) {
"use strict";
@@ -74,10 +74,13 @@ import {A} from "./a";
import {Cls} from "C";
>Cls : Symbol(Cls, Decl(e.ts, 2, 8))
(<any>A.prototype).getCls = function () {}
A.prototype.getCls = function () { return undefined; }
>A.prototype.getCls : Symbol(A.getCls, Decl(e.ts, 7, 17))
>A.prototype : Symbol(A.prototype)
>A : Symbol(A, Decl(e.ts, 1, 8))
>prototype : Symbol(A.prototype)
>getCls : Symbol(A.getCls, Decl(e.ts, 7, 17))
>undefined : Symbol(undefined)
declare module "./a" {
interface A {
@@ -78,16 +78,15 @@ import {A} from "./a";
import {Cls} from "C";
>Cls : typeof Cls
(<any>A.prototype).getCls = function () {}
>(<any>A.prototype).getCls = function () {} : () => void
>(<any>A.prototype).getCls : any
>(<any>A.prototype) : any
><any>A.prototype : any
A.prototype.getCls = function () { return undefined; }
>A.prototype.getCls = function () { return undefined; } : () => any
>A.prototype.getCls : () => Cls
>A.prototype : A
>A : typeof A
>prototype : A
>getCls : any
>function () {} : () => void
>getCls : () => Cls
>function () { return undefined; } : () => any
>undefined : undefined
declare module "./a" {
interface A {
@@ -13,7 +13,7 @@ export class B {
import {A} from "./f1";
import {B} from "./f2";
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
declare module "./f1" {
interface A {
foo(): B;
@@ -12,7 +12,7 @@ export class B {
// @filename: f3.ts
import {A} from "./f1";
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
namespace N {
export interface Ifc { a }
@@ -12,7 +12,7 @@ export class B {
// @filename: f3.ts
import {A} from "./f1";
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
namespace N {
export interface Ifc { a }
@@ -12,7 +12,7 @@ export class B {
import {A} from "./f1";
import {B} from "./f2";
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
namespace N {
export interface Ifc { a: number; }
@@ -13,7 +13,7 @@ export class B {
import {A} from "./f1";
import {B} from "./f2";
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
namespace N {
export interface Ifc { a: number; }
@@ -13,7 +13,7 @@ export class B {
import {A} from "./f1";
import {B} from "./f2";
(<any>A.prototype).foo = function () {}
A.prototype.foo = function () { return undefined; }
export namespace N {
export interface Ifc { a: number; }
@@ -20,8 +20,8 @@ import {A} from "./a";
import {B} from "./b";
import {Cls} from "C";
(<any>A.prototype).getB = function () {};
(<any>A.prototype).getCls = function () {}
A.prototype.getB = function () { return undefined; }
A.prototype.getCls = function () { return undefined; }
declare module "./a" {
interface A {
@@ -19,7 +19,7 @@ declare module "C" {
import {A} from "./a";
import {B} from "./b";
(<any>A.prototype).getB = function () {};
A.prototype.getB = function () { return undefined; }
declare module "./a" {
interface A {
@@ -31,7 +31,7 @@ declare module "./a" {
import {A} from "./a";
import {Cls} from "C";
(<any>A.prototype).getCls = function () {}
A.prototype.getCls = function () { return undefined; }
declare module "./a" {
interface A {
@@ -29,7 +29,7 @@ declare module "D" {
import {A} from "./a";
import {Cls} from "C";
(<any>A.prototype).getCls = function () {}
A.prototype.getCls = function () { return undefined; }
declare module "./a" {
interface A {