-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix metadata serialization for invalid jsdoc types (#37836)
- Loading branch information
Showing
6 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
tests/baselines/reference/decoratorMetadata-jsdoc.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
tests/cases/conformance/decorators/decoratorMetadata-jsdoc.ts(5,9): error TS8020: JSDoc types can only be used inside documentation comments. | ||
tests/cases/conformance/decorators/decoratorMetadata-jsdoc.ts(7,9): error TS8020: JSDoc types can only be used inside documentation comments. | ||
tests/cases/conformance/decorators/decoratorMetadata-jsdoc.ts(9,9): error TS8020: JSDoc types can only be used inside documentation comments. | ||
|
||
|
||
==== tests/cases/conformance/decorators/decoratorMetadata-jsdoc.ts (3 errors) ==== | ||
declare var decorator: any; | ||
|
||
class X { | ||
@decorator() | ||
a?: string?; | ||
~~~~~~~ | ||
!!! error TS8020: JSDoc types can only be used inside documentation comments. | ||
@decorator() | ||
b?: string!; | ||
~~~~~~~ | ||
!!! error TS8020: JSDoc types can only be used inside documentation comments. | ||
@decorator() | ||
c?: *; | ||
~ | ||
!!! error TS8020: JSDoc types can only be used inside documentation comments. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//// [decoratorMetadata-jsdoc.ts] | ||
declare var decorator: any; | ||
|
||
class X { | ||
@decorator() | ||
a?: string?; | ||
@decorator() | ||
b?: string!; | ||
@decorator() | ||
c?: *; | ||
} | ||
|
||
//// [decoratorMetadata-jsdoc.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 __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
var X = /** @class */ (function () { | ||
function X() { | ||
} | ||
__decorate([ | ||
decorator(), | ||
__metadata("design:type", String) | ||
], X.prototype, "a", void 0); | ||
__decorate([ | ||
decorator(), | ||
__metadata("design:type", String) | ||
], X.prototype, "b", void 0); | ||
__decorate([ | ||
decorator(), | ||
__metadata("design:type", Object) | ||
], X.prototype, "c", void 0); | ||
return X; | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
=== tests/cases/conformance/decorators/decoratorMetadata-jsdoc.ts === | ||
declare var decorator: any; | ||
>decorator : Symbol(decorator, Decl(decoratorMetadata-jsdoc.ts, 0, 11)) | ||
|
||
class X { | ||
>X : Symbol(X, Decl(decoratorMetadata-jsdoc.ts, 0, 27)) | ||
|
||
@decorator() | ||
>decorator : Symbol(decorator, Decl(decoratorMetadata-jsdoc.ts, 0, 11)) | ||
|
||
a?: string?; | ||
>a : Symbol(X.a, Decl(decoratorMetadata-jsdoc.ts, 2, 9)) | ||
|
||
@decorator() | ||
>decorator : Symbol(decorator, Decl(decoratorMetadata-jsdoc.ts, 0, 11)) | ||
|
||
b?: string!; | ||
>b : Symbol(X.b, Decl(decoratorMetadata-jsdoc.ts, 4, 16)) | ||
|
||
@decorator() | ||
>decorator : Symbol(decorator, Decl(decoratorMetadata-jsdoc.ts, 0, 11)) | ||
|
||
c?: *; | ||
>c : Symbol(X.c, Decl(decoratorMetadata-jsdoc.ts, 6, 16)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
=== tests/cases/conformance/decorators/decoratorMetadata-jsdoc.ts === | ||
declare var decorator: any; | ||
>decorator : any | ||
|
||
class X { | ||
>X : X | ||
|
||
@decorator() | ||
>decorator() : any | ||
>decorator : any | ||
|
||
a?: string?; | ||
>a : string | ||
|
||
@decorator() | ||
>decorator() : any | ||
>decorator : any | ||
|
||
b?: string!; | ||
>b : string | ||
|
||
@decorator() | ||
>decorator() : any | ||
>decorator : any | ||
|
||
c?: *; | ||
>c : any | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/cases/conformance/decorators/decoratorMetadata-jsdoc.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// @experimentalDecorators: true | ||
// @emitDecoratorMetadata: true | ||
// @target: es5 | ||
// @module: commonjs | ||
declare var decorator: any; | ||
|
||
class X { | ||
@decorator() | ||
a?: string?; | ||
@decorator() | ||
b?: string!; | ||
@decorator() | ||
c?: *; | ||
} |