From 36c489c8dbea802c85a188670e163304d75da8fe Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 14 Jan 2016 16:07:26 -0800 Subject: [PATCH] address PR feedback --- src/compiler/checker.ts | 19 +++++++------- .../moduleAugmentationImportsAndExports1.js | 4 +-- ...duleAugmentationImportsAndExports1.symbols | 5 +++- ...moduleAugmentationImportsAndExports1.types | 13 +++++----- ...eAugmentationImportsAndExports2.errors.txt | 7 +++-- .../moduleAugmentationImportsAndExports2.js | 4 +-- ...eAugmentationImportsAndExports3.errors.txt | 2 +- .../moduleAugmentationImportsAndExports3.js | 4 +-- .../moduleAugmentationImportsAndExports4.js | 4 +-- ...duleAugmentationImportsAndExports4.symbols | 11 +++++--- ...moduleAugmentationImportsAndExports4.types | 13 +++++----- ...eAugmentationImportsAndExports5.errors.txt | 2 +- .../moduleAugmentationImportsAndExports5.js | 4 +-- .../moduleAugmentationImportsAndExports6.js | 4 +-- ...duleAugmentationImportsAndExports6.symbols | 11 +++++--- ...moduleAugmentationImportsAndExports6.types | 13 +++++----- .../reference/moduleAugmentationsImports1.js | 8 +++--- .../moduleAugmentationsImports1.symbols | 10 +++++-- .../moduleAugmentationsImports1.types | 26 +++++++++---------- .../reference/moduleAugmentationsImports2.js | 8 +++--- .../moduleAugmentationsImports2.symbols | 10 +++++-- .../moduleAugmentationsImports2.types | 26 +++++++++---------- .../reference/moduleAugmentationsImports3.js | 4 +-- .../moduleAugmentationsImports3.symbols | 5 +++- .../moduleAugmentationsImports3.types | 13 +++++----- .../moduleAugmentationImportsAndExports1.ts | 2 +- .../moduleAugmentationImportsAndExports2.ts | 2 +- .../moduleAugmentationImportsAndExports3.ts | 2 +- .../moduleAugmentationImportsAndExports4.ts | 2 +- .../moduleAugmentationImportsAndExports5.ts | 2 +- .../moduleAugmentationImportsAndExports6.ts | 2 +- .../compiler/moduleAugmentationsImports1.ts | 4 +-- .../compiler/moduleAugmentationsImports2.ts | 4 +-- .../compiler/moduleAugmentationsImports3.ts | 2 +- 34 files changed, 135 insertions(+), 117 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3b48ff4bf45..1f265e59e06 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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 = getDeclaredTypeOfSymbol(prototype.parent); + const classType = getDeclaredTypeOfSymbol(getMergedSymbol(prototype.parent)); return classType.typeParameters ? createTypeReference(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); } } diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports1.js b/tests/baselines/reference/moduleAugmentationImportsAndExports1.js index 6c6dc72337e..7159e7b5d0c 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports1.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports1.js @@ -13,7 +13,7 @@ export class B { import {A} from "./f1"; import {B} from "./f2"; -(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"); diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports1.symbols b/tests/baselines/reference/moduleAugmentationImportsAndExports1.symbols index 4d9f8217e4c..c641cad5228 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports1.symbols +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports1.symbols @@ -18,10 +18,13 @@ import {A} from "./f1"; import {B} from "./f2"; >B : Symbol(B, Decl(f3.ts, 1, 8)) -(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 { diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports1.types b/tests/baselines/reference/moduleAugmentationImportsAndExports1.types index 53ea84f96eb..886a04b54ef 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports1.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports1.types @@ -18,16 +18,15 @@ import {A} from "./f1"; import {B} from "./f2"; >B : typeof B -(A.prototype).foo = function () {} ->(A.prototype).foo = function () {} : () => void ->(A.prototype).foo : any ->(A.prototype) : 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 { diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports2.errors.txt b/tests/baselines/reference/moduleAugmentationImportsAndExports2.errors.txt index 28cb7a7a7e9..deb3881e209 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports2.errors.txt +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports2.errors.txt @@ -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"; - (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 } diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports2.js b/tests/baselines/reference/moduleAugmentationImportsAndExports2.js index b0351c1c332..3a4a807a334 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports2.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports2.js @@ -12,7 +12,7 @@ export class B { //// [f3.ts] import {A} from "./f1"; -(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"); diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.errors.txt b/tests/baselines/reference/moduleAugmentationImportsAndExports3.errors.txt index b84ac9ece87..a7c8fa2cff2 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports3.errors.txt +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.errors.txt @@ -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"; - (A.prototype).foo = function () {} + A.prototype.foo = function () { return undefined; } namespace N { export interface Ifc { a } diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports3.js b/tests/baselines/reference/moduleAugmentationImportsAndExports3.js index 381ae5e1d10..d872a79e985 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports3.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports3.js @@ -12,7 +12,7 @@ export class B { //// [f3.ts] import {A} from "./f1"; -(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"); diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports4.js b/tests/baselines/reference/moduleAugmentationImportsAndExports4.js index cbb844fa20e..53095555815 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports4.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports4.js @@ -13,7 +13,7 @@ export class B { import {A} from "./f1"; import {B} from "./f2"; -(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"); diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports4.symbols b/tests/baselines/reference/moduleAugmentationImportsAndExports4.symbols index d526ce96866..94dc05519dd 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports4.symbols +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports4.symbols @@ -18,13 +18,16 @@ import {A} from "./f1"; import {B} from "./f2"; >B : Symbol(B, Decl(f3.ts, 1, 8)) -(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" { diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports4.types b/tests/baselines/reference/moduleAugmentationImportsAndExports4.types index 5931989ab42..454dc5d27ec 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports4.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports4.types @@ -18,16 +18,15 @@ import {A} from "./f1"; import {B} from "./f2"; >B : typeof B -(A.prototype).foo = function () {} ->(A.prototype).foo = function () {} : () => void ->(A.prototype).foo : any ->(A.prototype) : 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 diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports5.errors.txt b/tests/baselines/reference/moduleAugmentationImportsAndExports5.errors.txt index 177038d8aaf..5f783453888 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports5.errors.txt +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports5.errors.txt @@ -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"; - (A.prototype).foo = function () {} + A.prototype.foo = function () { return undefined; } namespace N { export interface Ifc { a: number; } diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports5.js b/tests/baselines/reference/moduleAugmentationImportsAndExports5.js index a69ccbf3855..c9b622ccf25 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports5.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports5.js @@ -13,7 +13,7 @@ export class B { import {A} from "./f1"; import {B} from "./f2"; -(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"); diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports6.js b/tests/baselines/reference/moduleAugmentationImportsAndExports6.js index c0cc8778ab1..f0b297720b3 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports6.js +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports6.js @@ -13,7 +13,7 @@ export class B { import {A} from "./f1"; import {B} from "./f2"; -(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"); diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports6.symbols b/tests/baselines/reference/moduleAugmentationImportsAndExports6.symbols index 3add4b08e8d..92952ef94bc 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports6.symbols +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports6.symbols @@ -18,13 +18,16 @@ import {A} from "./f1"; import {B} from "./f2"; >B : Symbol(B, Decl(f3.ts, 1, 8)) -(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" { diff --git a/tests/baselines/reference/moduleAugmentationImportsAndExports6.types b/tests/baselines/reference/moduleAugmentationImportsAndExports6.types index f7935e16c16..0c201599b52 100644 --- a/tests/baselines/reference/moduleAugmentationImportsAndExports6.types +++ b/tests/baselines/reference/moduleAugmentationImportsAndExports6.types @@ -18,16 +18,15 @@ import {A} from "./f1"; import {B} from "./f2"; >B : typeof B -(A.prototype).foo = function () {} ->(A.prototype).foo = function () {} : () => void ->(A.prototype).foo : any ->(A.prototype) : 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 diff --git a/tests/baselines/reference/moduleAugmentationsImports1.js b/tests/baselines/reference/moduleAugmentationsImports1.js index 4730afa4a5f..2c635a0719e 100644 --- a/tests/baselines/reference/moduleAugmentationsImports1.js +++ b/tests/baselines/reference/moduleAugmentationsImports1.js @@ -19,8 +19,8 @@ import {A} from "./a"; import {B} from "./b"; import {Cls} from "C"; -(A.prototype).getB = function () {}; -(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) { /// 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"; diff --git a/tests/baselines/reference/moduleAugmentationsImports1.symbols b/tests/baselines/reference/moduleAugmentationsImports1.symbols index 8f4cfd09868..38ef8f55229 100644 --- a/tests/baselines/reference/moduleAugmentationsImports1.symbols +++ b/tests/baselines/reference/moduleAugmentationsImports1.symbols @@ -27,15 +27,21 @@ import {B} from "./b"; import {Cls} from "C"; >Cls : Symbol(Cls, Decl(d.ts, 4, 8)) -(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) -(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 { diff --git a/tests/baselines/reference/moduleAugmentationsImports1.types b/tests/baselines/reference/moduleAugmentationsImports1.types index 14e0d32da59..bf0bfee0a7a 100644 --- a/tests/baselines/reference/moduleAugmentationsImports1.types +++ b/tests/baselines/reference/moduleAugmentationsImports1.types @@ -27,27 +27,25 @@ import {B} from "./b"; import {Cls} from "C"; >Cls : typeof Cls -(A.prototype).getB = function () {}; ->(A.prototype).getB = function () {} : () => void ->(A.prototype).getB : any ->(A.prototype) : 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 -(A.prototype).getCls = function () {} ->(A.prototype).getCls = function () {} : () => void ->(A.prototype).getCls : any ->(A.prototype) : 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 { diff --git a/tests/baselines/reference/moduleAugmentationsImports2.js b/tests/baselines/reference/moduleAugmentationsImports2.js index b0aee584a55..f70426b49bd 100644 --- a/tests/baselines/reference/moduleAugmentationsImports2.js +++ b/tests/baselines/reference/moduleAugmentationsImports2.js @@ -18,7 +18,7 @@ declare module "C" { import {A} from "./a"; import {B} from "./b"; -(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"; -(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) { /// 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"; diff --git a/tests/baselines/reference/moduleAugmentationsImports2.symbols b/tests/baselines/reference/moduleAugmentationsImports2.symbols index 20a5f779b8d..643ccf20eb2 100644 --- a/tests/baselines/reference/moduleAugmentationsImports2.symbols +++ b/tests/baselines/reference/moduleAugmentationsImports2.symbols @@ -24,10 +24,13 @@ import {A} from "./a"; import {B} from "./b"; >B : Symbol(B, Decl(d.ts, 3, 8)) -(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)) -(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 { diff --git a/tests/baselines/reference/moduleAugmentationsImports2.types b/tests/baselines/reference/moduleAugmentationsImports2.types index b2c20f17886..56b40625600 100644 --- a/tests/baselines/reference/moduleAugmentationsImports2.types +++ b/tests/baselines/reference/moduleAugmentationsImports2.types @@ -24,16 +24,15 @@ import {A} from "./a"; import {B} from "./b"; >B : typeof B -(A.prototype).getB = function () {}; ->(A.prototype).getB = function () {} : () => void ->(A.prototype).getB : any ->(A.prototype) : 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 -(A.prototype).getCls = function () {} ->(A.prototype).getCls = function () {} : () => void ->(A.prototype).getCls : any ->(A.prototype) : 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 { diff --git a/tests/baselines/reference/moduleAugmentationsImports3.js b/tests/baselines/reference/moduleAugmentationsImports3.js index 2254d3e3ff9..3654583b5c9 100644 --- a/tests/baselines/reference/moduleAugmentationsImports3.js +++ b/tests/baselines/reference/moduleAugmentationsImports3.js @@ -28,7 +28,7 @@ declare module "D" { import {A} from "./a"; import {Cls} from "C"; -(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"; diff --git a/tests/baselines/reference/moduleAugmentationsImports3.symbols b/tests/baselines/reference/moduleAugmentationsImports3.symbols index 514e412c5cf..db8eee074c0 100644 --- a/tests/baselines/reference/moduleAugmentationsImports3.symbols +++ b/tests/baselines/reference/moduleAugmentationsImports3.symbols @@ -74,10 +74,13 @@ import {A} from "./a"; import {Cls} from "C"; >Cls : Symbol(Cls, Decl(e.ts, 2, 8)) -(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 { diff --git a/tests/baselines/reference/moduleAugmentationsImports3.types b/tests/baselines/reference/moduleAugmentationsImports3.types index ba930c4f857..04d17296c56 100644 --- a/tests/baselines/reference/moduleAugmentationsImports3.types +++ b/tests/baselines/reference/moduleAugmentationsImports3.types @@ -78,16 +78,15 @@ import {A} from "./a"; import {Cls} from "C"; >Cls : typeof Cls -(A.prototype).getCls = function () {} ->(A.prototype).getCls = function () {} : () => void ->(A.prototype).getCls : any ->(A.prototype) : 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 { diff --git a/tests/cases/compiler/moduleAugmentationImportsAndExports1.ts b/tests/cases/compiler/moduleAugmentationImportsAndExports1.ts index b5e8a07a70e..165057cf025 100644 --- a/tests/cases/compiler/moduleAugmentationImportsAndExports1.ts +++ b/tests/cases/compiler/moduleAugmentationImportsAndExports1.ts @@ -13,7 +13,7 @@ export class B { import {A} from "./f1"; import {B} from "./f2"; -(A.prototype).foo = function () {} +A.prototype.foo = function () { return undefined; } declare module "./f1" { interface A { foo(): B; diff --git a/tests/cases/compiler/moduleAugmentationImportsAndExports2.ts b/tests/cases/compiler/moduleAugmentationImportsAndExports2.ts index 8cd9f8ffdba..8e76475c404 100644 --- a/tests/cases/compiler/moduleAugmentationImportsAndExports2.ts +++ b/tests/cases/compiler/moduleAugmentationImportsAndExports2.ts @@ -12,7 +12,7 @@ export class B { // @filename: f3.ts import {A} from "./f1"; -(A.prototype).foo = function () {} +A.prototype.foo = function () { return undefined; } namespace N { export interface Ifc { a } diff --git a/tests/cases/compiler/moduleAugmentationImportsAndExports3.ts b/tests/cases/compiler/moduleAugmentationImportsAndExports3.ts index 170bb6c3d11..ea1d5e435da 100644 --- a/tests/cases/compiler/moduleAugmentationImportsAndExports3.ts +++ b/tests/cases/compiler/moduleAugmentationImportsAndExports3.ts @@ -12,7 +12,7 @@ export class B { // @filename: f3.ts import {A} from "./f1"; -(A.prototype).foo = function () {} +A.prototype.foo = function () { return undefined; } namespace N { export interface Ifc { a } diff --git a/tests/cases/compiler/moduleAugmentationImportsAndExports4.ts b/tests/cases/compiler/moduleAugmentationImportsAndExports4.ts index d9eb823d8e0..3f3b9e19400 100644 --- a/tests/cases/compiler/moduleAugmentationImportsAndExports4.ts +++ b/tests/cases/compiler/moduleAugmentationImportsAndExports4.ts @@ -12,7 +12,7 @@ export class B { import {A} from "./f1"; import {B} from "./f2"; -(A.prototype).foo = function () {} +A.prototype.foo = function () { return undefined; } namespace N { export interface Ifc { a: number; } diff --git a/tests/cases/compiler/moduleAugmentationImportsAndExports5.ts b/tests/cases/compiler/moduleAugmentationImportsAndExports5.ts index 2e799a215b5..8dbff8f7cc9 100644 --- a/tests/cases/compiler/moduleAugmentationImportsAndExports5.ts +++ b/tests/cases/compiler/moduleAugmentationImportsAndExports5.ts @@ -13,7 +13,7 @@ export class B { import {A} from "./f1"; import {B} from "./f2"; -(A.prototype).foo = function () {} +A.prototype.foo = function () { return undefined; } namespace N { export interface Ifc { a: number; } diff --git a/tests/cases/compiler/moduleAugmentationImportsAndExports6.ts b/tests/cases/compiler/moduleAugmentationImportsAndExports6.ts index aafab20943f..e9e216cbbbe 100644 --- a/tests/cases/compiler/moduleAugmentationImportsAndExports6.ts +++ b/tests/cases/compiler/moduleAugmentationImportsAndExports6.ts @@ -13,7 +13,7 @@ export class B { import {A} from "./f1"; import {B} from "./f2"; -(A.prototype).foo = function () {} +A.prototype.foo = function () { return undefined; } export namespace N { export interface Ifc { a: number; } diff --git a/tests/cases/compiler/moduleAugmentationsImports1.ts b/tests/cases/compiler/moduleAugmentationsImports1.ts index cec14867802..ad029bdfc4a 100644 --- a/tests/cases/compiler/moduleAugmentationsImports1.ts +++ b/tests/cases/compiler/moduleAugmentationsImports1.ts @@ -20,8 +20,8 @@ import {A} from "./a"; import {B} from "./b"; import {Cls} from "C"; -(A.prototype).getB = function () {}; -(A.prototype).getCls = function () {} +A.prototype.getB = function () { return undefined; } +A.prototype.getCls = function () { return undefined; } declare module "./a" { interface A { diff --git a/tests/cases/compiler/moduleAugmentationsImports2.ts b/tests/cases/compiler/moduleAugmentationsImports2.ts index 1b0365ec420..bf5b4b1cd17 100644 --- a/tests/cases/compiler/moduleAugmentationsImports2.ts +++ b/tests/cases/compiler/moduleAugmentationsImports2.ts @@ -19,7 +19,7 @@ declare module "C" { import {A} from "./a"; import {B} from "./b"; -(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"; -(A.prototype).getCls = function () {} +A.prototype.getCls = function () { return undefined; } declare module "./a" { interface A { diff --git a/tests/cases/compiler/moduleAugmentationsImports3.ts b/tests/cases/compiler/moduleAugmentationsImports3.ts index 2075d66e1d3..92cc6c73a3c 100644 --- a/tests/cases/compiler/moduleAugmentationsImports3.ts +++ b/tests/cases/compiler/moduleAugmentationsImports3.ts @@ -29,7 +29,7 @@ declare module "D" { import {A} from "./a"; import {Cls} from "C"; -(A.prototype).getCls = function () {} +A.prototype.getCls = function () { return undefined; } declare module "./a" { interface A {