Added tests
This commit is contained in:
parent
16d8d9eb02
commit
e76f920e75
|
@ -0,0 +1,21 @@
|
|||
tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts(9,14): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/decorators/class/decoratorChecksFunctionBodies.ts (1 errors) ====
|
||||
|
||||
// from #2971
|
||||
function func(s: string): void {
|
||||
}
|
||||
|
||||
class A {
|
||||
@(x => {
|
||||
var a = 3;
|
||||
func(a);
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
|
||||
return x;
|
||||
})
|
||||
m() {
|
||||
|
||||
}
|
||||
}
|
44
tests/baselines/reference/decoratorChecksFunctionBodies.js
Normal file
44
tests/baselines/reference/decoratorChecksFunctionBodies.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
//// [decoratorChecksFunctionBodies.ts]
|
||||
|
||||
// from #2971
|
||||
function func(s: string): void {
|
||||
}
|
||||
|
||||
class A {
|
||||
@(x => {
|
||||
var a = 3;
|
||||
func(a);
|
||||
return x;
|
||||
})
|
||||
m() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//// [decoratorChecksFunctionBodies.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
|
||||
switch (arguments.length) {
|
||||
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);
|
||||
case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);
|
||||
case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);
|
||||
}
|
||||
};
|
||||
// from #2971
|
||||
function func(s) {
|
||||
}
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
A.prototype.m = function () {
|
||||
};
|
||||
Object.defineProperty(A.prototype, "m",
|
||||
__decorate([
|
||||
(function (x) {
|
||||
var a = 3;
|
||||
func(a);
|
||||
return x;
|
||||
})
|
||||
], A.prototype, "m", Object.getOwnPropertyDescriptor(A.prototype, "m")));
|
||||
return A;
|
||||
})();
|
|
@ -0,0 +1,53 @@
|
|||
//// [tests/cases/conformance/decorators/class/decoratorInstantiateModulesInFunctionBodies.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
|
||||
// from #3108
|
||||
export var test = 'abc';
|
||||
|
||||
//// [b.ts]
|
||||
import { test } from './a';
|
||||
|
||||
function filter(handler: any) {
|
||||
return function (target: any) {
|
||||
// ...
|
||||
};
|
||||
}
|
||||
|
||||
class Wat {
|
||||
@filter(() => test == 'abc')
|
||||
static whatever() {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
|
||||
//// [a.js]
|
||||
// from #3108
|
||||
exports.test = 'abc';
|
||||
//// [b.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
|
||||
switch (arguments.length) {
|
||||
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);
|
||||
case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);
|
||||
case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);
|
||||
}
|
||||
};
|
||||
var a_1 = require('./a');
|
||||
function filter(handler) {
|
||||
return function (target) {
|
||||
// ...
|
||||
};
|
||||
}
|
||||
var Wat = (function () {
|
||||
function Wat() {
|
||||
}
|
||||
Wat.whatever = function () {
|
||||
// ...
|
||||
};
|
||||
Object.defineProperty(Wat, "whatever",
|
||||
__decorate([
|
||||
filter(function () { return a_1.test == 'abc'; })
|
||||
], Wat, "whatever", Object.getOwnPropertyDescriptor(Wat, "whatever")));
|
||||
return Wat;
|
||||
})();
|
|
@ -0,0 +1,34 @@
|
|||
=== tests/cases/conformance/decorators/class/a.ts ===
|
||||
|
||||
// from #3108
|
||||
export var test = 'abc';
|
||||
>test : Symbol(test, Decl(a.ts, 2, 10))
|
||||
|
||||
=== tests/cases/conformance/decorators/class/b.ts ===
|
||||
import { test } from './a';
|
||||
>test : Symbol(test, Decl(b.ts, 0, 8))
|
||||
|
||||
function filter(handler: any) {
|
||||
>filter : Symbol(filter, Decl(b.ts, 0, 27))
|
||||
>handler : Symbol(handler, Decl(b.ts, 2, 16))
|
||||
|
||||
return function (target: any) {
|
||||
>target : Symbol(target, Decl(b.ts, 3, 21))
|
||||
|
||||
// ...
|
||||
};
|
||||
}
|
||||
|
||||
class Wat {
|
||||
>Wat : Symbol(Wat, Decl(b.ts, 6, 1))
|
||||
|
||||
@filter(() => test == 'abc')
|
||||
>filter : Symbol(filter, Decl(b.ts, 0, 27))
|
||||
>test : Symbol(test, Decl(b.ts, 0, 8))
|
||||
|
||||
static whatever() {
|
||||
>whatever : Symbol(Wat.whatever, Decl(b.ts, 8, 11))
|
||||
|
||||
// ...
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
=== tests/cases/conformance/decorators/class/a.ts ===
|
||||
|
||||
// from #3108
|
||||
export var test = 'abc';
|
||||
>test : string
|
||||
>'abc' : string
|
||||
|
||||
=== tests/cases/conformance/decorators/class/b.ts ===
|
||||
import { test } from './a';
|
||||
>test : string
|
||||
|
||||
function filter(handler: any) {
|
||||
>filter : (handler: any) => (target: any) => void
|
||||
>handler : any
|
||||
|
||||
return function (target: any) {
|
||||
>function (target: any) { // ... } : (target: any) => void
|
||||
>target : any
|
||||
|
||||
// ...
|
||||
};
|
||||
}
|
||||
|
||||
class Wat {
|
||||
>Wat : Wat
|
||||
|
||||
@filter(() => test == 'abc')
|
||||
>filter(() => test == 'abc') : (target: any) => void
|
||||
>filter : (handler: any) => (target: any) => void
|
||||
>() => test == 'abc' : () => boolean
|
||||
>test == 'abc' : boolean
|
||||
>test : string
|
||||
>'abc' : string
|
||||
|
||||
static whatever() {
|
||||
>whatever : () => void
|
||||
|
||||
// ...
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
// @target:es5
|
||||
|
||||
// from #2971
|
||||
function func(s: string): void {
|
||||
}
|
||||
|
||||
class A {
|
||||
@(x => {
|
||||
var a = 3;
|
||||
func(a);
|
||||
return x;
|
||||
})
|
||||
m() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
// @target:es5
|
||||
// @module:commonjs
|
||||
// @filename: a.ts
|
||||
|
||||
// from #3108
|
||||
export var test = 'abc';
|
||||
|
||||
// @filename: b.ts
|
||||
import { test } from './a';
|
||||
|
||||
function filter(handler: any) {
|
||||
return function (target: any) {
|
||||
// ...
|
||||
};
|
||||
}
|
||||
|
||||
class Wat {
|
||||
@filter(() => test == 'abc')
|
||||
static whatever() {
|
||||
// ...
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue