mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-09 07:55:10 -05:00
Update baselines
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
==== tests/cases/compiler/accessorParameterAccessibilityModifier.ts (4 errors) ====
|
||||
// target: es5
|
||||
|
||||
class C {
|
||||
set X(public v) { }
|
||||
~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
!!! A parameter property is only allowed in a constructor implementation.
|
||||
~~~~~~~~
|
||||
!!! A parameter property is only allowed in a constructor implementation.
|
||||
static set X(public v2) { }
|
||||
~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
!!! A parameter property is only allowed in a constructor implementation.
|
||||
~~~~~~~~~
|
||||
!!! A parameter property is only allowed in a constructor implementation.
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
==== tests/cases/compiler/accessorWithInitializer.ts (2 errors) ====
|
||||
// target: es5
|
||||
|
||||
class C {
|
||||
set X(v = 0) { }
|
||||
~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
!!! A 'set' accessor parameter cannot have an initializer.
|
||||
static set X(v2 = 0) { }
|
||||
~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
!!! A 'set' accessor parameter cannot have an initializer.
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
==== tests/cases/compiler/accessorWithRestParam.ts (2 errors) ====
|
||||
|
||||
class C {
|
||||
set X(...v) { }
|
||||
~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
!!! A 'set' accessor cannot have rest parameter.
|
||||
static set X(...v2) { }
|
||||
~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
!!! A 'set' accessor cannot have rest parameter.
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
==== tests/cases/compiler/aliasInaccessibleModule.ts (1 errors) ====
|
||||
module M {
|
||||
module N {
|
||||
}
|
||||
export import X = N;
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! Import declaration 'X' is using private name 'N'.
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
=== tests/cases/compiler/aliasInaccessibleModule.ts ===
|
||||
module M {
|
||||
>M : M
|
||||
|
||||
module N {
|
||||
>N : N
|
||||
}
|
||||
export import X = N;
|
||||
>X : X
|
||||
>N : N
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
==== tests/cases/compiler/aliasInaccessibleModule2.ts (1 errors) ====
|
||||
module M {
|
||||
module N {
|
||||
class C {
|
||||
}
|
||||
|
||||
}
|
||||
import R = N;
|
||||
~~~~~~~~~~~~~
|
||||
!!! Import declaration 'R' is using private name 'N'.
|
||||
export import X = R;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
=== tests/cases/compiler/aliasInaccessibleModule2.ts ===
|
||||
module M {
|
||||
>M : M
|
||||
|
||||
module N {
|
||||
>N : N
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
}
|
||||
|
||||
}
|
||||
import R = N;
|
||||
>R : R
|
||||
>N : typeof N
|
||||
|
||||
export import X = R;
|
||||
>X : X
|
||||
>R : typeof N
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
==== tests/cases/compiler/aliasUsage1_main.ts (2 errors) ====
|
||||
import Backbone = require("aliasUsage1_backbone");
|
||||
import moduleA = require("aliasUsage1_moduleA");
|
||||
interface IHasVisualizationModel {
|
||||
VisualizationModel: typeof Backbone.Model;
|
||||
}
|
||||
class C2 {
|
||||
x: IHasVisualizationModel;
|
||||
get A() {
|
||||
~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
return this.x;
|
||||
}
|
||||
set A(x) {
|
||||
~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
x = moduleA;
|
||||
}
|
||||
}
|
||||
==== tests/cases/compiler/aliasUsage1_backbone.ts (0 errors) ====
|
||||
export class Model {
|
||||
public someData: string;
|
||||
}
|
||||
|
||||
==== tests/cases/compiler/aliasUsage1_moduleA.ts (0 errors) ====
|
||||
import Backbone = require("aliasUsage1_backbone");
|
||||
export class VisualizationModel extends Backbone.Model {
|
||||
// interesting stuff here
|
||||
}
|
||||
|
||||
69
tests/baselines/reference/aliasUsageInAccessorsOfClass.js
Normal file
69
tests/baselines/reference/aliasUsageInAccessorsOfClass.js
Normal file
@@ -0,0 +1,69 @@
|
||||
//// [tests/cases/compiler/aliasUsageInAccessorsOfClass.ts] ////
|
||||
|
||||
//// [aliasUsage1_backbone.ts]
|
||||
export class Model {
|
||||
public someData: string;
|
||||
}
|
||||
|
||||
//// [aliasUsage1_moduleA.ts]
|
||||
import Backbone = require("aliasUsage1_backbone");
|
||||
export class VisualizationModel extends Backbone.Model {
|
||||
// interesting stuff here
|
||||
}
|
||||
|
||||
//// [aliasUsage1_main.ts]
|
||||
import Backbone = require("aliasUsage1_backbone");
|
||||
import moduleA = require("aliasUsage1_moduleA");
|
||||
interface IHasVisualizationModel {
|
||||
VisualizationModel: typeof Backbone.Model;
|
||||
}
|
||||
class C2 {
|
||||
x: IHasVisualizationModel;
|
||||
get A() {
|
||||
return this.x;
|
||||
}
|
||||
set A(x) {
|
||||
x = moduleA;
|
||||
}
|
||||
}
|
||||
|
||||
//// [aliasUsage1_backbone.js]
|
||||
var Model = (function () {
|
||||
function Model() {
|
||||
}
|
||||
return Model;
|
||||
})();
|
||||
exports.Model = Model;
|
||||
//// [aliasUsage1_moduleA.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Backbone = require("aliasUsage1_backbone");
|
||||
var VisualizationModel = (function (_super) {
|
||||
__extends(VisualizationModel, _super);
|
||||
function VisualizationModel() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return VisualizationModel;
|
||||
})(Backbone.Model);
|
||||
exports.VisualizationModel = VisualizationModel;
|
||||
//// [aliasUsage1_main.js]
|
||||
var moduleA = require("aliasUsage1_moduleA");
|
||||
var C2 = (function () {
|
||||
function C2() {
|
||||
}
|
||||
Object.defineProperty(C2.prototype, "A", {
|
||||
get: function () {
|
||||
return this.x;
|
||||
},
|
||||
set: function (x) {
|
||||
x = moduleA;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C2;
|
||||
})();
|
||||
60
tests/baselines/reference/aliasUsageInAccessorsOfClass.types
Normal file
60
tests/baselines/reference/aliasUsageInAccessorsOfClass.types
Normal file
@@ -0,0 +1,60 @@
|
||||
=== tests/cases/compiler/aliasUsage1_main.ts ===
|
||||
import Backbone = require("aliasUsage1_backbone");
|
||||
>Backbone : Backbone
|
||||
|
||||
import moduleA = require("aliasUsage1_moduleA");
|
||||
>moduleA : moduleA
|
||||
|
||||
interface IHasVisualizationModel {
|
||||
>IHasVisualizationModel : IHasVisualizationModel
|
||||
|
||||
VisualizationModel: typeof Backbone.Model;
|
||||
>VisualizationModel : typeof Backbone.Model
|
||||
>Backbone : typeof Backbone
|
||||
>Model : typeof Backbone.Model
|
||||
}
|
||||
class C2 {
|
||||
>C2 : C2
|
||||
|
||||
x: IHasVisualizationModel;
|
||||
>x : IHasVisualizationModel
|
||||
>IHasVisualizationModel : IHasVisualizationModel
|
||||
|
||||
get A() {
|
||||
>A : IHasVisualizationModel
|
||||
|
||||
return this.x;
|
||||
>this.x : IHasVisualizationModel
|
||||
>this : C2
|
||||
>x : IHasVisualizationModel
|
||||
}
|
||||
set A(x) {
|
||||
>A : IHasVisualizationModel
|
||||
>x : IHasVisualizationModel
|
||||
|
||||
x = moduleA;
|
||||
>x = moduleA : typeof moduleA
|
||||
>x : IHasVisualizationModel
|
||||
>moduleA : typeof moduleA
|
||||
}
|
||||
}
|
||||
=== tests/cases/compiler/aliasUsage1_backbone.ts ===
|
||||
export class Model {
|
||||
>Model : Model
|
||||
|
||||
public someData: string;
|
||||
>someData : string
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/aliasUsage1_moduleA.ts ===
|
||||
import Backbone = require("aliasUsage1_backbone");
|
||||
>Backbone : Backbone
|
||||
|
||||
export class VisualizationModel extends Backbone.Model {
|
||||
>VisualizationModel : VisualizationModel
|
||||
>Backbone : Backbone
|
||||
>Model : Backbone.Model
|
||||
|
||||
// interesting stuff here
|
||||
}
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
==== tests/cases/compiler/ambientExternalModuleWithRelativeModuleName.ts (1 errors) ====
|
||||
==== tests/cases/compiler/ambientExternalModuleWithRelativeModuleName.ts (2 errors) ====
|
||||
declare module "./relativeModule" {
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! Ambient external module declaration cannot specify relative module name.
|
||||
var x: string;
|
||||
}
|
||||
|
||||
declare module ".\\relativeModule" {
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! Ambient external module declaration cannot specify relative module name.
|
||||
var x: string;
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
//// [ambientExternalModuleWithRelativeModuleName.ts]
|
||||
declare module "./relativeModule" {
|
||||
var x: string;
|
||||
}
|
||||
|
||||
declare module ".\\relativeModule" {
|
||||
var x: string;
|
||||
}
|
||||
|
||||
//// [ambientExternalModuleWithRelativeModuleName.js]
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
==== tests/cases/compiler/ambientGetters.ts (2 errors) ====
|
||||
|
||||
declare class A {
|
||||
get length() : number;
|
||||
~~~~~~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
!!! An accessor cannot be declared in an ambient context.
|
||||
}
|
||||
|
||||
declare class B {
|
||||
get length() { return 0; }
|
||||
~~~~~~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
!!! An accessor cannot be declared in an ambient context.
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
==== tests/cases/compiler/amdDependencyComment2.ts (1 errors) ====
|
||||
///<amd-dependency path='bar'/>
|
||||
|
||||
import m1 = require("m2")
|
||||
~~~~
|
||||
!!! Cannot find external module 'm2'.
|
||||
m1.f();
|
||||
11
tests/baselines/reference/amdDependencyComment2.js
Normal file
11
tests/baselines/reference/amdDependencyComment2.js
Normal file
@@ -0,0 +1,11 @@
|
||||
//// [amdDependencyComment2.ts]
|
||||
///<amd-dependency path='bar'/>
|
||||
|
||||
import m1 = require("m2")
|
||||
m1.f();
|
||||
|
||||
//// [amdDependencyComment2.js]
|
||||
///<amd-dependency path='bar'/>
|
||||
define(["require", "exports", "m2", "bar"], function (require, exports, m1) {
|
||||
m1.f();
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
==== tests/cases/compiler/arrowFunctionMissingCurlyWithSemicolon.ts (1 errors) ====
|
||||
// Should error at semicolon.
|
||||
var f = () => ;
|
||||
~
|
||||
!!! Expression expected.
|
||||
var b = 1 * 2 * 3 * 4;
|
||||
var square = (x: number) => x * x;
|
||||
115
tests/baselines/reference/arrowFunctionsMissingTokens.errors.txt
Normal file
115
tests/baselines/reference/arrowFunctionsMissingTokens.errors.txt
Normal file
@@ -0,0 +1,115 @@
|
||||
==== tests/cases/compiler/arrowFunctionsMissingTokens.ts (24 errors) ====
|
||||
|
||||
module missingArrowsWithCurly {
|
||||
var a = () { };
|
||||
~
|
||||
!!! '=>' expected.
|
||||
|
||||
var b = (): void { }
|
||||
~
|
||||
!!! '=>' expected.
|
||||
|
||||
var c = (x) { };
|
||||
~
|
||||
!!! '=>' expected.
|
||||
|
||||
var d = (x: number, y: string) { };
|
||||
~
|
||||
!!! '=>' expected.
|
||||
|
||||
var e = (x: number, y: string): void { };
|
||||
~
|
||||
!!! '=>' expected.
|
||||
}
|
||||
|
||||
module missingCurliesWithArrow {
|
||||
module withStatement {
|
||||
var a = () => var k = 10;};
|
||||
~~~
|
||||
!!! '{' expected.
|
||||
|
||||
var b = (): void => var k = 10;}
|
||||
~~~
|
||||
!!! '{' expected.
|
||||
|
||||
var c = (x) => var k = 10;};
|
||||
~~~
|
||||
!!! '{' expected.
|
||||
|
||||
var d = (x: number, y: string) => var k = 10;};
|
||||
~~~
|
||||
!!! '{' expected.
|
||||
|
||||
var e = (x: number, y: string): void => var k = 10;};
|
||||
~~~
|
||||
!!! '{' expected.
|
||||
|
||||
var f = () => var k = 10;}
|
||||
~~~
|
||||
!!! '{' expected.
|
||||
}
|
||||
|
||||
module withoutStatement {
|
||||
var a = () => };
|
||||
~
|
||||
!!! Expression expected.
|
||||
|
||||
var b = (): void => }
|
||||
~
|
||||
!!! Expression expected.
|
||||
|
||||
var c = (x) => };
|
||||
~
|
||||
!!! Expression expected.
|
||||
|
||||
var d = (x: number, y: string) => };
|
||||
~
|
||||
!!! Expression expected.
|
||||
|
||||
var e = (x: number, y: string): void => };
|
||||
~
|
||||
!!! Expression expected.
|
||||
|
||||
var f = () => }
|
||||
~
|
||||
!!! Expression expected.
|
||||
}
|
||||
~
|
||||
!!! Declaration or statement expected.
|
||||
}
|
||||
~
|
||||
!!! Declaration or statement expected.
|
||||
|
||||
module ce_nEst_pas_une_arrow_function {
|
||||
var a = ();
|
||||
~
|
||||
!!! Expression expected.
|
||||
|
||||
var b = (): void;
|
||||
~
|
||||
!!! '=>' expected.
|
||||
|
||||
var c = (x);
|
||||
~
|
||||
!!! Cannot find name 'x'.
|
||||
|
||||
var d = (x: number, y: string);
|
||||
~
|
||||
!!! '=>' expected.
|
||||
|
||||
var e = (x: number, y: string): void;
|
||||
~
|
||||
!!! '=>' expected.
|
||||
}
|
||||
|
||||
module okay {
|
||||
var a = () => { };
|
||||
|
||||
var b = (): void => { }
|
||||
|
||||
var c = (x) => { };
|
||||
|
||||
var d = (x: number, y: string) => { };
|
||||
|
||||
var e = (x: number, y: string): void => { };
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
//// [asiAmbientFunctionDeclaration.ts]
|
||||
declare function foo()
|
||||
|
||||
//// [asiAmbientFunctionDeclaration.js]
|
||||
@@ -0,0 +1,4 @@
|
||||
=== tests/cases/compiler/asiAmbientFunctionDeclaration.ts ===
|
||||
declare function foo()
|
||||
>foo : typeof foo
|
||||
|
||||
6
tests/baselines/reference/asiBreak.js
Normal file
6
tests/baselines/reference/asiBreak.js
Normal file
@@ -0,0 +1,6 @@
|
||||
//// [asiBreak.ts]
|
||||
while (true) break
|
||||
|
||||
//// [asiBreak.js]
|
||||
while (true)
|
||||
break;
|
||||
3
tests/baselines/reference/asiBreak.types
Normal file
3
tests/baselines/reference/asiBreak.types
Normal file
@@ -0,0 +1,3 @@
|
||||
=== tests/cases/compiler/asiBreak.ts ===
|
||||
while (true) break
|
||||
No type information for this code.
|
||||
6
tests/baselines/reference/asiContinue.js
Normal file
6
tests/baselines/reference/asiContinue.js
Normal file
@@ -0,0 +1,6 @@
|
||||
//// [asiContinue.ts]
|
||||
while (true) continue
|
||||
|
||||
//// [asiContinue.js]
|
||||
while (true)
|
||||
continue;
|
||||
3
tests/baselines/reference/asiContinue.types
Normal file
3
tests/baselines/reference/asiContinue.types
Normal file
@@ -0,0 +1,3 @@
|
||||
=== tests/cases/compiler/asiContinue.ts ===
|
||||
while (true) continue
|
||||
No type information for this code.
|
||||
5
tests/baselines/reference/asiReturn.errors.txt
Normal file
5
tests/baselines/reference/asiReturn.errors.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
==== tests/cases/compiler/asiReturn.ts (1 errors) ====
|
||||
// This should be an error for using a return outside a function, but ASI should work properly
|
||||
return
|
||||
~~~~~~
|
||||
!!! A 'return' statement can only be used within a function body.
|
||||
@@ -1,14 +1,12 @@
|
||||
==== tests/cases/compiler/assignmentCompatability24.ts (2 errors) ====
|
||||
==== tests/cases/compiler/assignmentCompatability24.ts (1 errors) ====
|
||||
module __test1__ {
|
||||
export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };;
|
||||
export var __val__obj4 = obj4;
|
||||
}
|
||||
module __test2__ {
|
||||
export var obj = function f<string>(a: string) { return a; };;
|
||||
~~~~~~
|
||||
!!! Type parameter name cannot be 'string'
|
||||
export var obj = function f<Tstring>(a: Tstring) { return a; };;
|
||||
export var __val__obj = obj;
|
||||
}
|
||||
__test2__.__val__obj = __test1__.__val__obj4
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '<string>(a: string) => string'.
|
||||
!!! Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '<Tstring>(a: Tstring) => Tstring'.
|
||||
@@ -4,7 +4,7 @@ module __test1__ {
|
||||
export var __val__obj4 = obj4;
|
||||
}
|
||||
module __test2__ {
|
||||
export var obj = function f<string>(a: string) { return a; };;
|
||||
export var obj = function f<Tstring>(a: Tstring) { return a; };;
|
||||
export var __val__obj = obj;
|
||||
}
|
||||
__test2__.__val__obj = __test1__.__val__obj4
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
==== tests/cases/compiler/assignmentCompatability33.ts (2 errors) ====
|
||||
==== tests/cases/compiler/assignmentCompatability33.ts (1 errors) ====
|
||||
module __test1__ {
|
||||
export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };;
|
||||
export var __val__obj4 = obj4;
|
||||
}
|
||||
module __test2__ {
|
||||
export var obj: { <string>(a: string): string; };
|
||||
~~~~~~
|
||||
!!! Type parameter name cannot be 'string'
|
||||
export var obj: { <Tstring>(a: Tstring): Tstring; };
|
||||
export var __val__obj = obj;
|
||||
}
|
||||
__test2__.__val__obj = __test1__.__val__obj4
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '<string>(a: string) => string'.
|
||||
!!! Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '<Tstring>(a: Tstring) => Tstring'.
|
||||
@@ -4,7 +4,7 @@ module __test1__ {
|
||||
export var __val__obj4 = obj4;
|
||||
}
|
||||
module __test2__ {
|
||||
export var obj: { <string>(a: string): string; };
|
||||
export var obj: { <Tstring>(a: Tstring): Tstring; };
|
||||
export var __val__obj = obj;
|
||||
}
|
||||
__test2__.__val__obj = __test1__.__val__obj4
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
==== tests/cases/compiler/assignmentCompatability34.ts (2 errors) ====
|
||||
==== tests/cases/compiler/assignmentCompatability34.ts (1 errors) ====
|
||||
module __test1__ {
|
||||
export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };;
|
||||
export var __val__obj4 = obj4;
|
||||
}
|
||||
module __test2__ {
|
||||
export var obj: { <number>(a:number):number;};
|
||||
~~~~~~
|
||||
!!! Type parameter name cannot be 'number'
|
||||
export var obj: { <Tnumber>(a:Tnumber):Tnumber;};
|
||||
export var __val__obj = obj;
|
||||
}
|
||||
__test2__.__val__obj = __test1__.__val__obj4
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '<number>(a: number) => number'.
|
||||
!!! Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type '<Tnumber>(a: Tnumber) => Tnumber'.
|
||||
@@ -4,7 +4,7 @@ module __test1__ {
|
||||
export var __val__obj4 = obj4;
|
||||
}
|
||||
module __test2__ {
|
||||
export var obj: { <number>(a:number):number;};
|
||||
export var obj: { <Tnumber>(a:Tnumber):Tnumber;};
|
||||
export var __val__obj = obj;
|
||||
}
|
||||
__test2__.__val__obj = __test1__.__val__obj4
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
==== tests/cases/compiler/assignmentCompatability37.ts (2 errors) ====
|
||||
==== tests/cases/compiler/assignmentCompatability37.ts (1 errors) ====
|
||||
module __test1__ {
|
||||
export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };;
|
||||
export var __val__obj4 = obj4;
|
||||
}
|
||||
module __test2__ {
|
||||
export var aa:{ new <number>(param: number); };;
|
||||
~~~~~~
|
||||
!!! Type parameter name cannot be 'number'
|
||||
export var aa:{ new <Tnumber>(param: Tnumber); };;
|
||||
export var __val__aa = aa;
|
||||
}
|
||||
__test2__.__val__aa = __test1__.__val__obj4
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'new <number>(param: number) => any'.
|
||||
!!! Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'new <Tnumber>(param: Tnumber) => any'.
|
||||
@@ -4,7 +4,7 @@ module __test1__ {
|
||||
export var __val__obj4 = obj4;
|
||||
}
|
||||
module __test2__ {
|
||||
export var aa:{ new <number>(param: number); };;
|
||||
export var aa:{ new <Tnumber>(param: Tnumber); };;
|
||||
export var __val__aa = aa;
|
||||
}
|
||||
__test2__.__val__aa = __test1__.__val__obj4
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
==== tests/cases/compiler/assignmentCompatability38.ts (2 errors) ====
|
||||
==== tests/cases/compiler/assignmentCompatability38.ts (1 errors) ====
|
||||
module __test1__ {
|
||||
export interface interfaceWithPublicAndOptional<T,U> { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional<number,string> = { one: 1 };;
|
||||
export var __val__obj4 = obj4;
|
||||
}
|
||||
module __test2__ {
|
||||
export var aa:{ new <string>(param: string); };;
|
||||
~~~~~~
|
||||
!!! Type parameter name cannot be 'string'
|
||||
export var aa:{ new <Tstring>(param: Tstring); };;
|
||||
export var __val__aa = aa;
|
||||
}
|
||||
__test2__.__val__aa = __test1__.__val__obj4
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'new <string>(param: string) => any'.
|
||||
!!! Type 'interfaceWithPublicAndOptional<number, string>' is not assignable to type 'new <Tstring>(param: Tstring) => any'.
|
||||
@@ -4,7 +4,7 @@ module __test1__ {
|
||||
export var __val__obj4 = obj4;
|
||||
}
|
||||
module __test2__ {
|
||||
export var aa:{ new <string>(param: string); };;
|
||||
export var aa:{ new <Tstring>(param: Tstring); };;
|
||||
export var __val__aa = aa;
|
||||
}
|
||||
__test2__.__val__aa = __test1__.__val__obj4
|
||||
|
||||
6
tests/baselines/reference/augmentArray.js
Normal file
6
tests/baselines/reference/augmentArray.js
Normal file
@@ -0,0 +1,6 @@
|
||||
//// [augmentArray.ts]
|
||||
interface Array<T> {
|
||||
(): any[];
|
||||
}
|
||||
|
||||
//// [augmentArray.js]
|
||||
7
tests/baselines/reference/augmentArray.types
Normal file
7
tests/baselines/reference/augmentArray.types
Normal file
@@ -0,0 +1,7 @@
|
||||
=== tests/cases/compiler/augmentArray.ts ===
|
||||
interface Array<T> {
|
||||
>Array : Array<T>
|
||||
>T : T
|
||||
|
||||
(): any[];
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//// [autoAsiForStaticsInClassDeclaration.ts]
|
||||
class C {
|
||||
static x
|
||||
static y
|
||||
}
|
||||
|
||||
//// [autoAsiForStaticsInClassDeclaration.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,10 @@
|
||||
=== tests/cases/compiler/autoAsiForStaticsInClassDeclaration.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
static x
|
||||
>x : any
|
||||
|
||||
static y
|
||||
>y : any
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
==== tests/cases/compiler/badArraySyntax.ts (4 errors) ====
|
||||
==== tests/cases/compiler/badArraySyntax.ts (6 errors) ====
|
||||
class Z {
|
||||
public x = "";
|
||||
}
|
||||
@@ -16,5 +16,9 @@
|
||||
var a5: Z[] = new Z[]();
|
||||
~~
|
||||
!!! 'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead.
|
||||
|
||||
var a6: Z[][] = new Z [ ] [ ];
|
||||
~~~~~~~~
|
||||
!!! 'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead.
|
||||
~~~~
|
||||
!!! 'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead.
|
||||
|
||||
32
tests/baselines/reference/captureThisInSuperCall.js
Normal file
32
tests/baselines/reference/captureThisInSuperCall.js
Normal file
@@ -0,0 +1,32 @@
|
||||
//// [captureThisInSuperCall.ts]
|
||||
class A {
|
||||
constructor(p:any) {}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
constructor() { super({ test: () => this.someMethod()}); }
|
||||
someMethod() {}
|
||||
}
|
||||
|
||||
//// [captureThisInSuperCall.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var A = (function () {
|
||||
function A(p) {
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
var B = (function (_super) {
|
||||
__extends(B, _super);
|
||||
function B() {
|
||||
var _this = this;
|
||||
_super.call(this, { test: function () { return _this.someMethod(); } });
|
||||
}
|
||||
B.prototype.someMethod = function () {
|
||||
};
|
||||
return B;
|
||||
})(A);
|
||||
25
tests/baselines/reference/captureThisInSuperCall.types
Normal file
25
tests/baselines/reference/captureThisInSuperCall.types
Normal file
@@ -0,0 +1,25 @@
|
||||
=== tests/cases/compiler/captureThisInSuperCall.ts ===
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
constructor(p:any) {}
|
||||
>p : any
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
>B : B
|
||||
>A : A
|
||||
|
||||
constructor() { super({ test: () => this.someMethod()}); }
|
||||
>super({ test: () => this.someMethod()}) : void
|
||||
>{ test: () => this.someMethod()} : { test: () => void; }
|
||||
>test : () => void
|
||||
>() => this.someMethod() : () => void
|
||||
>this.someMethod() : void
|
||||
>this.someMethod : () => void
|
||||
>this : B
|
||||
>someMethod : () => void
|
||||
|
||||
someMethod() {}
|
||||
>someMethod : () => void
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
==== tests/cases/compiler/castExpressionParentheses.ts (1 errors) ====
|
||||
declare var a;
|
||||
|
||||
// parentheses should be omitted
|
||||
// literals
|
||||
(<any>{a:0});
|
||||
(<any>[1,3,]);
|
||||
(<any>"string");
|
||||
(<any>23.0);
|
||||
(<any>/regexp/g);
|
||||
(<any>false);
|
||||
(<any>true);
|
||||
(<any>null);
|
||||
// names and dotted names
|
||||
(<any>this);
|
||||
(<any>this.x);
|
||||
(<any>(<any>a).x);
|
||||
(<any><any>a);
|
||||
(<any>a[0]);
|
||||
(<any>a.b["0"]);
|
||||
(<any>a()).x;
|
||||
|
||||
declare var A;
|
||||
|
||||
// should keep the parentheses in emit
|
||||
(<any>new A).foo;
|
||||
(<any>typeof A).x;
|
||||
(<any>-A).x;
|
||||
new (<any>A());
|
||||
(<any>()=> {})();
|
||||
~~~
|
||||
!!! Type parameter name cannot be 'any'
|
||||
(<any>function foo() { })();
|
||||
(<any><number><any>-A).x;
|
||||
|
||||
// nested cast, should keep one pair of parenthese
|
||||
(<any><number>(<any>-A)).x;
|
||||
|
||||
// nested parenthesized expression, should keep one pair of parenthese
|
||||
(<any>(A))
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ declare var A;
|
||||
(<any>typeof A).x;
|
||||
(<any>-A).x;
|
||||
new (<any>A());
|
||||
(<any>()=> {})();
|
||||
(<Tany>()=> {})();
|
||||
(<any>function foo() { })();
|
||||
(<any><number><any>-A).x;
|
||||
|
||||
|
||||
169
tests/baselines/reference/castExpressionParentheses.types
Normal file
169
tests/baselines/reference/castExpressionParentheses.types
Normal file
@@ -0,0 +1,169 @@
|
||||
=== tests/cases/compiler/castExpressionParentheses.ts ===
|
||||
declare var a;
|
||||
>a : any
|
||||
|
||||
// parentheses should be omitted
|
||||
// literals
|
||||
(<any>{a:0});
|
||||
>(<any>{a:0}) : any
|
||||
><any>{a:0} : any
|
||||
>{a:0} : { a: number; }
|
||||
>a : number
|
||||
|
||||
(<any>[1,3,]);
|
||||
>(<any>[1,3,]) : any
|
||||
><any>[1,3,] : any
|
||||
>[1,3,] : number[]
|
||||
|
||||
(<any>"string");
|
||||
>(<any>"string") : any
|
||||
><any>"string" : any
|
||||
|
||||
(<any>23.0);
|
||||
>(<any>23.0) : any
|
||||
><any>23.0 : any
|
||||
|
||||
(<any>/regexp/g);
|
||||
>(<any>/regexp/g) : any
|
||||
><any>/regexp/g : any
|
||||
|
||||
(<any>false);
|
||||
>(<any>false) : any
|
||||
><any>false : any
|
||||
|
||||
(<any>true);
|
||||
>(<any>true) : any
|
||||
><any>true : any
|
||||
|
||||
(<any>null);
|
||||
>(<any>null) : any
|
||||
><any>null : any
|
||||
|
||||
// names and dotted names
|
||||
(<any>this);
|
||||
>(<any>this) : any
|
||||
><any>this : any
|
||||
>this : any
|
||||
|
||||
(<any>this.x);
|
||||
>(<any>this.x) : any
|
||||
><any>this.x : any
|
||||
>this.x : any
|
||||
>this : any
|
||||
>x : any
|
||||
|
||||
(<any>(<any>a).x);
|
||||
>(<any>(<any>a).x) : any
|
||||
><any>(<any>a).x : any
|
||||
>(<any>a).x : any
|
||||
>(<any>a) : any
|
||||
><any>a : any
|
||||
>a : any
|
||||
>x : any
|
||||
|
||||
(<any><any>a);
|
||||
>(<any><any>a) : any
|
||||
><any><any>a : any
|
||||
><any>a : any
|
||||
>a : any
|
||||
|
||||
(<any>a[0]);
|
||||
>(<any>a[0]) : any
|
||||
><any>a[0] : any
|
||||
>a[0] : any
|
||||
>a : any
|
||||
|
||||
(<any>a.b["0"]);
|
||||
>(<any>a.b["0"]) : any
|
||||
><any>a.b["0"] : any
|
||||
>a.b["0"] : any
|
||||
>a.b : any
|
||||
>a : any
|
||||
>b : any
|
||||
|
||||
(<any>a()).x;
|
||||
>(<any>a()).x : any
|
||||
>(<any>a()) : any
|
||||
><any>a() : any
|
||||
>a() : any
|
||||
>a : any
|
||||
>x : any
|
||||
|
||||
declare var A;
|
||||
>A : any
|
||||
|
||||
// should keep the parentheses in emit
|
||||
(<any>new A).foo;
|
||||
>(<any>new A).foo : any
|
||||
>(<any>new A) : any
|
||||
><any>new A : any
|
||||
>new A : any
|
||||
>A : any
|
||||
>foo : any
|
||||
|
||||
(<any>typeof A).x;
|
||||
>(<any>typeof A).x : any
|
||||
>(<any>typeof A) : any
|
||||
><any>typeof A : any
|
||||
>typeof A : string
|
||||
>A : any
|
||||
>x : any
|
||||
|
||||
(<any>-A).x;
|
||||
>(<any>-A).x : any
|
||||
>(<any>-A) : any
|
||||
><any>-A : any
|
||||
>-A : number
|
||||
>A : any
|
||||
>x : any
|
||||
|
||||
new (<any>A());
|
||||
>new (<any>A()) : any
|
||||
>(<any>A()) : any
|
||||
><any>A() : any
|
||||
>A() : any
|
||||
>A : any
|
||||
|
||||
(<Tany>()=> {})();
|
||||
>(<Tany>()=> {})() : void
|
||||
>(<Tany>()=> {}) : <Tany>() => void
|
||||
><Tany>()=> {} : <Tany>() => void
|
||||
>Tany : Tany
|
||||
|
||||
(<any>function foo() { })();
|
||||
>(<any>function foo() { })() : any
|
||||
>(<any>function foo() { }) : any
|
||||
><any>function foo() { } : any
|
||||
>function foo() { } : () => void
|
||||
>foo : () => void
|
||||
|
||||
(<any><number><any>-A).x;
|
||||
>(<any><number><any>-A).x : any
|
||||
>(<any><number><any>-A) : any
|
||||
><any><number><any>-A : any
|
||||
><number><any>-A : number
|
||||
><any>-A : any
|
||||
>-A : number
|
||||
>A : any
|
||||
>x : any
|
||||
|
||||
// nested cast, should keep one pair of parenthese
|
||||
(<any><number>(<any>-A)).x;
|
||||
>(<any><number>(<any>-A)).x : any
|
||||
>(<any><number>(<any>-A)) : any
|
||||
><any><number>(<any>-A) : any
|
||||
><number>(<any>-A) : number
|
||||
>(<any>-A) : any
|
||||
><any>-A : any
|
||||
>-A : number
|
||||
>A : any
|
||||
>x : any
|
||||
|
||||
// nested parenthesized expression, should keep one pair of parenthese
|
||||
(<any>(A))
|
||||
>(<any>(A)) : any
|
||||
><any>(A) : any
|
||||
>(A) : any
|
||||
>A : any
|
||||
|
||||
|
||||
@@ -6,15 +6,19 @@ export module m {
|
||||
}
|
||||
|
||||
//// [chainedImportAlias_file1.ts]
|
||||
import x = require('chainedImportAlias_file1');
|
||||
import x = require('chainedImportAlias_file0');
|
||||
import y = x;
|
||||
declare var console: {
|
||||
log(message?: any);
|
||||
};
|
||||
console.log(y);
|
||||
y.m.foo();
|
||||
|
||||
|
||||
//// [chainedImportAlias_file0.js]
|
||||
(function (m) {
|
||||
function foo() {
|
||||
}
|
||||
m.foo = foo;
|
||||
})(exports.m || (exports.m = {}));
|
||||
var m = exports.m;
|
||||
//// [chainedImportAlias_file1.js]
|
||||
var x = require('chainedImportAlias_file1');
|
||||
var x = require('chainedImportAlias_file0');
|
||||
var y = x;
|
||||
console.log(y);
|
||||
y.m.foo();
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
=== tests/cases/compiler/chainedImportAlias_file1.ts ===
|
||||
import x = require('chainedImportAlias_file1');
|
||||
import x = require('chainedImportAlias_file0');
|
||||
>x : x
|
||||
|
||||
import y = x;
|
||||
>y : y
|
||||
>x : typeof x
|
||||
|
||||
declare var console: {
|
||||
>console : { log(message?: any): any; }
|
||||
|
||||
log(message?: any);
|
||||
>log : (message?: any) => any
|
||||
>message : any
|
||||
|
||||
};
|
||||
console.log(y);
|
||||
>console.log(y) : any
|
||||
>console.log : (message?: any) => any
|
||||
>console : { log(message?: any): any; }
|
||||
>log : (message?: any) => any
|
||||
y.m.foo();
|
||||
>y.m.foo() : void
|
||||
>y.m.foo : typeof x.m.foo
|
||||
>y.m : typeof x.m
|
||||
>y : typeof x
|
||||
>m : typeof x.m
|
||||
>foo : typeof x.m.foo
|
||||
|
||||
=== tests/cases/compiler/chainedImportAlias_file0.ts ===
|
||||
export module m {
|
||||
>m : m
|
||||
|
||||
export function foo() { }
|
||||
>foo : typeof foo
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive2.ts (3 errors) ====
|
||||
// classes cannot extend primitives
|
||||
|
||||
class C4a extends void {}
|
||||
~~~~
|
||||
!!! Identifier expected.
|
||||
class C5a extends null { }
|
||||
~~~~
|
||||
!!! Identifier expected.
|
||||
~
|
||||
!!! ';' expected.
|
||||
@@ -0,0 +1,10 @@
|
||||
==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts (3 errors) ====
|
||||
class C2 extends { foo: string; } { } // error
|
||||
~
|
||||
!!! Identifier expected.
|
||||
|
||||
class C6 extends []{ } // error
|
||||
~
|
||||
!!! Identifier expected.
|
||||
~
|
||||
!!! ';' expected.
|
||||
@@ -0,0 +1,25 @@
|
||||
//// [classImplementsImportedInterface.ts]
|
||||
module M1 {
|
||||
export interface I {
|
||||
foo();
|
||||
}
|
||||
}
|
||||
|
||||
module M2 {
|
||||
import T = M1.I;
|
||||
class C implements T {
|
||||
foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
//// [classImplementsImportedInterface.js]
|
||||
var M2;
|
||||
(function (M2) {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
})(M2 || (M2 = {}));
|
||||
@@ -0,0 +1,28 @@
|
||||
=== tests/cases/compiler/classImplementsImportedInterface.ts ===
|
||||
module M1 {
|
||||
>M1 : M1
|
||||
|
||||
export interface I {
|
||||
>I : I
|
||||
|
||||
foo();
|
||||
>foo : () => any
|
||||
}
|
||||
}
|
||||
|
||||
module M2 {
|
||||
>M2 : M2
|
||||
|
||||
import T = M1.I;
|
||||
>T : T
|
||||
>M1 : M1
|
||||
>I : T
|
||||
|
||||
class C implements T {
|
||||
>C : C
|
||||
>T : T
|
||||
|
||||
foo() {}
|
||||
>foo : () => void
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
==== tests/cases/conformance/types/namedTypes/classWithOnlyPublicMembersEquivalentToInterface.ts (2 errors) ====
|
||||
// no errors expected
|
||||
|
||||
class C {
|
||||
public x: string;
|
||||
public y(a: number): number { return null; }
|
||||
public get z() { return 1; }
|
||||
~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
public set z(v) { }
|
||||
~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
[x: string]: Object;
|
||||
[x: number]: Object;
|
||||
0: number;
|
||||
}
|
||||
|
||||
interface I {
|
||||
x: string;
|
||||
y(b: number): number;
|
||||
z: number;
|
||||
[x: string]: Object;
|
||||
[x: number]: Object;
|
||||
0: number;
|
||||
}
|
||||
|
||||
var c: C;
|
||||
var i: I;
|
||||
c = i;
|
||||
i = c;
|
||||
@@ -0,0 +1,50 @@
|
||||
//// [classWithOnlyPublicMembersEquivalentToInterface.ts]
|
||||
// no errors expected
|
||||
|
||||
class C {
|
||||
public x: string;
|
||||
public y(a: number): number { return null; }
|
||||
public get z() { return 1; }
|
||||
public set z(v) { }
|
||||
[x: string]: Object;
|
||||
[x: number]: Object;
|
||||
0: number;
|
||||
}
|
||||
|
||||
interface I {
|
||||
x: string;
|
||||
y(b: number): number;
|
||||
z: number;
|
||||
[x: string]: Object;
|
||||
[x: number]: Object;
|
||||
0: number;
|
||||
}
|
||||
|
||||
var c: C;
|
||||
var i: I;
|
||||
c = i;
|
||||
i = c;
|
||||
|
||||
//// [classWithOnlyPublicMembersEquivalentToInterface.js]
|
||||
// no errors expected
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.y = function (a) {
|
||||
return null;
|
||||
};
|
||||
Object.defineProperty(C.prototype, "z", {
|
||||
get: function () {
|
||||
return 1;
|
||||
},
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
var c;
|
||||
var i;
|
||||
c = i;
|
||||
i = c;
|
||||
@@ -0,0 +1,73 @@
|
||||
=== tests/cases/conformance/types/namedTypes/classWithOnlyPublicMembersEquivalentToInterface.ts ===
|
||||
// no errors expected
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
public x: string;
|
||||
>x : string
|
||||
|
||||
public y(a: number): number { return null; }
|
||||
>y : (a: number) => number
|
||||
>a : number
|
||||
|
||||
public get z() { return 1; }
|
||||
>z : number
|
||||
|
||||
public set z(v) { }
|
||||
>z : number
|
||||
>v : number
|
||||
|
||||
[x: string]: Object;
|
||||
>x : string
|
||||
>Object : Object
|
||||
|
||||
[x: number]: Object;
|
||||
>x : number
|
||||
>Object : Object
|
||||
|
||||
0: number;
|
||||
}
|
||||
|
||||
interface I {
|
||||
>I : I
|
||||
|
||||
x: string;
|
||||
>x : string
|
||||
|
||||
y(b: number): number;
|
||||
>y : (b: number) => number
|
||||
>b : number
|
||||
|
||||
z: number;
|
||||
>z : number
|
||||
|
||||
[x: string]: Object;
|
||||
>x : string
|
||||
>Object : Object
|
||||
|
||||
[x: number]: Object;
|
||||
>x : number
|
||||
>Object : Object
|
||||
|
||||
0: number;
|
||||
}
|
||||
|
||||
var c: C;
|
||||
>c : C
|
||||
>C : C
|
||||
|
||||
var i: I;
|
||||
>i : I
|
||||
>I : I
|
||||
|
||||
c = i;
|
||||
>c = i : I
|
||||
>c : C
|
||||
>i : I
|
||||
|
||||
i = c;
|
||||
>i = c : C
|
||||
>i : I
|
||||
>c : C
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
==== tests/cases/conformance/types/namedTypes/classWithOnlyPublicMembersEquivalentToInterface2.ts (2 errors) ====
|
||||
// no errors expected
|
||||
|
||||
class C {
|
||||
public x: string;
|
||||
public y(a: number): number { return null; }
|
||||
public get z() { return 1; }
|
||||
~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
public set z(v) { }
|
||||
~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
[x: string]: Object;
|
||||
[x: number]: Object;
|
||||
0: number;
|
||||
|
||||
public static foo: string; // doesn't effect equivalence
|
||||
}
|
||||
|
||||
interface I {
|
||||
x: string;
|
||||
y(b: number): number;
|
||||
z: number;
|
||||
[x: string]: Object;
|
||||
[x: number]: Object;
|
||||
0: number;
|
||||
}
|
||||
|
||||
var c: C;
|
||||
var i: I;
|
||||
c = i;
|
||||
i = c;
|
||||
@@ -0,0 +1,52 @@
|
||||
//// [classWithOnlyPublicMembersEquivalentToInterface2.ts]
|
||||
// no errors expected
|
||||
|
||||
class C {
|
||||
public x: string;
|
||||
public y(a: number): number { return null; }
|
||||
public get z() { return 1; }
|
||||
public set z(v) { }
|
||||
[x: string]: Object;
|
||||
[x: number]: Object;
|
||||
0: number;
|
||||
|
||||
public static foo: string; // doesn't effect equivalence
|
||||
}
|
||||
|
||||
interface I {
|
||||
x: string;
|
||||
y(b: number): number;
|
||||
z: number;
|
||||
[x: string]: Object;
|
||||
[x: number]: Object;
|
||||
0: number;
|
||||
}
|
||||
|
||||
var c: C;
|
||||
var i: I;
|
||||
c = i;
|
||||
i = c;
|
||||
|
||||
//// [classWithOnlyPublicMembersEquivalentToInterface2.js]
|
||||
// no errors expected
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.y = function (a) {
|
||||
return null;
|
||||
};
|
||||
Object.defineProperty(C.prototype, "z", {
|
||||
get: function () {
|
||||
return 1;
|
||||
},
|
||||
set: function (v) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
var c;
|
||||
var i;
|
||||
c = i;
|
||||
i = c;
|
||||
@@ -0,0 +1,76 @@
|
||||
=== tests/cases/conformance/types/namedTypes/classWithOnlyPublicMembersEquivalentToInterface2.ts ===
|
||||
// no errors expected
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
public x: string;
|
||||
>x : string
|
||||
|
||||
public y(a: number): number { return null; }
|
||||
>y : (a: number) => number
|
||||
>a : number
|
||||
|
||||
public get z() { return 1; }
|
||||
>z : number
|
||||
|
||||
public set z(v) { }
|
||||
>z : number
|
||||
>v : number
|
||||
|
||||
[x: string]: Object;
|
||||
>x : string
|
||||
>Object : Object
|
||||
|
||||
[x: number]: Object;
|
||||
>x : number
|
||||
>Object : Object
|
||||
|
||||
0: number;
|
||||
|
||||
public static foo: string; // doesn't effect equivalence
|
||||
>foo : string
|
||||
}
|
||||
|
||||
interface I {
|
||||
>I : I
|
||||
|
||||
x: string;
|
||||
>x : string
|
||||
|
||||
y(b: number): number;
|
||||
>y : (b: number) => number
|
||||
>b : number
|
||||
|
||||
z: number;
|
||||
>z : number
|
||||
|
||||
[x: string]: Object;
|
||||
>x : string
|
||||
>Object : Object
|
||||
|
||||
[x: number]: Object;
|
||||
>x : number
|
||||
>Object : Object
|
||||
|
||||
0: number;
|
||||
}
|
||||
|
||||
var c: C;
|
||||
>c : C
|
||||
>C : C
|
||||
|
||||
var i: I;
|
||||
>i : I
|
||||
>I : I
|
||||
|
||||
c = i;
|
||||
>c = i : I
|
||||
>c : C
|
||||
>i : I
|
||||
|
||||
i = c;
|
||||
>i = c : C
|
||||
>i : I
|
||||
>c : C
|
||||
|
||||
@@ -2,21 +2,21 @@
|
||||
|
||||
/** This is class c2 without constuctor*/
|
||||
class c2 {
|
||||
}
|
||||
} // trailing comment1
|
||||
var i2 = new c2();
|
||||
var i2_c = c2;
|
||||
class c3 {
|
||||
/** Constructor comment*/
|
||||
constructor() {
|
||||
}
|
||||
}
|
||||
} // trailing comment of constructor
|
||||
} /* trailing comment 2 */
|
||||
var i3 = new c3();
|
||||
var i3_c = c3;
|
||||
/** Class comment*/
|
||||
class c4 {
|
||||
/** Constructor comment*/
|
||||
constructor() {
|
||||
}
|
||||
} /* trailing comment of constructor 2*/
|
||||
}
|
||||
var i4 = new c4();
|
||||
var i4_c = c4;
|
||||
@@ -63,6 +63,14 @@ class c8 {
|
||||
}
|
||||
var i8 = new c8();
|
||||
var i8_c = c8;
|
||||
|
||||
class c9 {
|
||||
constructor() {
|
||||
/// This is some detached comment
|
||||
|
||||
// should emit this leading comment of } too
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [commentsClass.js]
|
||||
@@ -71,22 +79,22 @@ var c2 = (function () {
|
||||
function c2() {
|
||||
}
|
||||
return c2;
|
||||
})();
|
||||
})(); // trailing comment1
|
||||
var i2 = new c2();
|
||||
var i2_c = c2;
|
||||
var c3 = (function () {
|
||||
/** Constructor comment*/
|
||||
function c3() {
|
||||
}
|
||||
} // trailing comment of constructor
|
||||
return c3;
|
||||
})();
|
||||
})(); /* trailing comment 2 */
|
||||
var i3 = new c3();
|
||||
var i3_c = c3;
|
||||
/** Class comment*/
|
||||
var c4 = (function () {
|
||||
/** Constructor comment*/
|
||||
function c4() {
|
||||
}
|
||||
} /* trailing comment of constructor 2*/
|
||||
return c4;
|
||||
})();
|
||||
var i4 = new c4();
|
||||
@@ -130,6 +138,13 @@ var c8 = (function () {
|
||||
})();
|
||||
var i8 = new c8();
|
||||
var i8_c = c8;
|
||||
var c9 = (function () {
|
||||
function c9() {
|
||||
/// This is some detached comment
|
||||
// should emit this leading comment of } too
|
||||
}
|
||||
return c9;
|
||||
})();
|
||||
|
||||
|
||||
//// [commentsClass.d.ts]
|
||||
@@ -180,3 +195,6 @@ declare class c8 {
|
||||
}
|
||||
declare var i8: c8;
|
||||
declare var i8_c: typeof c8;
|
||||
declare class c9 {
|
||||
constructor();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
/** This is class c2 without constuctor*/
|
||||
class c2 {
|
||||
>c2 : c2
|
||||
}
|
||||
|
||||
} // trailing comment1
|
||||
var i2 = new c2();
|
||||
>i2 : c2
|
||||
>new c2() : c2
|
||||
@@ -18,8 +19,8 @@ class c3 {
|
||||
|
||||
/** Constructor comment*/
|
||||
constructor() {
|
||||
}
|
||||
}
|
||||
} // trailing comment of constructor
|
||||
} /* trailing comment 2 */
|
||||
var i3 = new c3();
|
||||
>i3 : c3
|
||||
>new c3() : c3
|
||||
@@ -35,7 +36,7 @@ class c4 {
|
||||
|
||||
/** Constructor comment*/
|
||||
constructor() {
|
||||
}
|
||||
} /* trailing comment of constructor 2*/
|
||||
}
|
||||
var i4 = new c4();
|
||||
>i4 : c4
|
||||
@@ -129,3 +130,13 @@ var i8_c = c8;
|
||||
>i8_c : typeof c8
|
||||
>c8 : typeof c8
|
||||
|
||||
class c9 {
|
||||
>c9 : c9
|
||||
|
||||
constructor() {
|
||||
/// This is some detached comment
|
||||
|
||||
// should emit this leading comment of } too
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,21 +7,21 @@ class c1 {
|
||||
/** sum with property*/
|
||||
public p2(/** number to add*/b: number) {
|
||||
return this.p1 + b;
|
||||
}
|
||||
} /* trailing comment of method*/
|
||||
/** getter property*/
|
||||
public get p3() {
|
||||
return this.p2(this.p1);
|
||||
}
|
||||
}// trailing comment Getter
|
||||
/** setter property*/
|
||||
public set p3(/** this is value*/value: number) {
|
||||
this.p1 = this.p2(value);
|
||||
}
|
||||
}// trailing comment Setter
|
||||
/** pp1 is property of c1*/
|
||||
private pp1: number;
|
||||
/** sum with property*/
|
||||
private pp2(/** number to add*/b: number) {
|
||||
return this.p1 + b;
|
||||
}
|
||||
} // trailing comment of method
|
||||
/** getter property*/
|
||||
private get pp3() {
|
||||
return this.pp2(this.pp1);
|
||||
@@ -42,11 +42,11 @@ class c1 {
|
||||
/** static getter property*/
|
||||
static get s3() {
|
||||
return c1.s2(c1.s1);
|
||||
}
|
||||
} /*trailing comment 1 getter*/
|
||||
/** setter property*/
|
||||
static set s3( /** this is value*/value: number) {
|
||||
c1.s1 = c1.s2(value);
|
||||
}
|
||||
}/*trailing comment 2 */ /*setter*/
|
||||
public nc_p1: number;
|
||||
public nc_p2(b: number) {
|
||||
return this.nc_p1 + b;
|
||||
@@ -198,7 +198,7 @@ class cProperties {
|
||||
/** getter only property*/
|
||||
public get p1() {
|
||||
return this.val;
|
||||
}
|
||||
} // trailing comment of only getter
|
||||
public get nc_p1() {
|
||||
return this.val;
|
||||
}
|
||||
@@ -208,7 +208,10 @@ class cProperties {
|
||||
}
|
||||
public set nc_p2(value: number) {
|
||||
this.val = value;
|
||||
}
|
||||
} /* trailing comment of setter only*/
|
||||
|
||||
public x = 10; /*trailing comment for property*/
|
||||
private y = 10; // trailing comment of // style
|
||||
}
|
||||
var cProperties_i = new cProperties();
|
||||
cProperties_i.p2 = cProperties_i.p1;
|
||||
@@ -224,23 +227,25 @@ var c1 = (function () {
|
||||
/** sum with property*/
|
||||
c1.prototype.p2 = function (/** number to add*/ b) {
|
||||
return this.p1 + b;
|
||||
};
|
||||
}; /* trailing comment of method*/
|
||||
Object.defineProperty(c1.prototype, "p3", {
|
||||
/** getter property*/
|
||||
get: function () {
|
||||
return this.p2(this.p1);
|
||||
},
|
||||
} // trailing comment Getter
|
||||
,
|
||||
/** setter property*/
|
||||
set: function (/** this is value*/ value) {
|
||||
this.p1 = this.p2(value);
|
||||
},
|
||||
} // trailing comment Setter
|
||||
,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
/** sum with property*/
|
||||
c1.prototype.pp2 = function (/** number to add*/ b) {
|
||||
return this.p1 + b;
|
||||
};
|
||||
}; // trailing comment of method
|
||||
Object.defineProperty(c1.prototype, "pp3", {
|
||||
/** getter property*/
|
||||
get: function () {
|
||||
@@ -261,11 +266,11 @@ var c1 = (function () {
|
||||
/** static getter property*/
|
||||
get: function () {
|
||||
return c1.s2(c1.s1);
|
||||
},
|
||||
} /*trailing comment 1 getter*/,
|
||||
/** setter property*/
|
||||
set: function (/** this is value*/ value) {
|
||||
c1.s1 = c1.s2(value);
|
||||
},
|
||||
} /*trailing comment 2 */ /*setter*/,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
@@ -433,12 +438,15 @@ c1.nc_s3 = i1_s_ncprop;
|
||||
var i1_c = c1;
|
||||
var cProperties = (function () {
|
||||
function cProperties() {
|
||||
this.x = 10; /*trailing comment for property*/
|
||||
this.y = 10; // trailing comment of // style
|
||||
}
|
||||
Object.defineProperty(cProperties.prototype, "p1", {
|
||||
/** getter only property*/
|
||||
get: function () {
|
||||
return this.val;
|
||||
},
|
||||
} // trailing comment of only getter
|
||||
,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
@@ -460,7 +468,7 @@ var cProperties = (function () {
|
||||
Object.defineProperty(cProperties.prototype, "nc_p2", {
|
||||
set: function (value) {
|
||||
this.val = value;
|
||||
},
|
||||
} /* trailing comment of setter only*/,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
@@ -565,5 +573,7 @@ declare class cProperties {
|
||||
/**setter only property*/
|
||||
p2: number;
|
||||
nc_p2: number;
|
||||
x: number;
|
||||
private y;
|
||||
}
|
||||
declare var cProperties_i: cProperties;
|
||||
|
||||
@@ -19,7 +19,8 @@ class c1 {
|
||||
>this : c1
|
||||
>p1 : number
|
||||
>b : number
|
||||
}
|
||||
|
||||
} /* trailing comment of method*/
|
||||
/** getter property*/
|
||||
public get p3() {
|
||||
>p3 : number
|
||||
@@ -32,7 +33,8 @@ class c1 {
|
||||
>this.p1 : number
|
||||
>this : c1
|
||||
>p1 : number
|
||||
}
|
||||
|
||||
}// trailing comment Getter
|
||||
/** setter property*/
|
||||
public set p3(/** this is value*/value: number) {
|
||||
>p3 : number
|
||||
@@ -48,7 +50,8 @@ class c1 {
|
||||
>this : c1
|
||||
>p2 : (b: number) => number
|
||||
>value : number
|
||||
}
|
||||
|
||||
}// trailing comment Setter
|
||||
/** pp1 is property of c1*/
|
||||
private pp1: number;
|
||||
>pp1 : number
|
||||
@@ -64,7 +67,8 @@ class c1 {
|
||||
>this : c1
|
||||
>p1 : number
|
||||
>b : number
|
||||
}
|
||||
|
||||
} // trailing comment of method
|
||||
/** getter property*/
|
||||
private get pp3() {
|
||||
>pp3 : number
|
||||
@@ -125,7 +129,8 @@ class c1 {
|
||||
>c1.s1 : number
|
||||
>c1 : typeof c1
|
||||
>s1 : number
|
||||
}
|
||||
|
||||
} /*trailing comment 1 getter*/
|
||||
/** setter property*/
|
||||
static set s3( /** this is value*/value: number) {
|
||||
>s3 : number
|
||||
@@ -141,7 +146,8 @@ class c1 {
|
||||
>c1 : typeof c1
|
||||
>s2 : (b: number) => number
|
||||
>value : number
|
||||
}
|
||||
|
||||
}/*trailing comment 2 */ /*setter*/
|
||||
public nc_p1: number;
|
||||
>nc_p1 : number
|
||||
|
||||
@@ -696,7 +702,8 @@ class cProperties {
|
||||
>this.val : number
|
||||
>this : cProperties
|
||||
>val : number
|
||||
}
|
||||
|
||||
} // trailing comment of only getter
|
||||
public get nc_p1() {
|
||||
>nc_p1 : number
|
||||
|
||||
@@ -727,7 +734,14 @@ class cProperties {
|
||||
>this : cProperties
|
||||
>val : number
|
||||
>value : number
|
||||
}
|
||||
|
||||
} /* trailing comment of setter only*/
|
||||
|
||||
public x = 10; /*trailing comment for property*/
|
||||
>x : number
|
||||
|
||||
private y = 10; // trailing comment of // style
|
||||
>y : number
|
||||
}
|
||||
var cProperties_i = new cProperties();
|
||||
>cProperties_i : cProperties
|
||||
|
||||
34
tests/baselines/reference/commentsDottedModuleName.js
Normal file
34
tests/baselines/reference/commentsDottedModuleName.js
Normal file
@@ -0,0 +1,34 @@
|
||||
//// [commentsDottedModuleName.ts]
|
||||
|
||||
/** this is multi declare module*/
|
||||
export module outerModule.InnerModule {
|
||||
/// class b comment
|
||||
export class b {
|
||||
}
|
||||
}
|
||||
|
||||
//// [commentsDottedModuleName.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
/** this is multi declare module*/
|
||||
(function (outerModule) {
|
||||
(function (InnerModule) {
|
||||
/// class b comment
|
||||
var b = (function () {
|
||||
function b() {
|
||||
}
|
||||
return b;
|
||||
})();
|
||||
InnerModule.b = b;
|
||||
})(outerModule.InnerModule || (outerModule.InnerModule = {}));
|
||||
var InnerModule = outerModule.InnerModule;
|
||||
})(exports.outerModule || (exports.outerModule = {}));
|
||||
var outerModule = exports.outerModule;
|
||||
});
|
||||
|
||||
|
||||
//// [commentsDottedModuleName.d.ts]
|
||||
/** this is multi declare module*/
|
||||
export declare module outerModule.InnerModule {
|
||||
class b {
|
||||
}
|
||||
}
|
||||
12
tests/baselines/reference/commentsDottedModuleName.types
Normal file
12
tests/baselines/reference/commentsDottedModuleName.types
Normal file
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/compiler/commentsDottedModuleName.ts ===
|
||||
|
||||
/** this is multi declare module*/
|
||||
export module outerModule.InnerModule {
|
||||
>outerModule : outerModule
|
||||
>InnerModule : InnerModule
|
||||
|
||||
/// class b comment
|
||||
export class b {
|
||||
>b : b
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ enum Colors {
|
||||
Cornflower /* blue */,
|
||||
/** Fancy name for 'pink'*/
|
||||
FancyPink
|
||||
}
|
||||
} // trailing comment
|
||||
var x = Colors.Cornflower;
|
||||
x = Colors.FancyPink;
|
||||
|
||||
@@ -20,7 +20,7 @@ var Colors;
|
||||
Colors[Colors["Cornflower"] = 0] = "Cornflower"; /* blue */
|
||||
/** Fancy name for 'pink'*/
|
||||
Colors[Colors["FancyPink"] = 1] = "FancyPink";
|
||||
})(Colors || (Colors = {}));
|
||||
})(Colors || (Colors = {})); // trailing comment
|
||||
var x = 0 /* Cornflower */;
|
||||
x = 1 /* FancyPink */;
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ enum Colors {
|
||||
/** Fancy name for 'pink'*/
|
||||
FancyPink
|
||||
>FancyPink : Colors
|
||||
}
|
||||
|
||||
} // trailing comment
|
||||
var x = Colors.Cornflower;
|
||||
>x : Colors
|
||||
>Colors.Cornflower : Colors
|
||||
|
||||
@@ -54,7 +54,7 @@ var myvar2 = new m4.m2.c();
|
||||
|
||||
//// [commentsExternalModules_1.ts]
|
||||
/**This is on import declaration*/
|
||||
import extMod = require("commentsExternalModules_0");
|
||||
import extMod = require("commentsExternalModules_0"); // trailing comment1
|
||||
extMod.m1.fooExport();
|
||||
var newVar = new extMod.m1.m2.c();
|
||||
extMod.m4.fooExport();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
=== tests/cases/compiler/commentsExternalModules_1.ts ===
|
||||
/**This is on import declaration*/
|
||||
import extMod = require("commentsExternalModules_0");
|
||||
import extMod = require("commentsExternalModules_0"); // trailing comment1
|
||||
>extMod : extMod
|
||||
|
||||
extMod.m1.fooExport();
|
||||
|
||||
176
tests/baselines/reference/commentsExternalModules2.js
Normal file
176
tests/baselines/reference/commentsExternalModules2.js
Normal file
@@ -0,0 +1,176 @@
|
||||
//// [tests/cases/compiler/commentsExternalModules2.ts] ////
|
||||
|
||||
//// [commentsExternalModules2_0.ts]
|
||||
|
||||
/** Module comment*/
|
||||
export module m1 {
|
||||
/** b's comment*/
|
||||
export var b: number;
|
||||
/** foo's comment*/
|
||||
function foo() {
|
||||
return b;
|
||||
}
|
||||
/** m2 comments*/
|
||||
export module m2 {
|
||||
/** class comment;*/
|
||||
export class c {
|
||||
};
|
||||
/** i*/
|
||||
export var i = new c();
|
||||
}
|
||||
/** exported function*/
|
||||
export function fooExport() {
|
||||
return foo();
|
||||
}
|
||||
}
|
||||
m1.fooExport();
|
||||
var myvar = new m1.m2.c();
|
||||
|
||||
/** Module comment */
|
||||
export module m4 {
|
||||
/** b's comment */
|
||||
export var b: number;
|
||||
/** foo's comment
|
||||
*/
|
||||
function foo() {
|
||||
return b;
|
||||
}
|
||||
/** m2 comments
|
||||
*/
|
||||
export module m2 {
|
||||
/** class comment; */
|
||||
export class c {
|
||||
};
|
||||
/** i */
|
||||
export var i = new c();
|
||||
}
|
||||
/** exported function */
|
||||
export function fooExport() {
|
||||
return foo();
|
||||
}
|
||||
}
|
||||
m4.fooExport();
|
||||
var myvar2 = new m4.m2.c();
|
||||
|
||||
//// [commentsExternalModules_1.ts]
|
||||
/**This is on import declaration*/
|
||||
import extMod = require("commentsExternalModules2_0"); // trailing comment 1
|
||||
extMod.m1.fooExport();
|
||||
export var newVar = new extMod.m1.m2.c();
|
||||
extMod.m4.fooExport();
|
||||
export var newVar2 = new extMod.m4.m2.c();
|
||||
|
||||
|
||||
//// [commentsExternalModules2_0.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
/** Module comment*/
|
||||
(function (m1) {
|
||||
/** b's comment*/
|
||||
m1.b;
|
||||
/** foo's comment*/
|
||||
function foo() {
|
||||
return m1.b;
|
||||
}
|
||||
/** m2 comments*/
|
||||
(function (m2) {
|
||||
/** class comment;*/
|
||||
var c = (function () {
|
||||
function c() {
|
||||
}
|
||||
return c;
|
||||
})();
|
||||
m2.c = c;
|
||||
;
|
||||
/** i*/
|
||||
m2.i = new c();
|
||||
})(m1.m2 || (m1.m2 = {}));
|
||||
var m2 = m1.m2;
|
||||
/** exported function*/
|
||||
function fooExport() {
|
||||
return foo();
|
||||
}
|
||||
m1.fooExport = fooExport;
|
||||
})(exports.m1 || (exports.m1 = {}));
|
||||
var m1 = exports.m1;
|
||||
m1.fooExport();
|
||||
var myvar = new m1.m2.c();
|
||||
/** Module comment */
|
||||
(function (m4) {
|
||||
/** b's comment */
|
||||
m4.b;
|
||||
/** foo's comment
|
||||
*/
|
||||
function foo() {
|
||||
return m4.b;
|
||||
}
|
||||
/** m2 comments
|
||||
*/
|
||||
(function (m2) {
|
||||
/** class comment; */
|
||||
var c = (function () {
|
||||
function c() {
|
||||
}
|
||||
return c;
|
||||
})();
|
||||
m2.c = c;
|
||||
;
|
||||
/** i */
|
||||
m2.i = new c();
|
||||
})(m4.m2 || (m4.m2 = {}));
|
||||
var m2 = m4.m2;
|
||||
/** exported function */
|
||||
function fooExport() {
|
||||
return foo();
|
||||
}
|
||||
m4.fooExport = fooExport;
|
||||
})(exports.m4 || (exports.m4 = {}));
|
||||
var m4 = exports.m4;
|
||||
m4.fooExport();
|
||||
var myvar2 = new m4.m2.c();
|
||||
});
|
||||
//// [commentsExternalModules_1.js]
|
||||
define(["require", "exports", "commentsExternalModules2_0"], function (require, exports, extMod) {
|
||||
extMod.m1.fooExport();
|
||||
exports.newVar = new extMod.m1.m2.c();
|
||||
extMod.m4.fooExport();
|
||||
exports.newVar2 = new extMod.m4.m2.c();
|
||||
});
|
||||
|
||||
|
||||
//// [commentsExternalModules2_0.d.ts]
|
||||
/** Module comment*/
|
||||
export declare module m1 {
|
||||
/** b's comment*/
|
||||
var b: number;
|
||||
/** m2 comments*/
|
||||
module m2 {
|
||||
/** class comment;*/
|
||||
class c {
|
||||
}
|
||||
/** i*/
|
||||
var i: c;
|
||||
}
|
||||
/** exported function*/
|
||||
function fooExport(): number;
|
||||
}
|
||||
/** Module comment */
|
||||
export declare module m4 {
|
||||
/** b's comment */
|
||||
var b: number;
|
||||
/** m2 comments
|
||||
*/
|
||||
module m2 {
|
||||
/** class comment; */
|
||||
class c {
|
||||
}
|
||||
/** i */
|
||||
var i: c;
|
||||
}
|
||||
/** exported function */
|
||||
function fooExport(): number;
|
||||
}
|
||||
//// [commentsExternalModules_1.d.ts]
|
||||
/**This is on import declaration*/
|
||||
import extMod = require("commentsExternalModules2_0");
|
||||
export declare var newVar: extMod.m1.m2.c;
|
||||
export declare var newVar2: extMod.m4.m2.c;
|
||||
155
tests/baselines/reference/commentsExternalModules2.types
Normal file
155
tests/baselines/reference/commentsExternalModules2.types
Normal file
@@ -0,0 +1,155 @@
|
||||
=== tests/cases/compiler/commentsExternalModules_1.ts ===
|
||||
/**This is on import declaration*/
|
||||
import extMod = require("commentsExternalModules2_0"); // trailing comment 1
|
||||
>extMod : extMod
|
||||
|
||||
extMod.m1.fooExport();
|
||||
>extMod.m1.fooExport() : number
|
||||
>extMod.m1.fooExport : typeof extMod.m1.fooExport
|
||||
>extMod.m1 : typeof extMod.m1
|
||||
>extMod : typeof extMod
|
||||
>m1 : typeof extMod.m1
|
||||
>fooExport : typeof extMod.m1.fooExport
|
||||
|
||||
export var newVar = new extMod.m1.m2.c();
|
||||
>newVar : extMod.m1.m2.c
|
||||
>new extMod.m1.m2.c() : extMod.m1.m2.c
|
||||
>extMod.m1.m2.c : typeof extMod.m1.m2.c
|
||||
>extMod.m1.m2 : typeof extMod.m1.m2
|
||||
>extMod.m1 : typeof extMod.m1
|
||||
>extMod : typeof extMod
|
||||
>m1 : typeof extMod.m1
|
||||
>m2 : typeof extMod.m1.m2
|
||||
>c : typeof extMod.m1.m2.c
|
||||
|
||||
extMod.m4.fooExport();
|
||||
>extMod.m4.fooExport() : number
|
||||
>extMod.m4.fooExport : typeof extMod.m4.fooExport
|
||||
>extMod.m4 : typeof extMod.m4
|
||||
>extMod : typeof extMod
|
||||
>m4 : typeof extMod.m4
|
||||
>fooExport : typeof extMod.m4.fooExport
|
||||
|
||||
export var newVar2 = new extMod.m4.m2.c();
|
||||
>newVar2 : extMod.m4.m2.c
|
||||
>new extMod.m4.m2.c() : extMod.m4.m2.c
|
||||
>extMod.m4.m2.c : typeof extMod.m4.m2.c
|
||||
>extMod.m4.m2 : typeof extMod.m4.m2
|
||||
>extMod.m4 : typeof extMod.m4
|
||||
>extMod : typeof extMod
|
||||
>m4 : typeof extMod.m4
|
||||
>m2 : typeof extMod.m4.m2
|
||||
>c : typeof extMod.m4.m2.c
|
||||
|
||||
=== tests/cases/compiler/commentsExternalModules2_0.ts ===
|
||||
|
||||
/** Module comment*/
|
||||
export module m1 {
|
||||
>m1 : m1
|
||||
|
||||
/** b's comment*/
|
||||
export var b: number;
|
||||
>b : number
|
||||
|
||||
/** foo's comment*/
|
||||
function foo() {
|
||||
>foo : typeof foo
|
||||
|
||||
return b;
|
||||
>b : number
|
||||
}
|
||||
/** m2 comments*/
|
||||
export module m2 {
|
||||
>m2 : m2
|
||||
|
||||
/** class comment;*/
|
||||
export class c {
|
||||
>c : c
|
||||
|
||||
};
|
||||
/** i*/
|
||||
export var i = new c();
|
||||
>i : c
|
||||
>new c() : c
|
||||
>c : typeof c
|
||||
}
|
||||
/** exported function*/
|
||||
export function fooExport() {
|
||||
>fooExport : typeof fooExport
|
||||
|
||||
return foo();
|
||||
>foo() : number
|
||||
>foo : typeof foo
|
||||
}
|
||||
}
|
||||
m1.fooExport();
|
||||
>m1.fooExport() : number
|
||||
>m1.fooExport : typeof m1.fooExport
|
||||
>m1 : typeof m1
|
||||
>fooExport : typeof m1.fooExport
|
||||
|
||||
var myvar = new m1.m2.c();
|
||||
>myvar : m1.m2.c
|
||||
>new m1.m2.c() : m1.m2.c
|
||||
>m1.m2.c : typeof m1.m2.c
|
||||
>m1.m2 : typeof m1.m2
|
||||
>m1 : typeof m1
|
||||
>m2 : typeof m1.m2
|
||||
>c : typeof m1.m2.c
|
||||
|
||||
/** Module comment */
|
||||
export module m4 {
|
||||
>m4 : m4
|
||||
|
||||
/** b's comment */
|
||||
export var b: number;
|
||||
>b : number
|
||||
|
||||
/** foo's comment
|
||||
*/
|
||||
function foo() {
|
||||
>foo : typeof foo
|
||||
|
||||
return b;
|
||||
>b : number
|
||||
}
|
||||
/** m2 comments
|
||||
*/
|
||||
export module m2 {
|
||||
>m2 : m2
|
||||
|
||||
/** class comment; */
|
||||
export class c {
|
||||
>c : c
|
||||
|
||||
};
|
||||
/** i */
|
||||
export var i = new c();
|
||||
>i : c
|
||||
>new c() : c
|
||||
>c : typeof c
|
||||
}
|
||||
/** exported function */
|
||||
export function fooExport() {
|
||||
>fooExport : typeof fooExport
|
||||
|
||||
return foo();
|
||||
>foo() : number
|
||||
>foo : typeof foo
|
||||
}
|
||||
}
|
||||
m4.fooExport();
|
||||
>m4.fooExport() : number
|
||||
>m4.fooExport : typeof m4.fooExport
|
||||
>m4 : typeof m4
|
||||
>fooExport : typeof m4.fooExport
|
||||
|
||||
var myvar2 = new m4.m2.c();
|
||||
>myvar2 : m4.m2.c
|
||||
>new m4.m2.c() : m4.m2.c
|
||||
>m4.m2.c : typeof m4.m2.c
|
||||
>m4.m2 : typeof m4.m2
|
||||
>m4 : typeof m4
|
||||
>m2 : typeof m4.m2
|
||||
>c : typeof m4.m2.c
|
||||
|
||||
174
tests/baselines/reference/commentsExternalModules3.js
Normal file
174
tests/baselines/reference/commentsExternalModules3.js
Normal file
@@ -0,0 +1,174 @@
|
||||
//// [tests/cases/compiler/commentsExternalModules3.ts] ////
|
||||
|
||||
//// [commentsExternalModules2_0.ts]
|
||||
|
||||
/** Module comment*/
|
||||
export module m1 {
|
||||
/** b's comment*/
|
||||
export var b: number;
|
||||
/** foo's comment*/
|
||||
function foo() {
|
||||
return b;
|
||||
}
|
||||
/** m2 comments*/
|
||||
export module m2 {
|
||||
/** class comment;*/
|
||||
export class c {
|
||||
};
|
||||
/** i*/
|
||||
export var i = new c();
|
||||
}
|
||||
/** exported function*/
|
||||
export function fooExport() {
|
||||
return foo();
|
||||
}
|
||||
}
|
||||
m1.fooExport();
|
||||
var myvar = new m1.m2.c();
|
||||
|
||||
/** Module comment */
|
||||
export module m4 {
|
||||
/** b's comment */
|
||||
export var b: number;
|
||||
/** foo's comment
|
||||
*/
|
||||
function foo() {
|
||||
return b;
|
||||
}
|
||||
/** m2 comments
|
||||
*/
|
||||
export module m2 {
|
||||
/** class comment; */
|
||||
export class c {
|
||||
};
|
||||
/** i */
|
||||
export var i = new c();
|
||||
}
|
||||
/** exported function */
|
||||
export function fooExport() {
|
||||
return foo();
|
||||
}
|
||||
}
|
||||
m4.fooExport();
|
||||
var myvar2 = new m4.m2.c();
|
||||
|
||||
//// [commentsExternalModules_1.ts]
|
||||
/**This is on import declaration*/
|
||||
import extMod = require("commentsExternalModules2_0"); // trailing comment 1
|
||||
extMod.m1.fooExport();
|
||||
export var newVar = new extMod.m1.m2.c();
|
||||
extMod.m4.fooExport();
|
||||
export var newVar2 = new extMod.m4.m2.c();
|
||||
|
||||
|
||||
//// [commentsExternalModules2_0.js]
|
||||
/** Module comment*/
|
||||
(function (m1) {
|
||||
/** b's comment*/
|
||||
m1.b;
|
||||
/** foo's comment*/
|
||||
function foo() {
|
||||
return m1.b;
|
||||
}
|
||||
/** m2 comments*/
|
||||
(function (m2) {
|
||||
/** class comment;*/
|
||||
var c = (function () {
|
||||
function c() {
|
||||
}
|
||||
return c;
|
||||
})();
|
||||
m2.c = c;
|
||||
;
|
||||
/** i*/
|
||||
m2.i = new c();
|
||||
})(m1.m2 || (m1.m2 = {}));
|
||||
var m2 = m1.m2;
|
||||
/** exported function*/
|
||||
function fooExport() {
|
||||
return foo();
|
||||
}
|
||||
m1.fooExport = fooExport;
|
||||
})(exports.m1 || (exports.m1 = {}));
|
||||
var m1 = exports.m1;
|
||||
m1.fooExport();
|
||||
var myvar = new m1.m2.c();
|
||||
/** Module comment */
|
||||
(function (m4) {
|
||||
/** b's comment */
|
||||
m4.b;
|
||||
/** foo's comment
|
||||
*/
|
||||
function foo() {
|
||||
return m4.b;
|
||||
}
|
||||
/** m2 comments
|
||||
*/
|
||||
(function (m2) {
|
||||
/** class comment; */
|
||||
var c = (function () {
|
||||
function c() {
|
||||
}
|
||||
return c;
|
||||
})();
|
||||
m2.c = c;
|
||||
;
|
||||
/** i */
|
||||
m2.i = new c();
|
||||
})(m4.m2 || (m4.m2 = {}));
|
||||
var m2 = m4.m2;
|
||||
/** exported function */
|
||||
function fooExport() {
|
||||
return foo();
|
||||
}
|
||||
m4.fooExport = fooExport;
|
||||
})(exports.m4 || (exports.m4 = {}));
|
||||
var m4 = exports.m4;
|
||||
m4.fooExport();
|
||||
var myvar2 = new m4.m2.c();
|
||||
//// [commentsExternalModules_1.js]
|
||||
/**This is on import declaration*/
|
||||
var extMod = require("commentsExternalModules2_0"); // trailing comment 1
|
||||
extMod.m1.fooExport();
|
||||
exports.newVar = new extMod.m1.m2.c();
|
||||
extMod.m4.fooExport();
|
||||
exports.newVar2 = new extMod.m4.m2.c();
|
||||
|
||||
|
||||
//// [commentsExternalModules2_0.d.ts]
|
||||
/** Module comment*/
|
||||
export declare module m1 {
|
||||
/** b's comment*/
|
||||
var b: number;
|
||||
/** m2 comments*/
|
||||
module m2 {
|
||||
/** class comment;*/
|
||||
class c {
|
||||
}
|
||||
/** i*/
|
||||
var i: c;
|
||||
}
|
||||
/** exported function*/
|
||||
function fooExport(): number;
|
||||
}
|
||||
/** Module comment */
|
||||
export declare module m4 {
|
||||
/** b's comment */
|
||||
var b: number;
|
||||
/** m2 comments
|
||||
*/
|
||||
module m2 {
|
||||
/** class comment; */
|
||||
class c {
|
||||
}
|
||||
/** i */
|
||||
var i: c;
|
||||
}
|
||||
/** exported function */
|
||||
function fooExport(): number;
|
||||
}
|
||||
//// [commentsExternalModules_1.d.ts]
|
||||
/**This is on import declaration*/
|
||||
import extMod = require("commentsExternalModules2_0");
|
||||
export declare var newVar: extMod.m1.m2.c;
|
||||
export declare var newVar2: extMod.m4.m2.c;
|
||||
155
tests/baselines/reference/commentsExternalModules3.types
Normal file
155
tests/baselines/reference/commentsExternalModules3.types
Normal file
@@ -0,0 +1,155 @@
|
||||
=== tests/cases/compiler/commentsExternalModules_1.ts ===
|
||||
/**This is on import declaration*/
|
||||
import extMod = require("commentsExternalModules2_0"); // trailing comment 1
|
||||
>extMod : extMod
|
||||
|
||||
extMod.m1.fooExport();
|
||||
>extMod.m1.fooExport() : number
|
||||
>extMod.m1.fooExport : typeof extMod.m1.fooExport
|
||||
>extMod.m1 : typeof extMod.m1
|
||||
>extMod : typeof extMod
|
||||
>m1 : typeof extMod.m1
|
||||
>fooExport : typeof extMod.m1.fooExport
|
||||
|
||||
export var newVar = new extMod.m1.m2.c();
|
||||
>newVar : extMod.m1.m2.c
|
||||
>new extMod.m1.m2.c() : extMod.m1.m2.c
|
||||
>extMod.m1.m2.c : typeof extMod.m1.m2.c
|
||||
>extMod.m1.m2 : typeof extMod.m1.m2
|
||||
>extMod.m1 : typeof extMod.m1
|
||||
>extMod : typeof extMod
|
||||
>m1 : typeof extMod.m1
|
||||
>m2 : typeof extMod.m1.m2
|
||||
>c : typeof extMod.m1.m2.c
|
||||
|
||||
extMod.m4.fooExport();
|
||||
>extMod.m4.fooExport() : number
|
||||
>extMod.m4.fooExport : typeof extMod.m4.fooExport
|
||||
>extMod.m4 : typeof extMod.m4
|
||||
>extMod : typeof extMod
|
||||
>m4 : typeof extMod.m4
|
||||
>fooExport : typeof extMod.m4.fooExport
|
||||
|
||||
export var newVar2 = new extMod.m4.m2.c();
|
||||
>newVar2 : extMod.m4.m2.c
|
||||
>new extMod.m4.m2.c() : extMod.m4.m2.c
|
||||
>extMod.m4.m2.c : typeof extMod.m4.m2.c
|
||||
>extMod.m4.m2 : typeof extMod.m4.m2
|
||||
>extMod.m4 : typeof extMod.m4
|
||||
>extMod : typeof extMod
|
||||
>m4 : typeof extMod.m4
|
||||
>m2 : typeof extMod.m4.m2
|
||||
>c : typeof extMod.m4.m2.c
|
||||
|
||||
=== tests/cases/compiler/commentsExternalModules2_0.ts ===
|
||||
|
||||
/** Module comment*/
|
||||
export module m1 {
|
||||
>m1 : m1
|
||||
|
||||
/** b's comment*/
|
||||
export var b: number;
|
||||
>b : number
|
||||
|
||||
/** foo's comment*/
|
||||
function foo() {
|
||||
>foo : typeof foo
|
||||
|
||||
return b;
|
||||
>b : number
|
||||
}
|
||||
/** m2 comments*/
|
||||
export module m2 {
|
||||
>m2 : m2
|
||||
|
||||
/** class comment;*/
|
||||
export class c {
|
||||
>c : c
|
||||
|
||||
};
|
||||
/** i*/
|
||||
export var i = new c();
|
||||
>i : c
|
||||
>new c() : c
|
||||
>c : typeof c
|
||||
}
|
||||
/** exported function*/
|
||||
export function fooExport() {
|
||||
>fooExport : typeof fooExport
|
||||
|
||||
return foo();
|
||||
>foo() : number
|
||||
>foo : typeof foo
|
||||
}
|
||||
}
|
||||
m1.fooExport();
|
||||
>m1.fooExport() : number
|
||||
>m1.fooExport : typeof m1.fooExport
|
||||
>m1 : typeof m1
|
||||
>fooExport : typeof m1.fooExport
|
||||
|
||||
var myvar = new m1.m2.c();
|
||||
>myvar : m1.m2.c
|
||||
>new m1.m2.c() : m1.m2.c
|
||||
>m1.m2.c : typeof m1.m2.c
|
||||
>m1.m2 : typeof m1.m2
|
||||
>m1 : typeof m1
|
||||
>m2 : typeof m1.m2
|
||||
>c : typeof m1.m2.c
|
||||
|
||||
/** Module comment */
|
||||
export module m4 {
|
||||
>m4 : m4
|
||||
|
||||
/** b's comment */
|
||||
export var b: number;
|
||||
>b : number
|
||||
|
||||
/** foo's comment
|
||||
*/
|
||||
function foo() {
|
||||
>foo : typeof foo
|
||||
|
||||
return b;
|
||||
>b : number
|
||||
}
|
||||
/** m2 comments
|
||||
*/
|
||||
export module m2 {
|
||||
>m2 : m2
|
||||
|
||||
/** class comment; */
|
||||
export class c {
|
||||
>c : c
|
||||
|
||||
};
|
||||
/** i */
|
||||
export var i = new c();
|
||||
>i : c
|
||||
>new c() : c
|
||||
>c : typeof c
|
||||
}
|
||||
/** exported function */
|
||||
export function fooExport() {
|
||||
>fooExport : typeof fooExport
|
||||
|
||||
return foo();
|
||||
>foo() : number
|
||||
>foo : typeof foo
|
||||
}
|
||||
}
|
||||
m4.fooExport();
|
||||
>m4.fooExport() : number
|
||||
>m4.fooExport : typeof m4.fooExport
|
||||
>m4 : typeof m4
|
||||
>fooExport : typeof m4.fooExport
|
||||
|
||||
var myvar2 = new m4.m2.c();
|
||||
>myvar2 : m4.m2.c
|
||||
>new m4.m2.c() : m4.m2.c
|
||||
>m4.m2.c : typeof m4.m2.c
|
||||
>m4.m2 : typeof m4.m2
|
||||
>m4 : typeof m4
|
||||
>m2 : typeof m4.m2
|
||||
>c : typeof m4.m2.c
|
||||
|
||||
220
tests/baselines/reference/commentsFormatting.js
Normal file
220
tests/baselines/reference/commentsFormatting.js
Normal file
@@ -0,0 +1,220 @@
|
||||
//// [commentsFormatting.ts]
|
||||
|
||||
module m {
|
||||
/** this is first line - aligned to class declaration
|
||||
* this is 4 spaces left aligned
|
||||
* this is 3 spaces left aligned
|
||||
* this is 2 spaces left aligned
|
||||
* this is 1 spaces left aligned
|
||||
* this is at same level as first line
|
||||
* this is 1 spaces right aligned
|
||||
* this is 2 spaces right aligned
|
||||
* this is 3 spaces right aligned
|
||||
* this is 4 spaces right aligned
|
||||
* this is 5 spaces right aligned
|
||||
* this is 6 spaces right aligned
|
||||
* this is 7 spaces right aligned
|
||||
* this is 8 spaces right aligned */
|
||||
export class c {
|
||||
}
|
||||
|
||||
/** this is first line - 4 spaces right aligned to class but in js file should be aligned to class declaration
|
||||
* this is 8 spaces left aligned
|
||||
* this is 7 spaces left aligned
|
||||
* this is 6 spaces left aligned
|
||||
* this is 5 spaces left aligned
|
||||
* this is 4 spaces left aligned
|
||||
* this is 3 spaces left aligned
|
||||
* this is 2 spaces left aligned
|
||||
* this is 1 spaces left aligned
|
||||
* this is at same level as first line
|
||||
* this is 1 spaces right aligned
|
||||
* this is 2 spaces right aligned
|
||||
* this is 3 spaces right aligned
|
||||
* this is 4 spaces right aligned
|
||||
* this is 5 spaces right aligned
|
||||
* this is 6 spaces right aligned
|
||||
* this is 7 spaces right aligned
|
||||
* this is 8 spaces right aligned */
|
||||
export class c2 {
|
||||
}
|
||||
|
||||
/** this is comment with new lines in between
|
||||
|
||||
this is 4 spaces left aligned but above line is empty
|
||||
|
||||
this is 3 spaces left aligned but above line is empty
|
||||
|
||||
this is 2 spaces left aligned but above line is empty
|
||||
|
||||
this is 1 spaces left aligned but above line is empty
|
||||
|
||||
this is at same level as first line but above line is empty
|
||||
|
||||
this is 1 spaces right aligned but above line is empty
|
||||
|
||||
this is 2 spaces right aligned but above line is empty
|
||||
|
||||
this is 3 spaces right aligned but above line is empty
|
||||
|
||||
this is 4 spaces right aligned but above line is empty
|
||||
|
||||
|
||||
Above 2 lines are empty
|
||||
|
||||
|
||||
|
||||
above 3 lines are empty*/
|
||||
export class c3 {
|
||||
}
|
||||
}
|
||||
|
||||
//// [commentsFormatting.js]
|
||||
var m;
|
||||
(function (m) {
|
||||
/** this is first line - aligned to class declaration
|
||||
* this is 4 spaces left aligned
|
||||
* this is 3 spaces left aligned
|
||||
* this is 2 spaces left aligned
|
||||
* this is 1 spaces left aligned
|
||||
* this is at same level as first line
|
||||
* this is 1 spaces right aligned
|
||||
* this is 2 spaces right aligned
|
||||
* this is 3 spaces right aligned
|
||||
* this is 4 spaces right aligned
|
||||
* this is 5 spaces right aligned
|
||||
* this is 6 spaces right aligned
|
||||
* this is 7 spaces right aligned
|
||||
* this is 8 spaces right aligned */
|
||||
var c = (function () {
|
||||
function c() {
|
||||
}
|
||||
return c;
|
||||
})();
|
||||
m.c = c;
|
||||
/** this is first line - 4 spaces right aligned to class but in js file should be aligned to class declaration
|
||||
* this is 8 spaces left aligned
|
||||
* this is 7 spaces left aligned
|
||||
* this is 6 spaces left aligned
|
||||
* this is 5 spaces left aligned
|
||||
* this is 4 spaces left aligned
|
||||
* this is 3 spaces left aligned
|
||||
* this is 2 spaces left aligned
|
||||
* this is 1 spaces left aligned
|
||||
* this is at same level as first line
|
||||
* this is 1 spaces right aligned
|
||||
* this is 2 spaces right aligned
|
||||
* this is 3 spaces right aligned
|
||||
* this is 4 spaces right aligned
|
||||
* this is 5 spaces right aligned
|
||||
* this is 6 spaces right aligned
|
||||
* this is 7 spaces right aligned
|
||||
* this is 8 spaces right aligned */
|
||||
var c2 = (function () {
|
||||
function c2() {
|
||||
}
|
||||
return c2;
|
||||
})();
|
||||
m.c2 = c2;
|
||||
/** this is comment with new lines in between
|
||||
|
||||
this is 4 spaces left aligned but above line is empty
|
||||
|
||||
this is 3 spaces left aligned but above line is empty
|
||||
|
||||
this is 2 spaces left aligned but above line is empty
|
||||
|
||||
this is 1 spaces left aligned but above line is empty
|
||||
|
||||
this is at same level as first line but above line is empty
|
||||
|
||||
this is 1 spaces right aligned but above line is empty
|
||||
|
||||
this is 2 spaces right aligned but above line is empty
|
||||
|
||||
this is 3 spaces right aligned but above line is empty
|
||||
|
||||
this is 4 spaces right aligned but above line is empty
|
||||
|
||||
|
||||
Above 2 lines are empty
|
||||
|
||||
|
||||
|
||||
above 3 lines are empty*/
|
||||
var c3 = (function () {
|
||||
function c3() {
|
||||
}
|
||||
return c3;
|
||||
})();
|
||||
m.c3 = c3;
|
||||
})(m || (m = {}));
|
||||
|
||||
|
||||
//// [commentsFormatting.d.ts]
|
||||
declare module m {
|
||||
/** this is first line - aligned to class declaration
|
||||
* this is 4 spaces left aligned
|
||||
* this is 3 spaces left aligned
|
||||
* this is 2 spaces left aligned
|
||||
* this is 1 spaces left aligned
|
||||
* this is at same level as first line
|
||||
* this is 1 spaces right aligned
|
||||
* this is 2 spaces right aligned
|
||||
* this is 3 spaces right aligned
|
||||
* this is 4 spaces right aligned
|
||||
* this is 5 spaces right aligned
|
||||
* this is 6 spaces right aligned
|
||||
* this is 7 spaces right aligned
|
||||
* this is 8 spaces right aligned */
|
||||
class c {
|
||||
}
|
||||
/** this is first line - 4 spaces right aligned to class but in js file should be aligned to class declaration
|
||||
* this is 8 spaces left aligned
|
||||
* this is 7 spaces left aligned
|
||||
* this is 6 spaces left aligned
|
||||
* this is 5 spaces left aligned
|
||||
* this is 4 spaces left aligned
|
||||
* this is 3 spaces left aligned
|
||||
* this is 2 spaces left aligned
|
||||
* this is 1 spaces left aligned
|
||||
* this is at same level as first line
|
||||
* this is 1 spaces right aligned
|
||||
* this is 2 spaces right aligned
|
||||
* this is 3 spaces right aligned
|
||||
* this is 4 spaces right aligned
|
||||
* this is 5 spaces right aligned
|
||||
* this is 6 spaces right aligned
|
||||
* this is 7 spaces right aligned
|
||||
* this is 8 spaces right aligned */
|
||||
class c2 {
|
||||
}
|
||||
/** this is comment with new lines in between
|
||||
|
||||
this is 4 spaces left aligned but above line is empty
|
||||
|
||||
this is 3 spaces left aligned but above line is empty
|
||||
|
||||
this is 2 spaces left aligned but above line is empty
|
||||
|
||||
this is 1 spaces left aligned but above line is empty
|
||||
|
||||
this is at same level as first line but above line is empty
|
||||
|
||||
this is 1 spaces right aligned but above line is empty
|
||||
|
||||
this is 2 spaces right aligned but above line is empty
|
||||
|
||||
this is 3 spaces right aligned but above line is empty
|
||||
|
||||
this is 4 spaces right aligned but above line is empty
|
||||
|
||||
|
||||
Above 2 lines are empty
|
||||
|
||||
|
||||
|
||||
above 3 lines are empty*/
|
||||
class c3 {
|
||||
}
|
||||
}
|
||||
75
tests/baselines/reference/commentsFormatting.types
Normal file
75
tests/baselines/reference/commentsFormatting.types
Normal file
@@ -0,0 +1,75 @@
|
||||
=== tests/cases/compiler/commentsFormatting.ts ===
|
||||
|
||||
module m {
|
||||
>m : m
|
||||
|
||||
/** this is first line - aligned to class declaration
|
||||
* this is 4 spaces left aligned
|
||||
* this is 3 spaces left aligned
|
||||
* this is 2 spaces left aligned
|
||||
* this is 1 spaces left aligned
|
||||
* this is at same level as first line
|
||||
* this is 1 spaces right aligned
|
||||
* this is 2 spaces right aligned
|
||||
* this is 3 spaces right aligned
|
||||
* this is 4 spaces right aligned
|
||||
* this is 5 spaces right aligned
|
||||
* this is 6 spaces right aligned
|
||||
* this is 7 spaces right aligned
|
||||
* this is 8 spaces right aligned */
|
||||
export class c {
|
||||
>c : c
|
||||
}
|
||||
|
||||
/** this is first line - 4 spaces right aligned to class but in js file should be aligned to class declaration
|
||||
* this is 8 spaces left aligned
|
||||
* this is 7 spaces left aligned
|
||||
* this is 6 spaces left aligned
|
||||
* this is 5 spaces left aligned
|
||||
* this is 4 spaces left aligned
|
||||
* this is 3 spaces left aligned
|
||||
* this is 2 spaces left aligned
|
||||
* this is 1 spaces left aligned
|
||||
* this is at same level as first line
|
||||
* this is 1 spaces right aligned
|
||||
* this is 2 spaces right aligned
|
||||
* this is 3 spaces right aligned
|
||||
* this is 4 spaces right aligned
|
||||
* this is 5 spaces right aligned
|
||||
* this is 6 spaces right aligned
|
||||
* this is 7 spaces right aligned
|
||||
* this is 8 spaces right aligned */
|
||||
export class c2 {
|
||||
>c2 : c2
|
||||
}
|
||||
|
||||
/** this is comment with new lines in between
|
||||
|
||||
this is 4 spaces left aligned but above line is empty
|
||||
|
||||
this is 3 spaces left aligned but above line is empty
|
||||
|
||||
this is 2 spaces left aligned but above line is empty
|
||||
|
||||
this is 1 spaces left aligned but above line is empty
|
||||
|
||||
this is at same level as first line but above line is empty
|
||||
|
||||
this is 1 spaces right aligned but above line is empty
|
||||
|
||||
this is 2 spaces right aligned but above line is empty
|
||||
|
||||
this is 3 spaces right aligned but above line is empty
|
||||
|
||||
this is 4 spaces right aligned but above line is empty
|
||||
|
||||
|
||||
Above 2 lines are empty
|
||||
|
||||
|
||||
|
||||
above 3 lines are empty*/
|
||||
export class c3 {
|
||||
>c3 : c3
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
/** This comment should appear for foo*/
|
||||
function foo() {
|
||||
}
|
||||
} /* trailing comment of function */
|
||||
foo();
|
||||
/** This is comment for function signature*/
|
||||
function fooWithParameters(/** this is comment about a*/a: string,
|
||||
/** this is comment for b*/
|
||||
b: number) {
|
||||
var d = a;
|
||||
}
|
||||
} // trailing comment of function
|
||||
fooWithParameters("a", 10);
|
||||
/** fooFunc
|
||||
* comment
|
||||
@@ -22,19 +22,50 @@ var fooFunc = function FooFunctionValue(/** fooFunctionValue param */ b: string)
|
||||
var lambdaFoo = /** this is lambda comment*/ (/**param a*/a: number, /**param b*/b: number) => a + b;
|
||||
var lambddaNoVarComment = /** this is lambda multiplication*/ (/**param a*/a: number, /**param b*/b: number) => a * b;
|
||||
lambdaFoo(10, 20);
|
||||
lambddaNoVarComment(10, 20);
|
||||
lambddaNoVarComment(10, 20);
|
||||
|
||||
function blah(a: string /* multiline trailing comment
|
||||
multiline */) {
|
||||
}
|
||||
|
||||
function blah2(a: string /* single line multiple trailing comments */ /* second */) {
|
||||
}
|
||||
|
||||
function blah3(a: string // trailing commen single line
|
||||
) {
|
||||
}
|
||||
|
||||
lambdaFoo = (a, b) => a * b; // This is trailing comment
|
||||
|
||||
/*leading comment*/() => 0; // Needs to be wrapped in parens to be a valid expression (not declaration)
|
||||
/*leading comment*/(() => 0); //trailing comment
|
||||
|
||||
function blah4(/*1*/a: string/*2*/,/*3*/b: string/*4*/) {
|
||||
}
|
||||
|
||||
function foo1() {
|
||||
|
||||
// should emit this
|
||||
}
|
||||
|
||||
function foo2() {
|
||||
/// This is some detached comment
|
||||
|
||||
// should emit this leading comment of } too
|
||||
}
|
||||
|
||||
|
||||
//// [commentsFunction.js]
|
||||
/** This comment should appear for foo*/
|
||||
function foo() {
|
||||
}
|
||||
} /* trailing comment of function */
|
||||
foo();
|
||||
/** This is comment for function signature*/
|
||||
function fooWithParameters(/** this is comment about a*/ a,
|
||||
/** this is comment for b*/
|
||||
b) {
|
||||
var d = a;
|
||||
}
|
||||
} // trailing comment of function
|
||||
fooWithParameters("a", 10);
|
||||
/** fooFunc
|
||||
* comment
|
||||
@@ -47,6 +78,26 @@ var lambdaFoo = function (/**param a*/ a, /**param b*/ b) { return a + b; };
|
||||
var lambddaNoVarComment = function (/**param a*/ a, /**param b*/ b) { return a * b; };
|
||||
lambdaFoo(10, 20);
|
||||
lambddaNoVarComment(10, 20);
|
||||
function blah(a /* multiline trailing comment
|
||||
multiline */) {
|
||||
}
|
||||
function blah2(a /* single line multiple trailing comments */ /* second */) {
|
||||
}
|
||||
function blah3(a // trailing commen single line
|
||||
) {
|
||||
}
|
||||
lambdaFoo = function (a, b) { return a * b; }; // This is trailing comment
|
||||
/*leading comment*/ (function () { return 0; }); // Needs to be wrapped in parens to be a valid expression (not declaration)
|
||||
/*leading comment*/ (function () { return 0; }); //trailing comment
|
||||
function blah4(/*1*/ a /*2*/, /*3*/ b /*4*/) {
|
||||
}
|
||||
function foo1() {
|
||||
// should emit this
|
||||
}
|
||||
function foo2() {
|
||||
/// This is some detached comment
|
||||
// should emit this leading comment of } too
|
||||
}
|
||||
|
||||
|
||||
//// [commentsFunction.d.ts]
|
||||
@@ -62,3 +113,9 @@ declare function fooWithParameters(/** this is comment about a*/ a: string,
|
||||
declare var fooFunc: (b: string) => string;
|
||||
declare var lambdaFoo: (a: number, b: number) => number;
|
||||
declare var lambddaNoVarComment: (a: number, b: number) => number;
|
||||
declare function blah(a: string): void;
|
||||
declare function blah2(a: string): void;
|
||||
declare function blah3(a: string): void;
|
||||
declare function blah4(a: string, b: string): void;
|
||||
declare function foo1(): void;
|
||||
declare function foo2(): void;
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
/** This comment should appear for foo*/
|
||||
function foo() {
|
||||
>foo : typeof foo
|
||||
}
|
||||
|
||||
} /* trailing comment of function */
|
||||
foo();
|
||||
>foo() : void
|
||||
>foo : typeof foo
|
||||
@@ -20,7 +21,8 @@ function fooWithParameters(/** this is comment about a*/a: string,
|
||||
var d = a;
|
||||
>d : string
|
||||
>a : string
|
||||
}
|
||||
|
||||
} // trailing comment of function
|
||||
fooWithParameters("a", 10);
|
||||
>fooWithParameters("a", 10) : void
|
||||
>fooWithParameters : typeof fooWithParameters
|
||||
@@ -65,3 +67,59 @@ lambddaNoVarComment(10, 20);
|
||||
>lambddaNoVarComment(10, 20) : number
|
||||
>lambddaNoVarComment : (a: number, b: number) => number
|
||||
|
||||
function blah(a: string /* multiline trailing comment
|
||||
>blah : typeof blah
|
||||
>a : string
|
||||
|
||||
multiline */) {
|
||||
}
|
||||
|
||||
function blah2(a: string /* single line multiple trailing comments */ /* second */) {
|
||||
>blah2 : typeof blah2
|
||||
>a : string
|
||||
}
|
||||
|
||||
function blah3(a: string // trailing commen single line
|
||||
>blah3 : typeof blah3
|
||||
>a : string
|
||||
|
||||
) {
|
||||
}
|
||||
|
||||
lambdaFoo = (a, b) => a * b; // This is trailing comment
|
||||
>lambdaFoo = (a, b) => a * b : (a: number, b: number) => number
|
||||
>lambdaFoo : (a: number, b: number) => number
|
||||
>(a, b) => a * b : (a: number, b: number) => number
|
||||
>a : number
|
||||
>b : number
|
||||
>a * b : number
|
||||
>a : number
|
||||
>b : number
|
||||
|
||||
/*leading comment*/() => 0; // Needs to be wrapped in parens to be a valid expression (not declaration)
|
||||
>() => 0 : () => number
|
||||
|
||||
/*leading comment*/(() => 0); //trailing comment
|
||||
>(() => 0) : () => number
|
||||
>() => 0 : () => number
|
||||
|
||||
function blah4(/*1*/a: string/*2*/,/*3*/b: string/*4*/) {
|
||||
>blah4 : typeof blah4
|
||||
>a : string
|
||||
>b : string
|
||||
}
|
||||
|
||||
function foo1() {
|
||||
>foo1 : typeof foo1
|
||||
|
||||
// should emit this
|
||||
}
|
||||
|
||||
function foo2() {
|
||||
>foo2 : typeof foo2
|
||||
|
||||
/// This is some detached comment
|
||||
|
||||
// should emit this leading comment of } too
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ module m1 {
|
||||
*/
|
||||
function foo4Export() {
|
||||
}
|
||||
}
|
||||
} // trailing comment module
|
||||
m1.fooExport();
|
||||
var myvar = new m1.m2.c();
|
||||
/** module comment of m2.m3*/
|
||||
@@ -43,14 +43,14 @@ module m2.m3 {
|
||||
/** Exported class comment*/
|
||||
export class c {
|
||||
}
|
||||
}
|
||||
} /* trailing dotted module comment*/
|
||||
new m2.m3.c();
|
||||
/** module comment of m3.m4.m5*/
|
||||
module m3.m4.m5 {
|
||||
/** Exported class comment*/
|
||||
export class c {
|
||||
}
|
||||
}
|
||||
} // trailing dotted module 2
|
||||
new m3.m4.m5.c();
|
||||
/** module comment of m4.m5.m6*/
|
||||
module m4.m5.m6 {
|
||||
@@ -58,7 +58,7 @@ module m4.m5.m6 {
|
||||
/** Exported class comment*/
|
||||
export class c {
|
||||
}
|
||||
}
|
||||
} /* trailing inner module */ /* multiple comments*/
|
||||
}
|
||||
new m4.m5.m6.m7.c();
|
||||
/** module comment of m5.m6.m7*/
|
||||
@@ -141,7 +141,7 @@ var m1;
|
||||
*/
|
||||
function foo4Export() {
|
||||
}
|
||||
})(m1 || (m1 = {}));
|
||||
})(m1 || (m1 = {})); // trailing comment module
|
||||
m1.fooExport();
|
||||
var myvar = new m1.m2.c();
|
||||
/** module comment of m2.m3*/
|
||||
@@ -157,7 +157,7 @@ var m2;
|
||||
m3.c = c;
|
||||
})(m2.m3 || (m2.m3 = {}));
|
||||
var m3 = m2.m3;
|
||||
})(m2 || (m2 = {}));
|
||||
})(m2 || (m2 = {})); /* trailing dotted module comment*/
|
||||
new m2.m3.c();
|
||||
/** module comment of m3.m4.m5*/
|
||||
var m3;
|
||||
@@ -175,7 +175,7 @@ var m3;
|
||||
var m5 = m4.m5;
|
||||
})(m3.m4 || (m3.m4 = {}));
|
||||
var m4 = m3.m4;
|
||||
})(m3 || (m3 = {}));
|
||||
})(m3 || (m3 = {})); // trailing dotted module 2
|
||||
new m3.m4.m5.c();
|
||||
/** module comment of m4.m5.m6*/
|
||||
var m4;
|
||||
@@ -191,7 +191,7 @@ var m4;
|
||||
})();
|
||||
m7.c = c;
|
||||
})(m6.m7 || (m6.m7 = {}));
|
||||
var m7 = m6.m7;
|
||||
var m7 = m6.m7; /* trailing inner module */ /* multiple comments*/
|
||||
})(m5.m6 || (m5.m6 = {}));
|
||||
var m6 = m5.m6;
|
||||
})(m4.m5 || (m4.m5 = {}));
|
||||
|
||||
@@ -57,7 +57,7 @@ module m1 {
|
||||
function foo4Export() {
|
||||
>foo4Export : typeof foo4Export
|
||||
}
|
||||
}
|
||||
} // trailing comment module
|
||||
m1.fooExport();
|
||||
>m1.fooExport() : number
|
||||
>m1.fooExport : typeof m1.fooExport
|
||||
@@ -82,7 +82,7 @@ module m2.m3 {
|
||||
export class c {
|
||||
>c : c
|
||||
}
|
||||
}
|
||||
} /* trailing dotted module comment*/
|
||||
new m2.m3.c();
|
||||
>new m2.m3.c() : m2.m3.c
|
||||
>m2.m3.c : typeof m2.m3.c
|
||||
@@ -101,7 +101,7 @@ module m3.m4.m5 {
|
||||
export class c {
|
||||
>c : c
|
||||
}
|
||||
}
|
||||
} // trailing dotted module 2
|
||||
new m3.m4.m5.c();
|
||||
>new m3.m4.m5.c() : m3.m4.m5.c
|
||||
>m3.m4.m5.c : typeof m3.m4.m5.c
|
||||
@@ -125,7 +125,7 @@ module m4.m5.m6 {
|
||||
export class c {
|
||||
>c : c
|
||||
}
|
||||
}
|
||||
} /* trailing inner module */ /* multiple comments*/
|
||||
}
|
||||
new m4.m5.m6.m7.c();
|
||||
>new m4.m5.m6.m7.c() : m4.m5.m6.m7.c
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
==== tests/cases/compiler/commentsMultiModuleMultiFile_1.ts (0 errors) ====
|
||||
import m = require('commentsMultiModuleMultiFile_0');
|
||||
/** this is multi module 3 comment*/
|
||||
module multiM {
|
||||
/** class d comment*/
|
||||
export class d {
|
||||
}
|
||||
|
||||
/// class f comment
|
||||
export class f {
|
||||
}
|
||||
}
|
||||
new multiM.d();
|
||||
==== tests/cases/compiler/commentsMultiModuleMultiFile_0.ts (3 errors) ====
|
||||
|
||||
/** this is multi declare module*/
|
||||
export module multiM {
|
||||
~~~~~~
|
||||
!!! Individual declarations in merged declaration multiM must be all exported or all local.
|
||||
/// class b comment
|
||||
export class b {
|
||||
}
|
||||
}
|
||||
/** thi is multi module 2*/
|
||||
module multiM {
|
||||
~~~~~~
|
||||
!!! Individual declarations in merged declaration multiM must be all exported or all local.
|
||||
/** class c comment*/
|
||||
export class c {
|
||||
}
|
||||
|
||||
// class e comment
|
||||
export class e {
|
||||
}
|
||||
}
|
||||
|
||||
new multiM.b();
|
||||
new multiM.c();
|
||||
~
|
||||
!!! Property 'c' does not exist on type 'typeof multiM'.
|
||||
|
||||
@@ -9,7 +9,7 @@ export module multiM {
|
||||
}
|
||||
}
|
||||
/** thi is multi module 2*/
|
||||
module multiM {
|
||||
export module multiM {
|
||||
/** class c comment*/
|
||||
export class c {
|
||||
}
|
||||
@@ -25,7 +25,7 @@ new multiM.c();
|
||||
//// [commentsMultiModuleMultiFile_1.ts]
|
||||
import m = require('commentsMultiModuleMultiFile_0');
|
||||
/** this is multi module 3 comment*/
|
||||
module multiM {
|
||||
export module multiM {
|
||||
/** class d comment*/
|
||||
export class d {
|
||||
}
|
||||
@@ -50,7 +50,6 @@ define(["require", "exports"], function (require, exports) {
|
||||
})(exports.multiM || (exports.multiM = {}));
|
||||
var multiM = exports.multiM;
|
||||
/** thi is multi module 2*/
|
||||
var multiM;
|
||||
(function (multiM) {
|
||||
/** class c comment*/
|
||||
var c = (function () {
|
||||
@@ -66,14 +65,14 @@ define(["require", "exports"], function (require, exports) {
|
||||
return e;
|
||||
})();
|
||||
multiM.e = e;
|
||||
})(multiM || (multiM = {}));
|
||||
})(exports.multiM || (exports.multiM = {}));
|
||||
var multiM = exports.multiM;
|
||||
new multiM.b();
|
||||
new multiM.c();
|
||||
});
|
||||
//// [commentsMultiModuleMultiFile_1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
/** this is multi module 3 comment*/
|
||||
var multiM;
|
||||
(function (multiM) {
|
||||
/** class d comment*/
|
||||
var d = (function () {
|
||||
@@ -89,6 +88,32 @@ define(["require", "exports"], function (require, exports) {
|
||||
return f;
|
||||
})();
|
||||
multiM.f = f;
|
||||
})(multiM || (multiM = {}));
|
||||
})(exports.multiM || (exports.multiM = {}));
|
||||
var multiM = exports.multiM;
|
||||
new multiM.d();
|
||||
});
|
||||
|
||||
|
||||
//// [commentsMultiModuleMultiFile_0.d.ts]
|
||||
/** this is multi declare module*/
|
||||
export declare module multiM {
|
||||
class b {
|
||||
}
|
||||
}
|
||||
/** thi is multi module 2*/
|
||||
export declare module multiM {
|
||||
/** class c comment*/
|
||||
class c {
|
||||
}
|
||||
class e {
|
||||
}
|
||||
}
|
||||
//// [commentsMultiModuleMultiFile_1.d.ts]
|
||||
/** this is multi module 3 comment*/
|
||||
export declare module multiM {
|
||||
/** class d comment*/
|
||||
class d {
|
||||
}
|
||||
class f {
|
||||
}
|
||||
}
|
||||
|
||||
62
tests/baselines/reference/commentsMultiModuleMultiFile.types
Normal file
62
tests/baselines/reference/commentsMultiModuleMultiFile.types
Normal file
@@ -0,0 +1,62 @@
|
||||
=== tests/cases/compiler/commentsMultiModuleMultiFile_1.ts ===
|
||||
import m = require('commentsMultiModuleMultiFile_0');
|
||||
>m : m
|
||||
|
||||
/** this is multi module 3 comment*/
|
||||
export module multiM {
|
||||
>multiM : multiM
|
||||
|
||||
/** class d comment*/
|
||||
export class d {
|
||||
>d : d
|
||||
}
|
||||
|
||||
/// class f comment
|
||||
export class f {
|
||||
>f : f
|
||||
}
|
||||
}
|
||||
new multiM.d();
|
||||
>new multiM.d() : multiM.d
|
||||
>multiM.d : typeof multiM.d
|
||||
>multiM : typeof multiM
|
||||
>d : typeof multiM.d
|
||||
|
||||
=== tests/cases/compiler/commentsMultiModuleMultiFile_0.ts ===
|
||||
|
||||
/** this is multi declare module*/
|
||||
export module multiM {
|
||||
>multiM : multiM
|
||||
|
||||
/// class b comment
|
||||
export class b {
|
||||
>b : b
|
||||
}
|
||||
}
|
||||
/** thi is multi module 2*/
|
||||
export module multiM {
|
||||
>multiM : multiM
|
||||
|
||||
/** class c comment*/
|
||||
export class c {
|
||||
>c : c
|
||||
}
|
||||
|
||||
// class e comment
|
||||
export class e {
|
||||
>e : e
|
||||
}
|
||||
}
|
||||
|
||||
new multiM.b();
|
||||
>new multiM.b() : multiM.b
|
||||
>multiM.b : typeof multiM.b
|
||||
>multiM : typeof multiM
|
||||
>b : typeof multiM.b
|
||||
|
||||
new multiM.c();
|
||||
>new multiM.c() : multiM.c
|
||||
>multiM.c : typeof multiM.c
|
||||
>multiM : typeof multiM
|
||||
>c : typeof multiM.c
|
||||
|
||||
@@ -10,6 +10,6 @@
|
||||
*/
|
||||
initialize: function(name) {
|
||||
this.name = name;
|
||||
},
|
||||
} /* trailing comment 1*/,
|
||||
}
|
||||
);
|
||||
@@ -8,7 +8,7 @@ var Person = makeClass(
|
||||
*/
|
||||
initialize: function(name) {
|
||||
this.name = name;
|
||||
},
|
||||
} /* trailing comment 1*/,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -21,5 +21,5 @@ var Person = makeClass({
|
||||
*/
|
||||
initialize: function (name) {
|
||||
this.name = name;
|
||||
}
|
||||
} /* trailing comment 1*/
|
||||
});
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
==== tests/cases/compiler/commentsOnObjectLiteral3.ts (2 errors) ====
|
||||
|
||||
var v = {
|
||||
//property
|
||||
prop: 1,
|
||||
//property
|
||||
func: function () {
|
||||
},
|
||||
//PropertyName + CallSignature
|
||||
func1() { },
|
||||
//getter
|
||||
get a() {
|
||||
~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
return this.prop;
|
||||
},
|
||||
//setter
|
||||
set a(value) {
|
||||
~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
this.prop = value;
|
||||
}
|
||||
};
|
||||
|
||||
40
tests/baselines/reference/commentsOnObjectLiteral3.js
Normal file
40
tests/baselines/reference/commentsOnObjectLiteral3.js
Normal file
@@ -0,0 +1,40 @@
|
||||
//// [commentsOnObjectLiteral3.ts]
|
||||
|
||||
var v = {
|
||||
//property
|
||||
prop: 1 /* multiple trailing comments */ /*trailing comments*/,
|
||||
//property
|
||||
func: function () {
|
||||
},
|
||||
//PropertyName + CallSignature
|
||||
func1() { },
|
||||
//getter
|
||||
get a() {
|
||||
return this.prop;
|
||||
} /*trailing 1*/,
|
||||
//setter
|
||||
set a(value) {
|
||||
this.prop = value;
|
||||
} // trailing 2
|
||||
};
|
||||
|
||||
|
||||
//// [commentsOnObjectLiteral3.js]
|
||||
var v = {
|
||||
//property
|
||||
prop: 1 /* multiple trailing comments */ /*trailing comments*/,
|
||||
//property
|
||||
func: function () {
|
||||
},
|
||||
//PropertyName + CallSignature
|
||||
func1: function () {
|
||||
},
|
||||
//getter
|
||||
get a() {
|
||||
return this.prop;
|
||||
} /*trailing 1*/,
|
||||
//setter
|
||||
set a(value) {
|
||||
this.prop = value;
|
||||
} // trailing 2
|
||||
};
|
||||
46
tests/baselines/reference/commentsOnObjectLiteral3.types
Normal file
46
tests/baselines/reference/commentsOnObjectLiteral3.types
Normal file
@@ -0,0 +1,46 @@
|
||||
=== tests/cases/compiler/commentsOnObjectLiteral3.ts ===
|
||||
|
||||
var v = {
|
||||
>v : { prop: number; func: () => void; func1: () => void; a: any; }
|
||||
>{ //property prop: 1 /* multiple trailing comments */ /*trailing comments*/, //property func: function () { }, //PropertyName + CallSignature func1() { }, //getter get a() { return this.prop; } /*trailing 1*/, //setter set a(value) { this.prop = value; } // trailing 2} : { prop: number; func: () => void; func1: () => void; a: any; }
|
||||
|
||||
//property
|
||||
prop: 1 /* multiple trailing comments */ /*trailing comments*/,
|
||||
>prop : number
|
||||
|
||||
//property
|
||||
func: function () {
|
||||
>func : () => void
|
||||
>function () { } : () => void
|
||||
|
||||
},
|
||||
//PropertyName + CallSignature
|
||||
func1() { },
|
||||
>func1 : () => void
|
||||
>func1() { } : () => void
|
||||
|
||||
//getter
|
||||
get a() {
|
||||
>a : any
|
||||
|
||||
return this.prop;
|
||||
>this.prop : any
|
||||
>this : any
|
||||
>prop : any
|
||||
|
||||
} /*trailing 1*/,
|
||||
//setter
|
||||
set a(value) {
|
||||
>a : any
|
||||
>value : any
|
||||
|
||||
this.prop = value;
|
||||
>this.prop = value : any
|
||||
>this.prop : any
|
||||
>this : any
|
||||
>prop : any
|
||||
>value : any
|
||||
|
||||
} // trailing 2
|
||||
};
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
==== tests/cases/compiler/commentsOnObjectLiteral4.ts (1 errors) ====
|
||||
|
||||
var v = {
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
get bar(): number {
|
||||
~~~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
return this._bar;
|
||||
}
|
||||
}
|
||||
20
tests/baselines/reference/commentsOnObjectLiteral4.js
Normal file
20
tests/baselines/reference/commentsOnObjectLiteral4.js
Normal file
@@ -0,0 +1,20 @@
|
||||
//// [commentsOnObjectLiteral4.ts]
|
||||
|
||||
var v = {
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
get bar(): number {
|
||||
return this._bar;
|
||||
}
|
||||
}
|
||||
|
||||
//// [commentsOnObjectLiteral4.js]
|
||||
var v = {
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
get bar() {
|
||||
return this._bar;
|
||||
}
|
||||
};
|
||||
18
tests/baselines/reference/commentsOnObjectLiteral4.types
Normal file
18
tests/baselines/reference/commentsOnObjectLiteral4.types
Normal file
@@ -0,0 +1,18 @@
|
||||
=== tests/cases/compiler/commentsOnObjectLiteral4.ts ===
|
||||
|
||||
var v = {
|
||||
>v : { bar: number; }
|
||||
>{ /** * @type {number} */ get bar(): number { return this._bar; }} : { bar: number; }
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
get bar(): number {
|
||||
>bar : number
|
||||
|
||||
return this._bar;
|
||||
>this._bar : any
|
||||
>this : any
|
||||
>_bar : any
|
||||
}
|
||||
}
|
||||
44
tests/baselines/reference/commentsTypeParameters.js
Normal file
44
tests/baselines/reference/commentsTypeParameters.js
Normal file
@@ -0,0 +1,44 @@
|
||||
//// [commentsTypeParameters.ts]
|
||||
class C</**docComment for type parameter*/ T> {
|
||||
method</**docComment of method type parameter */ U extends T>(a: U) {
|
||||
}
|
||||
static staticmethod</**docComment of method type parameter */ U>(a: U) {
|
||||
}
|
||||
|
||||
private privatemethod</**docComment of method type parameter */ U extends T>(a: U) {
|
||||
}
|
||||
private static privatestaticmethod</**docComment of method type parameter */ U>(a: U) {
|
||||
}
|
||||
}
|
||||
|
||||
function compare</**type*/T>(a: T, b: T) {
|
||||
return a === b;
|
||||
}
|
||||
|
||||
//// [commentsTypeParameters.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.method = function (a) {
|
||||
};
|
||||
C.staticmethod = function (a) {
|
||||
};
|
||||
C.prototype.privatemethod = function (a) {
|
||||
};
|
||||
C.privatestaticmethod = function (a) {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
function compare(a, b) {
|
||||
return a === b;
|
||||
}
|
||||
|
||||
|
||||
//// [commentsTypeParameters.d.ts]
|
||||
declare class C</**docComment for type parameter*/ T> {
|
||||
method</**docComment of method type parameter */ U extends T>(a: U): void;
|
||||
static staticmethod</**docComment of method type parameter */ U>(a: U): void;
|
||||
private privatemethod</**docComment of method type parameter */ U>(a);
|
||||
private static privatestaticmethod</**docComment of method type parameter */ U>(a);
|
||||
}
|
||||
declare function compare</**type*/ T>(a: T, b: T): boolean;
|
||||
47
tests/baselines/reference/commentsTypeParameters.types
Normal file
47
tests/baselines/reference/commentsTypeParameters.types
Normal file
@@ -0,0 +1,47 @@
|
||||
=== tests/cases/compiler/commentsTypeParameters.ts ===
|
||||
class C</**docComment for type parameter*/ T> {
|
||||
>C : C<T>
|
||||
>T : T
|
||||
|
||||
method</**docComment of method type parameter */ U extends T>(a: U) {
|
||||
>method : <U extends T>(a: U) => void
|
||||
>U : U
|
||||
>T : T
|
||||
>a : U
|
||||
>U : U
|
||||
}
|
||||
static staticmethod</**docComment of method type parameter */ U>(a: U) {
|
||||
>staticmethod : <U>(a: U) => void
|
||||
>U : U
|
||||
>a : U
|
||||
>U : U
|
||||
}
|
||||
|
||||
private privatemethod</**docComment of method type parameter */ U extends T>(a: U) {
|
||||
>privatemethod : <U extends T>(a: U) => void
|
||||
>U : U
|
||||
>T : T
|
||||
>a : U
|
||||
>U : U
|
||||
}
|
||||
private static privatestaticmethod</**docComment of method type parameter */ U>(a: U) {
|
||||
>privatestaticmethod : <U>(a: U) => void
|
||||
>U : U
|
||||
>a : U
|
||||
>U : U
|
||||
}
|
||||
}
|
||||
|
||||
function compare</**type*/T>(a: T, b: T) {
|
||||
>compare : typeof compare
|
||||
>T : T
|
||||
>a : T
|
||||
>T : T
|
||||
>b : T
|
||||
>T : T
|
||||
|
||||
return a === b;
|
||||
>a === b : boolean
|
||||
>a : T
|
||||
>b : T
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
//// [commentsVarDecl.ts]
|
||||
|
||||
/** Variable comments*/
|
||||
var myVariable = 10;
|
||||
var myVariable = 10; // This trailing Comment1
|
||||
|
||||
/** This is another variable comment*/
|
||||
var anotherVariable = 30;
|
||||
@@ -11,13 +11,13 @@ var aVar = "";
|
||||
|
||||
/** this is multiline comment
|
||||
* All these variables are of number type */
|
||||
var anotherAnotherVariable = 70;
|
||||
var anotherAnotherVariable = 70; /* these are multiple trailing comments */ /* multiple trailing comments */
|
||||
|
||||
/** Triple slash multiline comment*/
|
||||
/** another line in the comment*/
|
||||
/** comment line 2*/
|
||||
var x = 70;
|
||||
|
||||
var x = 70; /* multiline trailing comment
|
||||
this is multiline trailing comment */
|
||||
/** Triple slash comment on the assignement shouldnt be in .d.ts file*/
|
||||
x = myVariable;
|
||||
|
||||
@@ -45,18 +45,19 @@ n4 = z2;
|
||||
|
||||
//// [commentsVarDecl.js]
|
||||
/** Variable comments*/
|
||||
var myVariable = 10;
|
||||
var myVariable = 10; // This trailing Comment1
|
||||
/** This is another variable comment*/
|
||||
var anotherVariable = 30;
|
||||
// shouldn't appear
|
||||
var aVar = "";
|
||||
/** this is multiline comment
|
||||
* All these variables are of number type */
|
||||
var anotherAnotherVariable = 70;
|
||||
var anotherAnotherVariable = 70; /* these are multiple trailing comments */ /* multiple trailing comments */
|
||||
/** Triple slash multiline comment*/
|
||||
/** another line in the comment*/
|
||||
/** comment line 2*/
|
||||
var x = 70;
|
||||
var x = 70; /* multiline trailing comment
|
||||
this is multiline trailing comment */
|
||||
/** Triple slash comment on the assignement shouldnt be in .d.ts file*/
|
||||
x = myVariable;
|
||||
/** triple slash comment1*/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
=== tests/cases/compiler/commentsVarDecl.ts ===
|
||||
|
||||
/** Variable comments*/
|
||||
var myVariable = 10;
|
||||
var myVariable = 10; // This trailing Comment1
|
||||
>myVariable : number
|
||||
|
||||
/** This is another variable comment*/
|
||||
@@ -14,15 +14,16 @@ var aVar = "";
|
||||
|
||||
/** this is multiline comment
|
||||
* All these variables are of number type */
|
||||
var anotherAnotherVariable = 70;
|
||||
var anotherAnotherVariable = 70; /* these are multiple trailing comments */ /* multiple trailing comments */
|
||||
>anotherAnotherVariable : number
|
||||
|
||||
/** Triple slash multiline comment*/
|
||||
/** another line in the comment*/
|
||||
/** comment line 2*/
|
||||
var x = 70;
|
||||
var x = 70; /* multiline trailing comment
|
||||
>x : number
|
||||
|
||||
this is multiline trailing comment */
|
||||
/** Triple slash comment on the assignement shouldnt be in .d.ts file*/
|
||||
x = myVariable;
|
||||
>x = myVariable : number
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
==== tests/cases/compiler/complicatedPrivacy.ts (5 errors) ====
|
||||
==== tests/cases/compiler/complicatedPrivacy.ts (4 errors) ====
|
||||
module m1 {
|
||||
export module m2 {
|
||||
|
||||
@@ -11,13 +11,11 @@
|
||||
export class C2 implements m3.i3 {
|
||||
public get p1(arg) {
|
||||
~~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
!!! A 'get' accessor cannot have parameters.
|
||||
return new C1();
|
||||
}
|
||||
|
||||
public set p1(arg1: C1) {
|
||||
~~
|
||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
}
|
||||
|
||||
public f55() {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
==== tests/cases/compiler/constructorArgsErrors3.ts (1 errors) ====
|
||||
class foo {
|
||||
constructor (public public a: number) {
|
||||
~~~~~~
|
||||
!!! Accessibility modifier already seen.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
==== tests/cases/compiler/constructorArgsErrors4.ts (1 errors) ====
|
||||
class foo {
|
||||
constructor (private public a: number) {
|
||||
~~~~~~
|
||||
!!! Accessibility modifier already seen.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
==== tests/cases/compiler/constructorArgsErrors5.ts (1 errors) ====
|
||||
class foo {
|
||||
constructor (export a: number) {
|
||||
~~~~~~
|
||||
!!! 'export' modifier cannot appear on a parameter.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
==== tests/cases/compiler/constructorsWithSpecializedSignatures.ts (8 errors) ====
|
||||
// errors
|
||||
declare class C {
|
||||
constructor(x: "hi");
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
||||
constructor(x: "foo");
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
||||
constructor(x: number);
|
||||
}
|
||||
|
||||
// ok
|
||||
declare class C2 {
|
||||
constructor(x: "hi");
|
||||
constructor(x: "foo");
|
||||
constructor(x: string);
|
||||
}
|
||||
|
||||
// errors
|
||||
class D {
|
||||
constructor(x: "hi");
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
||||
constructor(x: "foo");
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
||||
constructor(x: number);
|
||||
constructor(x: "hi") { }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! A signature with an implementation cannot use a string literal type.
|
||||
}
|
||||
|
||||
// overloads are ok
|
||||
class D2 {
|
||||
constructor(x: "hi");
|
||||
constructor(x: "foo");
|
||||
constructor(x: string);
|
||||
constructor(x: "hi") { } // error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! A signature with an implementation cannot use a string literal type.
|
||||
}
|
||||
|
||||
// errors
|
||||
interface I {
|
||||
new (x: "hi");
|
||||
~~~~~~~~~~~~~~
|
||||
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
||||
new (x: "foo");
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
||||
new (x: number);
|
||||
}
|
||||
|
||||
// ok
|
||||
interface I2 {
|
||||
new (x: "hi");
|
||||
new (x: "foo");
|
||||
new (x: string);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
//// [constructorsWithSpecializedSignatures.ts]
|
||||
// errors
|
||||
declare class C {
|
||||
constructor(x: "hi");
|
||||
constructor(x: "foo");
|
||||
constructor(x: number);
|
||||
}
|
||||
|
||||
// ok
|
||||
declare class C2 {
|
||||
constructor(x: "hi");
|
||||
constructor(x: "foo");
|
||||
constructor(x: string);
|
||||
}
|
||||
|
||||
// errors
|
||||
class D {
|
||||
constructor(x: "hi");
|
||||
constructor(x: "foo");
|
||||
constructor(x: number);
|
||||
constructor(x: "hi") { }
|
||||
}
|
||||
|
||||
// overloads are ok
|
||||
class D2 {
|
||||
constructor(x: "hi");
|
||||
constructor(x: "foo");
|
||||
constructor(x: string);
|
||||
constructor(x: "hi") { } // error
|
||||
}
|
||||
|
||||
// errors
|
||||
interface I {
|
||||
new (x: "hi");
|
||||
new (x: "foo");
|
||||
new (x: number);
|
||||
}
|
||||
|
||||
// ok
|
||||
interface I2 {
|
||||
new (x: "hi");
|
||||
new (x: "foo");
|
||||
new (x: string);
|
||||
}
|
||||
|
||||
//// [constructorsWithSpecializedSignatures.js]
|
||||
// errors
|
||||
var D = (function () {
|
||||
function D(x) {
|
||||
}
|
||||
return D;
|
||||
})();
|
||||
// overloads are ok
|
||||
var D2 = (function () {
|
||||
function D2(x) {
|
||||
} // error
|
||||
return D2;
|
||||
})();
|
||||
@@ -0,0 +1,43 @@
|
||||
//// [contextualSignatureInstantiation3.ts]
|
||||
function map<T, U>(items: T[], f: (x: T) => U): U[]{
|
||||
return items.map(f);
|
||||
}
|
||||
|
||||
function identity<T>(x: T) {
|
||||
return x;
|
||||
}
|
||||
|
||||
function singleton<T>(x: T) {
|
||||
return [x];
|
||||
}
|
||||
|
||||
var xs = [1, 2, 3];
|
||||
|
||||
// Have compiler check that we get the correct types
|
||||
var v1: number[];
|
||||
var v1 = xs.map(identity); // Error if not number[]
|
||||
var v1 = map(xs, identity); // Error if not number[]
|
||||
|
||||
var v2: number[][];
|
||||
var v2 = xs.map(singleton); // Error if not number[][]
|
||||
var v2 = map(xs, singleton); // Error if not number[][]
|
||||
|
||||
|
||||
//// [contextualSignatureInstantiation3.js]
|
||||
function map(items, f) {
|
||||
return items.map(f);
|
||||
}
|
||||
function identity(x) {
|
||||
return x;
|
||||
}
|
||||
function singleton(x) {
|
||||
return [x];
|
||||
}
|
||||
var xs = [1, 2, 3];
|
||||
// Have compiler check that we get the correct types
|
||||
var v1;
|
||||
var v1 = xs.map(identity); // Error if not number[]
|
||||
var v1 = map(xs, identity); // Error if not number[]
|
||||
var v2;
|
||||
var v2 = xs.map(singleton); // Error if not number[][]
|
||||
var v2 = map(xs, singleton); // Error if not number[][]
|
||||
@@ -0,0 +1,83 @@
|
||||
=== tests/cases/compiler/contextualSignatureInstantiation3.ts ===
|
||||
function map<T, U>(items: T[], f: (x: T) => U): U[]{
|
||||
>map : typeof map
|
||||
>T : T
|
||||
>U : U
|
||||
>items : T[]
|
||||
>T : T
|
||||
>f : (x: T) => U
|
||||
>x : T
|
||||
>T : T
|
||||
>U : U
|
||||
>U : U
|
||||
|
||||
return items.map(f);
|
||||
>items.map(f) : U[]
|
||||
>items.map : <U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]
|
||||
>items : T[]
|
||||
>map : <U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]
|
||||
>f : (x: T) => U
|
||||
}
|
||||
|
||||
function identity<T>(x: T) {
|
||||
>identity : typeof identity
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
|
||||
return x;
|
||||
>x : T
|
||||
}
|
||||
|
||||
function singleton<T>(x: T) {
|
||||
>singleton : typeof singleton
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
|
||||
return [x];
|
||||
>[x] : T[]
|
||||
>x : T
|
||||
}
|
||||
|
||||
var xs = [1, 2, 3];
|
||||
>xs : number[]
|
||||
>[1, 2, 3] : number[]
|
||||
|
||||
// Have compiler check that we get the correct types
|
||||
var v1: number[];
|
||||
>v1 : number[]
|
||||
|
||||
var v1 = xs.map(identity); // Error if not number[]
|
||||
>v1 : number[]
|
||||
>xs.map(identity) : number[]
|
||||
>xs.map : <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]
|
||||
>xs : number[]
|
||||
>map : <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]
|
||||
>identity : typeof identity
|
||||
|
||||
var v1 = map(xs, identity); // Error if not number[]
|
||||
>v1 : number[]
|
||||
>map(xs, identity) : number[]
|
||||
>map : typeof map
|
||||
>xs : number[]
|
||||
>identity : typeof identity
|
||||
|
||||
var v2: number[][];
|
||||
>v2 : number[][]
|
||||
|
||||
var v2 = xs.map(singleton); // Error if not number[][]
|
||||
>v2 : number[][]
|
||||
>xs.map(singleton) : number[][]
|
||||
>xs.map : <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]
|
||||
>xs : number[]
|
||||
>map : <U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]
|
||||
>singleton : typeof singleton
|
||||
|
||||
var v2 = map(xs, singleton); // Error if not number[][]
|
||||
>v2 : number[][]
|
||||
>map(xs, singleton) : number[][]
|
||||
>map : typeof map
|
||||
>xs : number[]
|
||||
>singleton : typeof singleton
|
||||
|
||||
@@ -234,5 +234,5 @@
|
||||
interface B extends A { }
|
||||
var x: B = { };
|
||||
~
|
||||
!!! Type '{}' is not assignable to type 'B':
|
||||
!!! Property 'x' is missing in type '{}'.
|
||||
!!! Type '{}' is not assignable to type 'B':\n Property 'x' is missing in type '{}'.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user