mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-11 19:27:35 -06:00
Merge pull request #6193 from Microsoft/fixUpFromPRs-2015-12-21
Nit fix ups for PRs
This commit is contained in:
commit
7785e84926
@ -4280,25 +4280,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
|
||||
// TODO (yuisu) : we should not have special cases to condition emitting comments
|
||||
// but have one place to fix check for these conditions.
|
||||
if (node.kind !== SyntaxKind.MethodDeclaration &&
|
||||
node.kind !== SyntaxKind.MethodSignature &&
|
||||
node.parent &&
|
||||
node.parent.kind !== SyntaxKind.PropertyAssignment &&
|
||||
node.parent.kind !== SyntaxKind.CallExpression &&
|
||||
node.parent.kind !== SyntaxKind.ArrayLiteralExpression) {
|
||||
// 1. Methods will emit the comments as part of emitting method declaration
|
||||
|
||||
const { kind, parent } = node;
|
||||
if (kind !== SyntaxKind.MethodDeclaration &&
|
||||
kind !== SyntaxKind.MethodSignature &&
|
||||
parent &&
|
||||
parent.kind !== SyntaxKind.PropertyAssignment &&
|
||||
parent.kind !== SyntaxKind.CallExpression &&
|
||||
parent.kind !== SyntaxKind.ArrayLiteralExpression) {
|
||||
// 1. Methods will emit comments at their assignment declaration sites.
|
||||
//
|
||||
// 2. If the function is a property of object literal, emitting leading-comments
|
||||
// is done by emitNodeWithoutSourceMap which then call this function.
|
||||
// In particular, we would like to avoid emit comments twice in following case:
|
||||
// For example:
|
||||
// is done by emitNodeWithoutSourceMap which then call this function.
|
||||
// In particular, we would like to avoid emit comments twice in following case:
|
||||
//
|
||||
// var obj = {
|
||||
// id:
|
||||
// /*comment*/ () => void
|
||||
// }
|
||||
|
||||
//
|
||||
// 3. If the function is an argument in call expression, emitting of comments will be
|
||||
// taken care of in emit list of arguments inside of emitCallexpression
|
||||
// taken care of in emit list of arguments inside of 'emitCallExpression'.
|
||||
//
|
||||
// 4. If the function is in an array literal, 'emitLinePreservingList' will take care
|
||||
// of leading comments.
|
||||
emitLeadingComments(node);
|
||||
}
|
||||
|
||||
@ -4325,12 +4329,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
emitSignatureAndBody(node);
|
||||
if (modulekind !== ModuleKind.ES6 && node.kind === SyntaxKind.FunctionDeclaration && node.parent === currentSourceFile && node.name) {
|
||||
if (modulekind !== ModuleKind.ES6 && kind === SyntaxKind.FunctionDeclaration && parent === currentSourceFile && node.name) {
|
||||
emitExportMemberAssignments((<FunctionDeclaration>node).name);
|
||||
}
|
||||
|
||||
emitEnd(node);
|
||||
if (node.kind !== SyntaxKind.MethodDeclaration && node.kind !== SyntaxKind.MethodSignature) {
|
||||
if (kind !== SyntaxKind.MethodDeclaration && kind !== SyntaxKind.MethodSignature) {
|
||||
emitTrailingComments(node);
|
||||
}
|
||||
}
|
||||
|
||||
25
tests/baselines/reference/decoratorOnClassMethodOverload2.js
Normal file
25
tests/baselines/reference/decoratorOnClassMethodOverload2.js
Normal file
@ -0,0 +1,25 @@
|
||||
//// [decoratorOnClassMethodOverload2.ts]
|
||||
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
|
||||
class C {
|
||||
method()
|
||||
@dec
|
||||
method() { }
|
||||
}
|
||||
|
||||
//// [decoratorOnClassMethodOverload2.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.method = function () { };
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "method", null);
|
||||
return C;
|
||||
}());
|
||||
@ -0,0 +1,24 @@
|
||||
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethodOverload2.ts ===
|
||||
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
>dec : Symbol(dec, Decl(decoratorOnClassMethodOverload2.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(decoratorOnClassMethodOverload2.ts, 0, 21))
|
||||
>target : Symbol(target, Decl(decoratorOnClassMethodOverload2.ts, 0, 24))
|
||||
>propertyKey : Symbol(propertyKey, Decl(decoratorOnClassMethodOverload2.ts, 0, 36))
|
||||
>descriptor : Symbol(descriptor, Decl(decoratorOnClassMethodOverload2.ts, 0, 57))
|
||||
>TypedPropertyDescriptor : Symbol(TypedPropertyDescriptor, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(decoratorOnClassMethodOverload2.ts, 0, 21))
|
||||
>TypedPropertyDescriptor : Symbol(TypedPropertyDescriptor, Decl(lib.d.ts, --, --))
|
||||
>T : Symbol(T, Decl(decoratorOnClassMethodOverload2.ts, 0, 21))
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(decoratorOnClassMethodOverload2.ts, 0, 126))
|
||||
|
||||
method()
|
||||
>method : Symbol(method, Decl(decoratorOnClassMethodOverload2.ts, 2, 9), Decl(decoratorOnClassMethodOverload2.ts, 3, 12))
|
||||
|
||||
@dec
|
||||
>dec : Symbol(dec, Decl(decoratorOnClassMethodOverload2.ts, 0, 0))
|
||||
|
||||
method() { }
|
||||
>method : Symbol(method, Decl(decoratorOnClassMethodOverload2.ts, 2, 9), Decl(decoratorOnClassMethodOverload2.ts, 3, 12))
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethodOverload2.ts ===
|
||||
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
>T : T
|
||||
>target : any
|
||||
>propertyKey : string
|
||||
>descriptor : TypedPropertyDescriptor<T>
|
||||
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
|
||||
>T : T
|
||||
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
|
||||
>T : T
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
method()
|
||||
>method : () => any
|
||||
|
||||
@dec
|
||||
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
|
||||
method() { }
|
||||
>method : () => any
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
// @target: ES5
|
||||
// @experimentaldecorators: true
|
||||
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
|
||||
class C {
|
||||
method()
|
||||
@dec
|
||||
method() { }
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user