diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 0b363b00aa7a1..48f9dd32aafe7 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -5307,10 +5307,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi function emitDecoratorsOfConstructor(node: ClassLikeDeclaration) { const decorators = node.decorators; const constructor = getFirstConstructorWithBody(node); - const hasDecoratedParameters = constructor && forEach(constructor.parameters, nodeIsDecorated); + const firstParameterDecorator = constructor && forEach(constructor.parameters, parameter => parameter.decorators); // skip decoration of the constructor if neither it nor its parameters are decorated - if (!decorators && !hasDecoratedParameters) { + if (!decorators && !firstParameterDecorator) { return; } @@ -5326,28 +5326,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // writeLine(); - emitStart(node); + emitStart(node.decorators || firstParameterDecorator); emitDeclarationName(node); write(" = __decorate(["); increaseIndent(); writeLine(); const decoratorCount = decorators ? decorators.length : 0; - let argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, decorator => { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); - - argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); + let argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, + decorator => emit(decorator.expression)); + if (firstParameterDecorator) { + argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); + } emitSerializedTypeMetadata(node, /*leadingComma*/ argumentsWritten >= 0); decreaseIndent(); writeLine(); write("], "); emitDeclarationName(node); - write(");"); - emitEnd(node); + write(")"); + emitEnd(node.decorators || firstParameterDecorator); + write(";"); writeLine(); } @@ -5363,11 +5362,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi continue; } - // skip a member if it or any of its parameters are not decorated - if (!nodeOrChildIsDecorated(member)) { - continue; - } - // skip an accessor declaration if it is not the first accessor let decorators: NodeArray; let functionLikeMember: FunctionLikeDeclaration; @@ -5394,6 +5388,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi functionLikeMember = member; } } + const firstParameterDecorator = functionLikeMember && forEach(functionLikeMember.parameters, parameter => parameter.decorators); + + // skip a member if it or any of its parameters are not decorated + if (!decorators && !firstParameterDecorator) { + continue; + } // Emit the call to __decorate. Given the following: // @@ -5427,29 +5427,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi // writeLine(); - emitStart(member); + emitStart(decorators || firstParameterDecorator); write("__decorate(["); increaseIndent(); writeLine(); const decoratorCount = decorators ? decorators.length : 0; - let argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, decorator => { - emitStart(decorator); - emit(decorator.expression); - emitEnd(decorator); - }); + let argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, + decorator => emit(decorator.expression)); - argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); + if (firstParameterDecorator) { + argumentsWritten += emitDecoratorsOfParameters(functionLikeMember, argumentsWritten > 0); + } emitSerializedTypeMetadata(member, argumentsWritten > 0); decreaseIndent(); writeLine(); write("], "); - emitStart(member.name); emitClassMemberPrefix(node, member); write(", "); emitExpressionForPropertyName(member.name); - emitEnd(member.name); if (languageVersion > ScriptTarget.ES3) { if (member.kind !== SyntaxKind.PropertyDeclaration) { @@ -5464,8 +5461,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } - write(");"); - emitEnd(member); + write(")"); + emitEnd(decorators || firstParameterDecorator); + write(";"); writeLine(); } } @@ -5478,11 +5476,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi if (nodeIsDecorated(parameter)) { const decorators = parameter.decorators; argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, decorator => { - emitStart(decorator); write(`__param(${parameterIndex}, `); emit(decorator.expression); write(")"); - emitEnd(decorator); }); leadingComma = true; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index e917ef9bfe6e1..fda1b1015d98f 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4902,7 +4902,7 @@ namespace ts { if (!decorators) { decorators = >[]; - decorators.pos = scanner.getStartPos(); + decorators.pos = decoratorStart; } const decorator = createNode(SyntaxKind.Decorator, decoratorStart); diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index d29e32135882e..fb2aceb26e05f 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -251,7 +251,8 @@ namespace ts { } function emitStart(range: TextRange) { - emitPos(range.pos !== -1 ? skipTrivia(currentSourceFile.text, range.pos) : -1); + const rangeHasDecorators = !!(range as Node).decorators; + emitPos(range.pos !== -1 ? skipTrivia(currentSourceFile.text, rangeHasDecorators ? (range as Node).decorators.end : range.pos) : -1); } function emitEnd(range: TextRange) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 44c1c0d2d5993..60118604c5058 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -906,23 +906,6 @@ namespace ts { return false; } - export function childIsDecorated(node: Node): boolean { - switch (node.kind) { - case SyntaxKind.ClassDeclaration: - return forEach((node).members, nodeOrChildIsDecorated); - - case SyntaxKind.MethodDeclaration: - case SyntaxKind.SetAccessor: - return forEach((node).parameters, nodeIsDecorated); - } - - return false; - } - - export function nodeOrChildIsDecorated(node: Node): boolean { - return nodeIsDecorated(node) || childIsDecorated(node); - } - export function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression { return node.kind === SyntaxKind.PropertyAccessExpression; } diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index e307b21979e26..31ab5d2adec5d 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -16,7 +16,7 @@ namespace ts.BreakpointResolver { let tokenAtLocation = getTokenAtPosition(sourceFile, position); let lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart()).line > lineOfPosition) { + if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart(sourceFile)).line > lineOfPosition) { // Get previous token if the token is returned starts on new line // eg: let x =10; |--- cursor is here // let y = 10; @@ -39,16 +39,23 @@ namespace ts.BreakpointResolver { return spanInNode(tokenAtLocation); function textSpan(startNode: Node, endNode?: Node) { - return createTextSpanFromBounds(startNode.getStart(), (endNode || startNode).getEnd()); + const start = startNode.decorators ? + skipTrivia(sourceFile.text, startNode.decorators.end) : + startNode.getStart(sourceFile); + return createTextSpanFromBounds(start, (endNode || startNode).getEnd()); } function spanInNodeIfStartsOnSameLine(node: Node, otherwiseOnNode?: Node): TextSpan { - if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart()).line) { + if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line) { return spanInNode(node); } return spanInNode(otherwiseOnNode); } + function spanInNodeArray(nodeArray: NodeArray) { + return createTextSpanFromBounds(skipTrivia(sourceFile.text, nodeArray.pos), nodeArray.end); + } + function spanInPreviousNode(node: Node): TextSpan { return spanInNode(findPrecedingToken(node.pos, sourceFile)); } @@ -65,6 +72,11 @@ namespace ts.BreakpointResolver { return spanInPreviousNode(node); } + if (node.parent.kind === SyntaxKind.Decorator) { + // Set breakpoint on the decorator emit + return spanInNode(node.parent); + } + if (node.parent.kind === SyntaxKind.ForStatement) { // For now lets set the span on this expression, fix it later return textSpan(node); @@ -207,6 +219,9 @@ namespace ts.BreakpointResolver { // span in statement return spanInNode((node).statement); + case SyntaxKind.Decorator: + return spanInNodeArray(node.parent.decorators); + // No breakpoint in interface, type alias case SyntaxKind.InterfaceDeclaration: case SyntaxKind.TypeAliasDeclaration: diff --git a/tests/baselines/reference/bpSpan_decorators.baseline b/tests/baselines/reference/bpSpan_decorators.baseline new file mode 100644 index 0000000000000..f6bb700e0989f --- /dev/null +++ b/tests/baselines/reference/bpSpan_decorators.baseline @@ -0,0 +1,384 @@ + +1 >declare function ClassDecorator1(target: Function): void; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (0 to 57) SpanInfo: undefined +-------------------------------- +2 >declare function ClassDecorator2(x: number): (target: Function) => void; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (58 to 130) SpanInfo: undefined +-------------------------------- +3 >declare function PropertyDecorator1(target: Object, key: string | symbol, descriptor?: PropertyDescriptor): void; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (131 to 244) SpanInfo: undefined +-------------------------------- +4 >declare function PropertyDecorator2(x: number): (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (245 to 373) SpanInfo: undefined +-------------------------------- +5 >declare function ParameterDecorator1(target: Object, key: string | symbol, paramIndex: number): void; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (374 to 475) SpanInfo: undefined +-------------------------------- +6 >declare function ParameterDecorator2(x: number): (target: Object, key: string | symbol, paramIndex: number) => void; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (476 to 592) SpanInfo: undefined +-------------------------------- +7 > + + ~ => Pos: (593 to 593) SpanInfo: undefined +-------------------------------- +8 >@ClassDecorator1 + + ~~~~~~~~~~~~~~~~~ => Pos: (594 to 610) SpanInfo: {"start":594,"length":37} + >@ClassDecorator1 + >@ClassDecorator2(10) + >:=> (line 8, col 0) to (line 9, col 20) +-------------------------------- +9 >@ClassDecorator2(10) + + ~~~~~~~~~~~~~~~~~~~~~ => Pos: (611 to 631) SpanInfo: {"start":594,"length":37} + >@ClassDecorator1 + >@ClassDecorator2(10) + >:=> (line 8, col 0) to (line 9, col 20) +-------------------------------- +10 >class Greeter { + + ~~~~~~~~~~~~~~~~ => Pos: (632 to 647) SpanInfo: {"start":632,"length":914} + >class Greeter { + > constructor( + > @ParameterDecorator1 + > @ParameterDecorator2(20) + > public greeting: string, + > + > @ParameterDecorator1 + > @ParameterDecorator2(30) + > ...b: string[]) { + > } + > + > @PropertyDecorator1 + > @PropertyDecorator2(40) + > greet() { + > return "

" + this.greeting + "

"; + > } + > + > @PropertyDecorator1 + > @PropertyDecorator2(50) + > private x: string; + > + > @PropertyDecorator1 + > @PropertyDecorator2(60) + > private static x1: number = 10; + > + > private fn( + > @ParameterDecorator1 + > @ParameterDecorator2(70) + > x: number) { + > return this.greeting; + > } + > + > @PropertyDecorator1 + > @PropertyDecorator2(80) + > get greetings() { + > return this.greeting; + > } + > + > set greetings( + > @ParameterDecorator1 + > @ParameterDecorator2(90) + > greetings: string) { + > this.greeting = greetings; + > } + >} + >:=> (line 10, col 0) to (line 54, col 1) +-------------------------------- +11 > constructor( + + ~~~~~~~~~~~~~~~~~ => Pos: (648 to 664) SpanInfo: {"start":857,"length":1} + >} + >:=> (line 19, col 4) to (line 19, col 5) +-------------------------------- +12 > @ParameterDecorator1 + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (665 to 693) SpanInfo: {"start":673,"length":53} + >@ParameterDecorator1 + > @ParameterDecorator2(20) + >:=> (line 12, col 8) to (line 13, col 32) +-------------------------------- +13 > @ParameterDecorator2(20) + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (694 to 726) SpanInfo: {"start":673,"length":53} + >@ParameterDecorator1 + > @ParameterDecorator2(20) + >:=> (line 12, col 8) to (line 13, col 32) +-------------------------------- +14 > public greeting: string, + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (727 to 759) SpanInfo: {"start":735,"length":23} + >public greeting: string + >:=> (line 14, col 8) to (line 14, col 31) +-------------------------------- +15 > + + ~ => Pos: (760 to 760) SpanInfo: undefined +-------------------------------- +16 > @ParameterDecorator1 + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (761 to 789) SpanInfo: {"start":769,"length":53} + >@ParameterDecorator1 + > @ParameterDecorator2(30) + >:=> (line 16, col 8) to (line 17, col 32) +-------------------------------- +17 > @ParameterDecorator2(30) + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (790 to 822) SpanInfo: {"start":769,"length":53} + >@ParameterDecorator1 + > @ParameterDecorator2(30) + >:=> (line 16, col 8) to (line 17, col 32) +-------------------------------- +18 > ...b: string[]) { + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (823 to 849) SpanInfo: {"start":835,"length":14} + >...b: string[] + >:=> (line 18, col 12) to (line 18, col 26) +18 > ...b: string[]) { + + ~~~ => Pos: (850 to 852) SpanInfo: {"start":857,"length":1} + >} + >:=> (line 19, col 4) to (line 19, col 5) +-------------------------------- +19 > } + + ~~~~~~ => Pos: (853 to 858) SpanInfo: {"start":857,"length":1} + >} + >:=> (line 19, col 4) to (line 19, col 5) +-------------------------------- +20 > + + ~ => Pos: (859 to 859) SpanInfo: undefined +-------------------------------- +21 > @PropertyDecorator1 + + ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (860 to 883) SpanInfo: {"start":864,"length":47} + >@PropertyDecorator1 + > @PropertyDecorator2(40) + >:=> (line 21, col 4) to (line 22, col 27) +-------------------------------- +22 > @PropertyDecorator2(40) + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (884 to 911) SpanInfo: {"start":864,"length":47} + >@PropertyDecorator1 + > @PropertyDecorator2(40) + >:=> (line 21, col 4) to (line 22, col 27) +-------------------------------- +23 > greet() { + + ~~~~~~~~~~~ => Pos: (912 to 922) SpanInfo: {"start":916,"length":64} + >greet() { + > return "

" + this.greeting + "

"; + > } + >:=> (line 23, col 4) to (line 25, col 5) +23 > greet() { + + ~~~ => Pos: (923 to 925) SpanInfo: {"start":934,"length":39} + >return "

" + this.greeting + "

" + >:=> (line 24, col 8) to (line 24, col 47) +-------------------------------- +24 > return "

" + this.greeting + "

"; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (926 to 974) SpanInfo: {"start":934,"length":39} + >return "

" + this.greeting + "

" + >:=> (line 24, col 8) to (line 24, col 47) +-------------------------------- +25 > } + + ~~~~~~ => Pos: (975 to 980) SpanInfo: {"start":979,"length":1} + >} + >:=> (line 25, col 4) to (line 25, col 5) +-------------------------------- +26 > + + ~ => Pos: (981 to 981) SpanInfo: undefined +-------------------------------- +27 > @PropertyDecorator1 + + ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (982 to 1005) SpanInfo: {"start":986,"length":47} + >@PropertyDecorator1 + > @PropertyDecorator2(50) + >:=> (line 27, col 4) to (line 28, col 27) +-------------------------------- +28 > @PropertyDecorator2(50) + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1006 to 1033) SpanInfo: {"start":986,"length":47} + >@PropertyDecorator1 + > @PropertyDecorator2(50) + >:=> (line 27, col 4) to (line 28, col 27) +-------------------------------- +29 > private x: string; + + ~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1034 to 1056) SpanInfo: undefined +-------------------------------- +30 > + + ~ => Pos: (1057 to 1057) SpanInfo: undefined +-------------------------------- +31 > @PropertyDecorator1 + + ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1058 to 1081) SpanInfo: {"start":1062,"length":47} + >@PropertyDecorator1 + > @PropertyDecorator2(60) + >:=> (line 31, col 4) to (line 32, col 27) +-------------------------------- +32 > @PropertyDecorator2(60) + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1082 to 1109) SpanInfo: {"start":1062,"length":47} + >@PropertyDecorator1 + > @PropertyDecorator2(60) + >:=> (line 31, col 4) to (line 32, col 27) +-------------------------------- +33 > private static x1: number = 10; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1110 to 1145) SpanInfo: {"start":1114,"length":31} + >private static x1: number = 10; + >:=> (line 33, col 4) to (line 33, col 35) +-------------------------------- +34 > + + ~ => Pos: (1146 to 1146) SpanInfo: undefined +-------------------------------- +35 > private fn( + + ~~~~~~~~~~~~~~~~ => Pos: (1147 to 1162) SpanInfo: {"start":1151,"length":130} + >private fn( + > @ParameterDecorator1 + > @ParameterDecorator2(70) + > x: number) { + > return this.greeting; + > } + >:=> (line 35, col 4) to (line 40, col 5) +-------------------------------- +36 > @ParameterDecorator1 + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1163 to 1191) SpanInfo: {"start":1171,"length":53} + >@ParameterDecorator1 + > @ParameterDecorator2(70) + >:=> (line 36, col 8) to (line 37, col 32) +-------------------------------- +37 > @ParameterDecorator2(70) + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1192 to 1224) SpanInfo: {"start":1171,"length":53} + >@ParameterDecorator1 + > @ParameterDecorator2(70) + >:=> (line 36, col 8) to (line 37, col 32) +-------------------------------- +38 > x: number) { + + ~~~~~~~~~~~~~~~~~~~~~ => Pos: (1225 to 1245) SpanInfo: {"start":1254,"length":20} + >return this.greeting + >:=> (line 39, col 8) to (line 39, col 28) +-------------------------------- +39 > return this.greeting; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1246 to 1275) SpanInfo: {"start":1254,"length":20} + >return this.greeting + >:=> (line 39, col 8) to (line 39, col 28) +-------------------------------- +40 > } + + ~~~~~~ => Pos: (1276 to 1281) SpanInfo: {"start":1280,"length":1} + >} + >:=> (line 40, col 4) to (line 40, col 5) +-------------------------------- +41 > + + ~ => Pos: (1282 to 1282) SpanInfo: undefined +-------------------------------- +42 > @PropertyDecorator1 + + ~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1283 to 1306) SpanInfo: {"start":1287,"length":47} + >@PropertyDecorator1 + > @PropertyDecorator2(80) + >:=> (line 42, col 4) to (line 43, col 27) +-------------------------------- +43 > @PropertyDecorator2(80) + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1307 to 1334) SpanInfo: {"start":1287,"length":47} + >@PropertyDecorator1 + > @PropertyDecorator2(80) + >:=> (line 42, col 4) to (line 43, col 27) +-------------------------------- +44 > get greetings() { + + ~~~~~~~~~~~~~~~~~~~ => Pos: (1335 to 1353) SpanInfo: {"start":1339,"length":53} + >get greetings() { + > return this.greeting; + > } + >:=> (line 44, col 4) to (line 46, col 5) +44 > get greetings() { + + ~~~ => Pos: (1354 to 1356) SpanInfo: {"start":1365,"length":20} + >return this.greeting + >:=> (line 45, col 8) to (line 45, col 28) +-------------------------------- +45 > return this.greeting; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1357 to 1386) SpanInfo: {"start":1365,"length":20} + >return this.greeting + >:=> (line 45, col 8) to (line 45, col 28) +-------------------------------- +46 > } + + ~~~~~~ => Pos: (1387 to 1392) SpanInfo: {"start":1391,"length":1} + >} + >:=> (line 46, col 4) to (line 46, col 5) +-------------------------------- +47 > + + ~ => Pos: (1393 to 1393) SpanInfo: undefined +-------------------------------- +48 > set greetings( + + ~~~~~~~~~~~~~~~~~~~ => Pos: (1394 to 1412) SpanInfo: {"start":1398,"length":146} + >set greetings( + > @ParameterDecorator1 + > @ParameterDecorator2(90) + > greetings: string) { + > this.greeting = greetings; + > } + >:=> (line 48, col 4) to (line 53, col 5) +-------------------------------- +49 > @ParameterDecorator1 + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1413 to 1441) SpanInfo: {"start":1421,"length":53} + >@ParameterDecorator1 + > @ParameterDecorator2(90) + >:=> (line 49, col 8) to (line 50, col 32) +-------------------------------- +50 > @ParameterDecorator2(90) + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1442 to 1474) SpanInfo: {"start":1421,"length":53} + >@ParameterDecorator1 + > @ParameterDecorator2(90) + >:=> (line 49, col 8) to (line 50, col 32) +-------------------------------- +51 > greetings: string) { + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1475 to 1503) SpanInfo: {"start":1512,"length":25} + >this.greeting = greetings + >:=> (line 52, col 8) to (line 52, col 33) +-------------------------------- +52 > this.greeting = greetings; + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (1504 to 1538) SpanInfo: {"start":1512,"length":25} + >this.greeting = greetings + >:=> (line 52, col 8) to (line 52, col 33) +-------------------------------- +53 > } + + ~~~~~~ => Pos: (1539 to 1544) SpanInfo: {"start":1543,"length":1} + >} + >:=> (line 53, col 4) to (line 53, col 5) +-------------------------------- +54 >} + ~ => Pos: (1545 to 1545) SpanInfo: {"start":1545,"length":1} + >} + >:=> (line 54, col 0) to (line 54, col 1) \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDecorators.js.map b/tests/baselines/reference/sourceMapValidationDecorators.js.map index 4a8b3258659e0..4af925231cd27 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.js.map +++ b/tests/baselines/reference/sourceMapValidationDecorators.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDecorators.js.map] -{"version":3,"file":"sourceMapValidationDecorators.js","sourceRoot":"","sources":["sourceMapValidationDecorators.ts"],"names":["Greeter","Greeter.constructor","Greeter.greet","Greeter.fn","Greeter.greetings"],"mappings":";;;;;;;;;AAOA;IAGIA,iBAGSA,QAAgBA;QAEvBC,WAEcA;aAFdA,WAEcA,CAFdA,sBAEcA,CAFdA,IAEcA;YAFdA,0BAEcA;;QAJPA,aAAQA,GAARA,QAAQA,CAAQA;IAKzBA,CAACA;IAIDD,uBAAKA,GAFLA;QAGIE,MAAMA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,QAAQA,GAAGA,OAAOA,CAACA;IAC5CA,CAACA;IAUOF,oBAAEA,GAAVA,UAGEA,CAASA;QACPG,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;IACzBA,CAACA;IAEDH,sBAEIA,8BAASA;aAFbA;YAGII,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;QACzBA,CAACA;aAEDJ,UAGEA,SAAiBA;YACfI,IAAIA,CAACA,QAAQA,GAAGA,SAASA,CAACA;QAC9BA,CAACA;;;OAPAJ;IAbcA,UAAEA,GAAWA,EAAEA,CAACA;IAZ/BA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;OACvBA,0BAAKA,QAEJA;IAEDA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;OACfA,sBAACA,UAASA;IAMlBA;QACEA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;OAFlBA,uBAAEA,QAKTA;IAEDA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;QAMrBA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;OANtBA,8BAASA,QAEZA;IAfDA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;OACRA,aAAEA,UAAcA;IAzBnCA;QAACA,eAAeA;QACfA,eAAeA,CAACA,EAAEA,CAACA;QAGdA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;QAGxBA,WAACA,mBAAmBA,CAAAA;QACpBA,WAACA,mBAAmBA,CAACA,EAAEA,CAACA,CAAAA;gBAqC7BA;IAADA,cAACA;AAADA,CAACA,AA9CD,IA8CC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDecorators.js","sourceRoot":"","sources":["sourceMapValidationDecorators.ts"],"names":["Greeter","Greeter.constructor","Greeter.greet","Greeter.fn","Greeter.greetings"],"mappings":";;;;;;;;;AASA;IACIA,iBAGSA,QAAgBA;QAIvBC,WAAcA;aAAdA,WAAcA,CAAdA,sBAAcA,CAAdA,IAAcA;YAAdA,0BAAcA;;QAJPA,aAAQA,GAARA,QAAQA,CAAQA;IAKzBA,CAACA;IAIDD,uBAAKA,GAALA;QACIE,MAAMA,CAACA,MAAMA,GAAGA,IAAIA,CAACA,QAAQA,GAAGA,OAAOA,CAACA;IAC5CA,CAACA;IAUOF,oBAAEA,GAAVA,UAGEA,CAASA;QACPG,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;IACzBA,CAACA;IAIDH,sBAAIA,8BAASA;aAAbA;YACII,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA;QACzBA,CAACA;aAEDJ,UAGEA,SAAiBA;YACfI,IAAIA,CAACA,QAAQA,GAAGA,SAASA,CAACA;QAC9BA,CAACA;;;OAPAJ;IAbcA,UAAEA,GAAWA,EAAEA,CAACA;IAZ/BA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;wCAAAA;IAKvBA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;sCAAAA;IAQrBA;mBAACA,mBAAmBA;mBACnBA,mBAAmBA,CAACA,EAAEA,CAACA;qCAAAA;IAK1BA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;mBAMpBA,mBAAmBA;mBACnBA,mBAAmBA,CAACA,EAAEA,CAACA;4CAPHA;IAZvBA;QAACA,kBAAkBA;QAClBA,kBAAkBA,CAACA,EAAEA,CAACA;6BAAAA;IAxB3BA;QAACA,eAAeA;QACfA,eAAeA,CAACA,EAAEA,CAACA;mBAGbA,mBAAmBA;mBACnBA,mBAAmBA,CAACA,EAAEA,CAACA;mBAGvBA,mBAAmBA;mBACnBA,mBAAmBA,CAACA,EAAEA,CAACA;eARVA;IA6CpBA,cAACA;AAADA,CAACA,AA5CD,IA4CC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt index d9c8d0cc976f0..1e270c40593ac 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt @@ -27,16 +27,16 @@ sourceFile:sourceMapValidationDecorators.ts >declare function ParameterDecorator1(target: Object, key: string | symbol, paramIndex: number): void; >declare function ParameterDecorator2(x: number): (target: Object, key: string | symbol, paramIndex: number) => void; > + >@ClassDecorator1 + >@ClassDecorator2(10) > -1 >Emitted(10, 1) Source(8, 1) + SourceIndex(0) +1 >Emitted(10, 1) Source(10, 1) + SourceIndex(0) --- >>> function Greeter(greeting) { 1->^^^^ 2 > ^^^^^^^^^^^^^^^^^ 3 > ^^^^^^^^ -1->@ClassDecorator1 - >@ClassDecorator2(10) - >class Greeter { +1->class Greeter { > 2 > constructor( > @ParameterDecorator1 @@ -53,11 +53,11 @@ sourceFile:sourceMapValidationDecorators.ts 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >, > + > @ParameterDecorator1 + > @ParameterDecorator2(30) > -2 > @ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[] -1 >Emitted(12, 9) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) +2 > ...b: string[] +1 >Emitted(12, 9) Source(18, 7) + SourceIndex(0) name (Greeter.constructor) 2 >Emitted(12, 20) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) --- >>> for (var _i = 1; _i < arguments.length; _i++) { @@ -68,32 +68,24 @@ sourceFile:sourceMapValidationDecorators.ts 5 > ^ 6 > ^^^^ 1-> -2 > @ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[] +2 > ...b: string[] 3 > -4 > @ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[] +4 > ...b: string[] 5 > -6 > @ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[] -1->Emitted(13, 14) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) +6 > ...b: string[] +1->Emitted(13, 14) Source(18, 7) + SourceIndex(0) name (Greeter.constructor) 2 >Emitted(13, 25) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) -3 >Emitted(13, 26) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) +3 >Emitted(13, 26) Source(18, 7) + SourceIndex(0) name (Greeter.constructor) 4 >Emitted(13, 48) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) -5 >Emitted(13, 49) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) +5 >Emitted(13, 49) Source(18, 7) + SourceIndex(0) name (Greeter.constructor) 6 >Emitted(13, 53) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) --- >>> b[_i - 1] = arguments[_i]; 1 >^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > -2 > @ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[] -1 >Emitted(14, 13) Source(16, 7) + SourceIndex(0) name (Greeter.constructor) +2 > ...b: string[] +1 >Emitted(14, 13) Source(18, 7) + SourceIndex(0) name (Greeter.constructor) 2 >Emitted(14, 39) Source(18, 21) + SourceIndex(0) name (Greeter.constructor) --- >>> } @@ -142,7 +134,7 @@ sourceFile:sourceMapValidationDecorators.ts 3 > 1->Emitted(18, 5) Source(23, 5) + SourceIndex(0) name (Greeter) 2 >Emitted(18, 28) Source(23, 10) + SourceIndex(0) name (Greeter) -3 >Emitted(18, 31) Source(21, 5) + SourceIndex(0) name (Greeter) +3 >Emitted(18, 31) Source(23, 5) + SourceIndex(0) name (Greeter) --- >>> return "

" + this.greeting + "

"; 1->^^^^^^^^ @@ -156,9 +148,7 @@ sourceFile:sourceMapValidationDecorators.ts 9 > ^^^ 10> ^^^^^^^ 11> ^ -1->@PropertyDecorator1 - > @PropertyDecorator2(40) - > greet() { +1->greet() { > 2 > return 3 > @@ -262,12 +252,12 @@ sourceFile:sourceMapValidationDecorators.ts 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > + > @PropertyDecorator1 + > @PropertyDecorator2(80) > -2 > @PropertyDecorator1 - > @PropertyDecorator2(80) - > get +2 > get 3 > greetings -1->Emitted(24, 5) Source(42, 5) + SourceIndex(0) name (Greeter) +1->Emitted(24, 5) Source(44, 5) + SourceIndex(0) name (Greeter) 2 >Emitted(24, 27) Source(44, 9) + SourceIndex(0) name (Greeter) 3 >Emitted(24, 57) Source(44, 18) + SourceIndex(0) name (Greeter) --- @@ -275,7 +265,7 @@ sourceFile:sourceMapValidationDecorators.ts 1 >^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(25, 14) Source(42, 5) + SourceIndex(0) name (Greeter) +1 >Emitted(25, 14) Source(44, 5) + SourceIndex(0) name (Greeter) --- >>> return this.greeting; 1->^^^^^^^^^^^^ @@ -285,9 +275,7 @@ sourceFile:sourceMapValidationDecorators.ts 5 > ^ 6 > ^^^^^^^^ 7 > ^ -1->@PropertyDecorator1 - > @PropertyDecorator2(80) - > get greetings() { +1->get greetings() { > 2 > return 3 > @@ -424,23 +412,17 @@ sourceFile:sourceMapValidationDecorators.ts 5 >Emitted(37, 31) Source(22, 28) + SourceIndex(0) name (Greeter) --- >>> ], Greeter.prototype, "greet", null); -1->^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^ -1-> - > -2 > greet -3 > () { - > return "

" + this.greeting + "

"; - > } -1->Emitted(38, 8) Source(23, 5) + SourceIndex(0) name (Greeter) -2 >Emitted(38, 34) Source(23, 10) + SourceIndex(0) name (Greeter) -3 >Emitted(38, 42) Source(25, 6) + SourceIndex(0) name (Greeter) +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +1->Emitted(38, 41) Source(22, 28) + SourceIndex(0) name (Greeter) --- >>> __decorate([ 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > + > greet() { + > return "

" + this.greeting + "

"; + > } > > 1 >Emitted(39, 5) Source(27, 5) + SourceIndex(0) name (Greeter) @@ -474,89 +456,63 @@ sourceFile:sourceMapValidationDecorators.ts 5 >Emitted(41, 31) Source(28, 28) + SourceIndex(0) name (Greeter) --- >>> ], Greeter.prototype, "x", void 0); -1->^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^^^ -1-> - > private -2 > x -3 > : string; -1->Emitted(42, 8) Source(29, 13) + SourceIndex(0) name (Greeter) -2 >Emitted(42, 30) Source(29, 14) + SourceIndex(0) name (Greeter) -3 >Emitted(42, 40) Source(29, 23) + SourceIndex(0) name (Greeter) +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +1->Emitted(42, 39) Source(28, 28) + SourceIndex(0) name (Greeter) --- >>> __decorate([ 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > + > private x: string; > > @PropertyDecorator1 > @PropertyDecorator2(60) > private static x1: number = 10; > - > -1 >Emitted(43, 5) Source(35, 5) + SourceIndex(0) name (Greeter) + > private fn( + > +1 >Emitted(43, 5) Source(36, 7) + SourceIndex(0) name (Greeter) --- >>> __param(0, ParameterDecorator1), -1->^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^-> -1->private fn( - > -2 > @ -3 > ParameterDecorator1 -4 > -1->Emitted(44, 9) Source(36, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(44, 20) Source(36, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(44, 39) Source(36, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(44, 40) Source(36, 27) + SourceIndex(0) name (Greeter) +1->^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^-> +1->@ +2 > ParameterDecorator1 +1->Emitted(44, 20) Source(36, 8) + SourceIndex(0) name (Greeter) +2 >Emitted(44, 39) Source(36, 27) + SourceIndex(0) name (Greeter) --- >>> __param(0, ParameterDecorator2(70)) -1->^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^ -6 > ^ -7 > ^ +1->^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ 1-> - > -2 > @ -3 > ParameterDecorator2 -4 > ( -5 > 70 -6 > ) -7 > -1->Emitted(45, 9) Source(37, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(45, 20) Source(37, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(45, 39) Source(37, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(45, 40) Source(37, 28) + SourceIndex(0) name (Greeter) -5 >Emitted(45, 42) Source(37, 30) + SourceIndex(0) name (Greeter) -6 >Emitted(45, 43) Source(37, 31) + SourceIndex(0) name (Greeter) -7 >Emitted(45, 44) Source(37, 31) + SourceIndex(0) name (Greeter) + > @ +2 > ParameterDecorator2 +3 > ( +4 > 70 +5 > ) +1->Emitted(45, 20) Source(37, 8) + SourceIndex(0) name (Greeter) +2 >Emitted(45, 39) Source(37, 27) + SourceIndex(0) name (Greeter) +3 >Emitted(45, 40) Source(37, 28) + SourceIndex(0) name (Greeter) +4 >Emitted(45, 42) Source(37, 30) + SourceIndex(0) name (Greeter) +5 >Emitted(45, 43) Source(37, 31) + SourceIndex(0) name (Greeter) --- >>> ], Greeter.prototype, "fn", null); -1 >^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^ +1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > -2 > fn -3 > ( - > @ParameterDecorator1 - > @ParameterDecorator2(70) - > x: number) { - > return this.greeting; - > } -1 >Emitted(46, 8) Source(35, 13) + SourceIndex(0) name (Greeter) -2 >Emitted(46, 31) Source(35, 15) + SourceIndex(0) name (Greeter) -3 >Emitted(46, 39) Source(40, 6) + SourceIndex(0) name (Greeter) +1 >Emitted(46, 38) Source(37, 31) + SourceIndex(0) name (Greeter) --- >>> __decorate([ 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > +1 > + > x: number) { + > return this.greeting; + > } > > 1 >Emitted(47, 5) Source(42, 5) + SourceIndex(0) name (Greeter) @@ -590,63 +546,43 @@ sourceFile:sourceMapValidationDecorators.ts 5 >Emitted(49, 31) Source(43, 28) + SourceIndex(0) name (Greeter) --- >>> __param(0, ParameterDecorator1), -1->^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^-> +1->^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^-> 1-> > get greetings() { > return this.greeting; > } > > set greetings( - > -2 > @ -3 > ParameterDecorator1 -4 > -1->Emitted(50, 9) Source(49, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(50, 20) Source(49, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(50, 39) Source(49, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(50, 40) Source(49, 27) + SourceIndex(0) name (Greeter) + > @ +2 > ParameterDecorator1 +1->Emitted(50, 20) Source(49, 8) + SourceIndex(0) name (Greeter) +2 >Emitted(50, 39) Source(49, 27) + SourceIndex(0) name (Greeter) --- >>> __param(0, ParameterDecorator2(90)) -1->^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^ -6 > ^ -7 > ^ -8 > ^^^-> +1->^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^^-> 1-> - > -2 > @ -3 > ParameterDecorator2 -4 > ( -5 > 90 -6 > ) -7 > -1->Emitted(51, 9) Source(50, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(51, 20) Source(50, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(51, 39) Source(50, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(51, 40) Source(50, 28) + SourceIndex(0) name (Greeter) -5 >Emitted(51, 42) Source(50, 30) + SourceIndex(0) name (Greeter) -6 >Emitted(51, 43) Source(50, 31) + SourceIndex(0) name (Greeter) -7 >Emitted(51, 44) Source(50, 31) + SourceIndex(0) name (Greeter) + > @ +2 > ParameterDecorator2 +3 > ( +4 > 90 +5 > ) +1->Emitted(51, 20) Source(50, 8) + SourceIndex(0) name (Greeter) +2 >Emitted(51, 39) Source(50, 27) + SourceIndex(0) name (Greeter) +3 >Emitted(51, 40) Source(50, 28) + SourceIndex(0) name (Greeter) +4 >Emitted(51, 42) Source(50, 30) + SourceIndex(0) name (Greeter) +5 >Emitted(51, 43) Source(50, 31) + SourceIndex(0) name (Greeter) --- >>> ], Greeter.prototype, "greetings", null); -1->^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^ +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> -2 > greetings -3 > () { - > return this.greeting; - > } -1->Emitted(52, 8) Source(44, 9) + SourceIndex(0) name (Greeter) -2 >Emitted(52, 38) Source(44, 18) + SourceIndex(0) name (Greeter) -3 >Emitted(52, 46) Source(46, 6) + SourceIndex(0) name (Greeter) +1->Emitted(52, 45) Source(43, 28) + SourceIndex(0) name (Greeter) --- >>> __decorate([ 1 >^^^^ @@ -683,16 +619,9 @@ sourceFile:sourceMapValidationDecorators.ts 5 >Emitted(55, 31) Source(32, 28) + SourceIndex(0) name (Greeter) --- >>> ], Greeter, "x1", void 0); -1->^^^^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^^^ -1-> - > private static -2 > x1 -3 > : number = 10; -1->Emitted(56, 8) Source(33, 20) + SourceIndex(0) name (Greeter) -2 >Emitted(56, 21) Source(33, 22) + SourceIndex(0) name (Greeter) -3 >Emitted(56, 31) Source(33, 36) + SourceIndex(0) name (Greeter) +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +1->Emitted(56, 30) Source(32, 28) + SourceIndex(0) name (Greeter) --- >>> Greeter = __decorate([ 1 >^^^^ @@ -729,93 +658,83 @@ sourceFile:sourceMapValidationDecorators.ts 5 >Emitted(59, 28) Source(9, 21) + SourceIndex(0) name (Greeter) --- >>> __param(0, ParameterDecorator1), -1->^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^^-> +1->^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^-> 1-> >class Greeter { > constructor( - > -2 > @ -3 > ParameterDecorator1 -4 > -1->Emitted(60, 9) Source(12, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(60, 20) Source(12, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(60, 39) Source(12, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(60, 40) Source(12, 27) + SourceIndex(0) name (Greeter) + > @ +2 > ParameterDecorator1 +1->Emitted(60, 20) Source(12, 8) + SourceIndex(0) name (Greeter) +2 >Emitted(60, 39) Source(12, 27) + SourceIndex(0) name (Greeter) --- >>> __param(0, ParameterDecorator2(20)), -1->^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^ -6 > ^ -7 > ^ +1->^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ 1-> - > -2 > @ -3 > ParameterDecorator2 -4 > ( -5 > 20 -6 > ) -7 > -1->Emitted(61, 9) Source(13, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(61, 20) Source(13, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(61, 39) Source(13, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(61, 40) Source(13, 28) + SourceIndex(0) name (Greeter) -5 >Emitted(61, 42) Source(13, 30) + SourceIndex(0) name (Greeter) -6 >Emitted(61, 43) Source(13, 31) + SourceIndex(0) name (Greeter) -7 >Emitted(61, 44) Source(13, 31) + SourceIndex(0) name (Greeter) + > @ +2 > ParameterDecorator2 +3 > ( +4 > 20 +5 > ) +1->Emitted(61, 20) Source(13, 8) + SourceIndex(0) name (Greeter) +2 >Emitted(61, 39) Source(13, 27) + SourceIndex(0) name (Greeter) +3 >Emitted(61, 40) Source(13, 28) + SourceIndex(0) name (Greeter) +4 >Emitted(61, 42) Source(13, 30) + SourceIndex(0) name (Greeter) +5 >Emitted(61, 43) Source(13, 31) + SourceIndex(0) name (Greeter) --- >>> __param(1, ParameterDecorator1), -1 >^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^-> +1 >^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^-> 1 > > public greeting: string, > - > -2 > @ -3 > ParameterDecorator1 -4 > -1 >Emitted(62, 9) Source(16, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(62, 20) Source(16, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(62, 39) Source(16, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(62, 40) Source(16, 27) + SourceIndex(0) name (Greeter) + > @ +2 > ParameterDecorator1 +1 >Emitted(62, 20) Source(16, 8) + SourceIndex(0) name (Greeter) +2 >Emitted(62, 39) Source(16, 27) + SourceIndex(0) name (Greeter) --- >>> __param(1, ParameterDecorator2(30)) -1->^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^ -6 > ^ -7 > ^ +1->^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ 1-> - > -2 > @ -3 > ParameterDecorator2 -4 > ( -5 > 30 -6 > ) -7 > -1->Emitted(63, 9) Source(17, 7) + SourceIndex(0) name (Greeter) -2 >Emitted(63, 20) Source(17, 8) + SourceIndex(0) name (Greeter) -3 >Emitted(63, 39) Source(17, 27) + SourceIndex(0) name (Greeter) -4 >Emitted(63, 40) Source(17, 28) + SourceIndex(0) name (Greeter) -5 >Emitted(63, 42) Source(17, 30) + SourceIndex(0) name (Greeter) -6 >Emitted(63, 43) Source(17, 31) + SourceIndex(0) name (Greeter) -7 >Emitted(63, 44) Source(17, 31) + SourceIndex(0) name (Greeter) + > @ +2 > ParameterDecorator2 +3 > ( +4 > 30 +5 > ) +1->Emitted(63, 20) Source(17, 8) + SourceIndex(0) name (Greeter) +2 >Emitted(63, 39) Source(17, 27) + SourceIndex(0) name (Greeter) +3 >Emitted(63, 40) Source(17, 28) + SourceIndex(0) name (Greeter) +4 >Emitted(63, 42) Source(17, 30) + SourceIndex(0) name (Greeter) +5 >Emitted(63, 43) Source(17, 31) + SourceIndex(0) name (Greeter) --- >>> ], Greeter); -1 >^^^^^^^^^^^^^^^^ -2 > ^^^^-> -1 > +1 >^^^^^^^^^^^^^^^ +2 > ^^^^^-> +1 > +1 >Emitted(64, 16) Source(9, 21) + SourceIndex(0) name (Greeter) +--- +>>> return Greeter; +1->^^^^ +2 > ^^^^^^^^^^^^^^ +1-> + >class Greeter { + > constructor( + > @ParameterDecorator1 + > @ParameterDecorator2(20) + > public greeting: string, + > + > @ParameterDecorator1 + > @ParameterDecorator2(30) > ...b: string[]) { > } > @@ -852,13 +771,7 @@ sourceFile:sourceMapValidationDecorators.ts > greetings: string) { > this.greeting = greetings; > } - >} -1 >Emitted(64, 17) Source(54, 2) + SourceIndex(0) name (Greeter) ---- ->>> return Greeter; -1->^^^^ -2 > ^^^^^^^^^^^^^^ -1-> + > 2 > } 1->Emitted(65, 5) Source(54, 1) + SourceIndex(0) name (Greeter) 2 >Emitted(65, 19) Source(54, 2) + SourceIndex(0) name (Greeter) @@ -872,9 +785,7 @@ sourceFile:sourceMapValidationDecorators.ts 1 > 2 >} 3 > -4 > @ClassDecorator1 - > @ClassDecorator2(10) - > class Greeter { +4 > class Greeter { > constructor( > @ParameterDecorator1 > @ParameterDecorator2(20) @@ -921,7 +832,7 @@ sourceFile:sourceMapValidationDecorators.ts > } 1 >Emitted(66, 1) Source(54, 1) + SourceIndex(0) name (Greeter) 2 >Emitted(66, 2) Source(54, 2) + SourceIndex(0) name (Greeter) -3 >Emitted(66, 2) Source(8, 1) + SourceIndex(0) +3 >Emitted(66, 2) Source(10, 1) + SourceIndex(0) 4 >Emitted(66, 6) Source(54, 2) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationDecorators.js.map \ No newline at end of file diff --git a/tests/cases/fourslash/breakpointValidationDecorators.ts b/tests/cases/fourslash/breakpointValidationDecorators.ts new file mode 100644 index 0000000000000..9eb4463e00209 --- /dev/null +++ b/tests/cases/fourslash/breakpointValidationDecorators.ts @@ -0,0 +1,60 @@ +/// + +// @BaselineFile: bpSpan_decorators.baseline +// @Filename: bpSpan_decorators.ts +////declare function ClassDecorator1(target: Function): void; +////declare function ClassDecorator2(x: number): (target: Function) => void; +////declare function PropertyDecorator1(target: Object, key: string | symbol, descriptor?: PropertyDescriptor): void; +////declare function PropertyDecorator2(x: number): (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void; +////declare function ParameterDecorator1(target: Object, key: string | symbol, paramIndex: number): void; +////declare function ParameterDecorator2(x: number): (target: Object, key: string | symbol, paramIndex: number) => void; +//// +////@ClassDecorator1 +////@ClassDecorator2(10) +////class Greeter { +//// constructor( +//// @ParameterDecorator1 +//// @ParameterDecorator2(20) +//// public greeting: string, +//// +//// @ParameterDecorator1 +//// @ParameterDecorator2(30) +//// ...b: string[]) { +//// } +//// +//// @PropertyDecorator1 +//// @PropertyDecorator2(40) +//// greet() { +//// return "

" + this.greeting + "

"; +//// } +//// +//// @PropertyDecorator1 +//// @PropertyDecorator2(50) +//// private x: string; +//// +//// @PropertyDecorator1 +//// @PropertyDecorator2(60) +//// private static x1: number = 10; +//// +//// private fn( +//// @ParameterDecorator1 +//// @ParameterDecorator2(70) +//// x: number) { +//// return this.greeting; +//// } +//// +//// @PropertyDecorator1 +//// @PropertyDecorator2(80) +//// get greetings() { +//// return this.greeting; +//// } +//// +//// set greetings( +//// @ParameterDecorator1 +//// @ParameterDecorator2(90) +//// greetings: string) { +//// this.greeting = greetings; +//// } +////} + +verify.baselineCurrentFileBreakpointLocations(); \ No newline at end of file