diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7f20c54212..9ed3ca55e1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9871,31 +9871,39 @@ namespace ts { } // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (returnType && (returnType === voidType || isTypeAny(returnType))) { - return; - } - - // if return type is not specified then we'll do the check only if 'noImplicitReturns' option is set - if (!returnType && !compilerOptions.noImplicitReturns) { + if (returnType === voidType || isTypeAny(returnType)) { return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - // also if HasImplicitReturnValue flags is not set this means that all codepaths in function body end with return of throw + // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw if (nodeIsMissing(func.body) || func.body.kind !== SyntaxKind.Block || !(func.flags & NodeFlags.HasImplicitReturn)) { return; } - if (!returnType || func.flags & NodeFlags.HasExplicitReturn) { - if (compilerOptions.noImplicitReturns) { - error(func.type || func, Diagnostics.Not_all_code_paths_return_a_value); - } - } - else { - // This function does not conform to the specification. + const hasExplicitReturn = func.flags & NodeFlags.HasExplicitReturn; + + if (returnType && !hasExplicitReturn) { + // minimal check: function has syntactic return type annotation and no explicit return statements in the body + // this function does not conform to the specification. // NOTE: having returnType !== undefined is a precondition for entering this branch so func.type will always be present error(func.type, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } + else if (compilerOptions.noImplicitReturns) { + if (!returnType) { + // If return type annotation is omitted check if function has any explicit return statements. + // If it does not have any - its inferred return type is void - don't do any checks. + // Otherwise get inferred return type from function body and report error only if it is not void / anytype + const inferredReturnType = hasExplicitReturn + ? getReturnTypeOfSignature(getSignatureFromDeclaration(func)) + : voidType; + + if (inferredReturnType === voidType || isTypeAny(inferredReturnType)) { + return; + } + } + error(func.type || func, Diagnostics.Not_all_code_paths_return_a_value); + } } function checkFunctionExpressionOrObjectLiteralMethod(node: FunctionExpression | MethodDeclaration, contextualMapper?: TypeMapper): Type { @@ -12119,8 +12127,8 @@ namespace ts { const symbol = getSymbolOfNode(node); const localSymbol = node.localSymbol || symbol; - // Since the javascript won't do semantic analysis like typescript, - // if the javascript file comes before the typescript file and both contain same name functions, + // Since the javascript won't do semantic analysis like typescript, + // if the javascript file comes before the typescript file and both contain same name functions, // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. const firstDeclaration = forEach(localSymbol.declarations, // Get first non javascript function declaration @@ -14370,6 +14378,7 @@ namespace ts { emitExtends = false; emitDecorate = false; emitParam = false; + emitAwaiter = false; potentialThisCollisions.length = 0; forEach(node.statements, checkSourceElement); diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 00d35c3d1c..88847999a4 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -5292,10 +5292,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; } @@ -5311,28 +5311,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(); } @@ -5348,11 +5347,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; @@ -5379,6 +5373,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: // @@ -5412,29 +5412,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) { @@ -5449,8 +5446,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } } - write(");"); - emitEnd(member); + write(")"); + emitEnd(decorators || firstParameterDecorator); + write(";"); writeLine(); } } @@ -5463,11 +5461,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 e917ef9bfe..fda1b1015d 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 e5e4d8ca91..d98dc233c1 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -230,7 +230,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 44c1c0d2d5..60118604c5 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 e307b21979..31ab5d2ade 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/asyncMultiFile.js b/tests/baselines/reference/asyncMultiFile.js new file mode 100644 index 0000000000..e93dc58625 --- /dev/null +++ b/tests/baselines/reference/asyncMultiFile.js @@ -0,0 +1,26 @@ +//// [tests/cases/conformance/async/es6/asyncMultiFile.ts] //// + +//// [a.ts] +async function f() {} +//// [b.ts] +function g() { } + +//// [a.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) { + return new Promise(function (resolve, reject) { + generator = generator.call(thisArg, _arguments); + function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); } + function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } } + function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } } + function step(verb, value) { + var result = generator[verb](value); + result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject); + } + step("next", void 0); + }); +}; +function f() { + return __awaiter(this, void 0, Promise, function* () { }); +} +//// [b.js] +function g() { } diff --git a/tests/baselines/reference/asyncMultiFile.symbols b/tests/baselines/reference/asyncMultiFile.symbols new file mode 100644 index 0000000000..790ceafef8 --- /dev/null +++ b/tests/baselines/reference/asyncMultiFile.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es6/a.ts === +async function f() {} +>f : Symbol(f, Decl(a.ts, 0, 0)) + +=== tests/cases/conformance/async/es6/b.ts === +function g() { } +>g : Symbol(g, Decl(b.ts, 0, 0)) + diff --git a/tests/baselines/reference/asyncMultiFile.types b/tests/baselines/reference/asyncMultiFile.types new file mode 100644 index 0000000000..70eebc0577 --- /dev/null +++ b/tests/baselines/reference/asyncMultiFile.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es6/a.ts === +async function f() {} +>f : () => Promise + +=== tests/cases/conformance/async/es6/b.ts === +function g() { } +>g : () => void + diff --git a/tests/baselines/reference/bpSpan_decorators.baseline b/tests/baselines/reference/bpSpan_decorators.baseline new file mode 100644 index 0000000000..f6bb700e09 --- /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/reachabilityChecks6.errors.txt b/tests/baselines/reference/reachabilityChecks6.errors.txt index 5b78891afb..38e72def8c 100644 --- a/tests/baselines/reference/reachabilityChecks6.errors.txt +++ b/tests/baselines/reference/reachabilityChecks6.errors.txt @@ -1,5 +1,4 @@ tests/cases/compiler/reachabilityChecks6.ts(6,10): error TS7030: Not all code paths return a value. -tests/cases/compiler/reachabilityChecks6.ts(19,10): error TS7030: Not all code paths return a value. tests/cases/compiler/reachabilityChecks6.ts(31,10): error TS7030: Not all code paths return a value. tests/cases/compiler/reachabilityChecks6.ts(41,10): error TS7030: Not all code paths return a value. tests/cases/compiler/reachabilityChecks6.ts(52,10): error TS7030: Not all code paths return a value. @@ -10,7 +9,7 @@ tests/cases/compiler/reachabilityChecks6.ts(116,10): error TS7030: Not all code tests/cases/compiler/reachabilityChecks6.ts(123,13): error TS7027: Unreachable code detected. -==== tests/cases/compiler/reachabilityChecks6.ts (10 errors) ==== +==== tests/cases/compiler/reachabilityChecks6.ts (9 errors) ==== function f0(x) { while (true); @@ -32,8 +31,6 @@ tests/cases/compiler/reachabilityChecks6.ts(123,13): error TS7027: Unreachable c } function f3(x) { - ~~ -!!! error TS7030: Not all code paths return a value. while (x) { throw new Error(); } diff --git a/tests/baselines/reference/reachabilityChecks7.errors.txt b/tests/baselines/reference/reachabilityChecks7.errors.txt index 9e8f803f95..1596c7d9a3 100644 --- a/tests/baselines/reference/reachabilityChecks7.errors.txt +++ b/tests/baselines/reference/reachabilityChecks7.errors.txt @@ -1,21 +1,39 @@ -tests/cases/compiler/reachabilityChecks7.ts(3,16): error TS7030: Not all code paths return a value. -tests/cases/compiler/reachabilityChecks7.ts(6,9): error TS7030: Not all code paths return a value. +tests/cases/compiler/reachabilityChecks7.ts(14,16): error TS7030: Not all code paths return a value. +tests/cases/compiler/reachabilityChecks7.ts(18,22): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. ==== tests/cases/compiler/reachabilityChecks7.ts (2 errors) ==== // async function without return type annotation - error async function f1() { - ~~ -!!! error TS7030: Not all code paths return a value. } let x = async function() { - ~~~~~ -!!! error TS7030: Not all code paths return a value. } // async function with which promised type is void - return can be omitted async function f2(): Promise { - } \ No newline at end of file + } + + async function f3(x) { + ~~ +!!! error TS7030: Not all code paths return a value. + if (x) return 10; + } + + async function f4(): Promise { + ~~~~~~~~~~~~~~~ +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. + + } + + function voidFunc(): void { + } + + function calltoVoidFunc(x) { + if (x) return voidFunc(); + } + + declare function use(s: string): void; + let x1 = () => { use("Test"); } \ No newline at end of file diff --git a/tests/baselines/reference/reachabilityChecks7.js b/tests/baselines/reference/reachabilityChecks7.js index f9579d5828..c78f99953e 100644 --- a/tests/baselines/reference/reachabilityChecks7.js +++ b/tests/baselines/reference/reachabilityChecks7.js @@ -10,7 +10,25 @@ let x = async function() { // async function with which promised type is void - return can be omitted async function f2(): Promise { -} +} + +async function f3(x) { + if (x) return 10; +} + +async function f4(): Promise { + +} + +function voidFunc(): void { +} + +function calltoVoidFunc(x) { + if (x) return voidFunc(); +} + +declare function use(s: string): void; +let x1 = () => { use("Test"); } //// [reachabilityChecks7.js] var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) { @@ -40,3 +58,20 @@ function f2() { return __awaiter(this, void 0, Promise, function* () { }); } +function f3(x) { + return __awaiter(this, void 0, Promise, function* () { + if (x) + return 10; + }); +} +function f4() { + return __awaiter(this, void 0, Promise, function* () { + }); +} +function voidFunc() { +} +function calltoVoidFunc(x) { + if (x) + return voidFunc(); +} +let x1 = () => { use("Test"); }; diff --git a/tests/baselines/reference/sourceMapValidationDecorators.js.map b/tests/baselines/reference/sourceMapValidationDecorators.js.map index ea2b514b7e..0a6b45eb38 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":[],"mappings":";;;;;;;;;AAOA;IAGI,iBAGS,QAAgB;QAEvB,WAEc;aAFd,WAEc,CAFd,sBAEc,CAFd,IAEc;YAFd,0BAEc;;QAJP,aAAQ,GAAR,QAAQ,CAAQ;IAKzB,CAAC;IAID,uBAAK,GAFL;QAGI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5C,CAAC;IAUO,oBAAE,GAAV,UAGE,CAAS;QACP,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED,sBAEI,8BAAS;aAFb;YAGI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;aAED,UAGE,SAAiB;YACf,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC9B,CAAC;;;OAPA;IAbc,UAAE,GAAW,EAAE,CAAC;IAZ/B;QAAC,kBAAkB;QAClB,kBAAkB,CAAC,EAAE,CAAC;OACvB,0BAAK,QAEJ;IAED;QAAC,kBAAkB;QAClB,kBAAkB,CAAC,EAAE,CAAC;OACf,sBAAC,UAAS;IAMlB;QACE,WAAC,mBAAmB,CAAA;QACpB,WAAC,mBAAmB,CAAC,EAAE,CAAC,CAAA;OAFlB,uBAAE,QAKT;IAED;QAAC,kBAAkB;QAClB,kBAAkB,CAAC,EAAE,CAAC;QAMrB,WAAC,mBAAmB,CAAA;QACpB,WAAC,mBAAmB,CAAC,EAAE,CAAC,CAAA;OANtB,8BAAS,QAEZ;IAfD;QAAC,kBAAkB;QAClB,kBAAkB,CAAC,EAAE,CAAC;OACR,aAAE,UAAc;IAzBnC;QAAC,eAAe;QACf,eAAe,CAAC,EAAE,CAAC;QAGd,WAAC,mBAAmB,CAAA;QACpB,WAAC,mBAAmB,CAAC,EAAE,CAAC,CAAA;QAGxB,WAAC,mBAAmB,CAAA;QACpB,WAAC,mBAAmB,CAAC,EAAE,CAAC,CAAA;gBAqC7B;IAAD,cAAC;AAAD,CAAC,AA9CD,IA8CC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDecorators.js","sourceRoot":"","sources":["sourceMapValidationDecorators.ts"],"names":[],"mappings":";;;;;;;;;AASA;IACI,iBAGS,QAAgB;QAIvB,WAAc;aAAd,WAAc,CAAd,sBAAc,CAAd,IAAc;YAAd,0BAAc;;QAJP,aAAQ,GAAR,QAAQ,CAAQ;IAKzB,CAAC;IAID,uBAAK,GAAL;QACI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5C,CAAC;IAUO,oBAAE,GAAV,UAGE,CAAS;QACP,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAID,sBAAI,8BAAS;aAAb;YACI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;aAED,UAGE,SAAiB;YACf,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC9B,CAAC;;;OAPA;IAbc,UAAE,GAAW,EAAE,CAAC;IAZ/B;QAAC,kBAAkB;QAClB,kBAAkB,CAAC,EAAE,CAAC;wCAAA;IAKvB;QAAC,kBAAkB;QAClB,kBAAkB,CAAC,EAAE,CAAC;sCAAA;IAQrB;mBAAC,mBAAmB;mBACnB,mBAAmB,CAAC,EAAE,CAAC;qCAAA;IAK1B;QAAC,kBAAkB;QAClB,kBAAkB,CAAC,EAAE,CAAC;mBAMpB,mBAAmB;mBACnB,mBAAmB,CAAC,EAAE,CAAC;4CAPH;IAZvB;QAAC,kBAAkB;QAClB,kBAAkB,CAAC,EAAE,CAAC;6BAAA;IAxB3B;QAAC,eAAe;QACf,eAAe,CAAC,EAAE,CAAC;mBAGb,mBAAmB;mBACnB,mBAAmB,CAAC,EAAE,CAAC;mBAGvB,mBAAmB;mBACnB,mBAAmB,CAAC,EAAE,CAAC;eARV;IA6CpB,cAAC;AAAD,CAAC,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 83639857f0..418fee1f87 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) +2 > ...b: string[] +1 >Emitted(12, 9) Source(18, 7) + SourceIndex(0) 2 >Emitted(12, 20) Source(18, 21) + SourceIndex(0) --- >>> 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) +6 > ...b: string[] +1->Emitted(13, 14) Source(18, 7) + SourceIndex(0) 2 >Emitted(13, 25) Source(18, 21) + SourceIndex(0) -3 >Emitted(13, 26) Source(16, 7) + SourceIndex(0) +3 >Emitted(13, 26) Source(18, 7) + SourceIndex(0) 4 >Emitted(13, 48) Source(18, 21) + SourceIndex(0) -5 >Emitted(13, 49) Source(16, 7) + SourceIndex(0) +5 >Emitted(13, 49) Source(18, 7) + SourceIndex(0) 6 >Emitted(13, 53) Source(18, 21) + SourceIndex(0) --- >>> b[_i - 1] = arguments[_i]; 1 >^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > -2 > @ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[] -1 >Emitted(14, 13) Source(16, 7) + SourceIndex(0) +2 > ...b: string[] +1 >Emitted(14, 13) Source(18, 7) + SourceIndex(0) 2 >Emitted(14, 39) Source(18, 21) + SourceIndex(0) --- >>> } @@ -142,7 +134,7 @@ sourceFile:sourceMapValidationDecorators.ts 3 > 1->Emitted(18, 5) Source(23, 5) + SourceIndex(0) 2 >Emitted(18, 28) Source(23, 10) + SourceIndex(0) -3 >Emitted(18, 31) Source(21, 5) + SourceIndex(0) +3 >Emitted(18, 31) Source(23, 5) + SourceIndex(0) --- >>> 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) +1->Emitted(24, 5) Source(44, 5) + SourceIndex(0) 2 >Emitted(24, 27) Source(44, 9) + SourceIndex(0) 3 >Emitted(24, 57) Source(44, 18) + SourceIndex(0) --- @@ -275,7 +265,7 @@ sourceFile:sourceMapValidationDecorators.ts 1 >^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(25, 14) Source(42, 5) + SourceIndex(0) +1 >Emitted(25, 14) Source(44, 5) + SourceIndex(0) --- >>> 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) --- >>> ], Greeter.prototype, "greet", null); -1->^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^ -1-> - > -2 > greet -3 > () { - > return "

" + this.greeting + "

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

" + this.greeting + "

"; + > } > > 1 >Emitted(39, 5) Source(27, 5) + SourceIndex(0) @@ -474,89 +456,63 @@ sourceFile:sourceMapValidationDecorators.ts 5 >Emitted(41, 31) Source(28, 28) + SourceIndex(0) --- >>> ], Greeter.prototype, "x", void 0); -1->^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^^^ -1-> - > private -2 > x -3 > : string; -1->Emitted(42, 8) Source(29, 13) + SourceIndex(0) -2 >Emitted(42, 30) Source(29, 14) + SourceIndex(0) -3 >Emitted(42, 40) Source(29, 23) + SourceIndex(0) +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +1->Emitted(42, 39) Source(28, 28) + SourceIndex(0) --- >>> __decorate([ 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > + > private x: string; > > @PropertyDecorator1 > @PropertyDecorator2(60) > private static x1: number = 10; > - > -1 >Emitted(43, 5) Source(35, 5) + SourceIndex(0) + > private fn( + > +1 >Emitted(43, 5) Source(36, 7) + SourceIndex(0) --- >>> __param(0, ParameterDecorator1), -1->^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^ -5 > ^^^^^-> -1->private fn( - > -2 > @ -3 > ParameterDecorator1 -4 > -1->Emitted(44, 9) Source(36, 7) + SourceIndex(0) -2 >Emitted(44, 20) Source(36, 8) + SourceIndex(0) -3 >Emitted(44, 39) Source(36, 27) + SourceIndex(0) -4 >Emitted(44, 40) Source(36, 27) + SourceIndex(0) +1->^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^-> +1->@ +2 > ParameterDecorator1 +1->Emitted(44, 20) Source(36, 8) + SourceIndex(0) +2 >Emitted(44, 39) Source(36, 27) + SourceIndex(0) --- >>> __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) -2 >Emitted(45, 20) Source(37, 8) + SourceIndex(0) -3 >Emitted(45, 39) Source(37, 27) + SourceIndex(0) -4 >Emitted(45, 40) Source(37, 28) + SourceIndex(0) -5 >Emitted(45, 42) Source(37, 30) + SourceIndex(0) -6 >Emitted(45, 43) Source(37, 31) + SourceIndex(0) -7 >Emitted(45, 44) Source(37, 31) + SourceIndex(0) + > @ +2 > ParameterDecorator2 +3 > ( +4 > 70 +5 > ) +1->Emitted(45, 20) Source(37, 8) + SourceIndex(0) +2 >Emitted(45, 39) Source(37, 27) + SourceIndex(0) +3 >Emitted(45, 40) Source(37, 28) + SourceIndex(0) +4 >Emitted(45, 42) Source(37, 30) + SourceIndex(0) +5 >Emitted(45, 43) Source(37, 31) + SourceIndex(0) --- >>> ], 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) -2 >Emitted(46, 31) Source(35, 15) + SourceIndex(0) -3 >Emitted(46, 39) Source(40, 6) + SourceIndex(0) +1 >Emitted(46, 38) Source(37, 31) + SourceIndex(0) --- >>> __decorate([ 1 >^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > +1 > + > x: number) { + > return this.greeting; + > } > > 1 >Emitted(47, 5) Source(42, 5) + SourceIndex(0) @@ -590,63 +546,43 @@ sourceFile:sourceMapValidationDecorators.ts 5 >Emitted(49, 31) Source(43, 28) + SourceIndex(0) --- >>> __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) -2 >Emitted(50, 20) Source(49, 8) + SourceIndex(0) -3 >Emitted(50, 39) Source(49, 27) + SourceIndex(0) -4 >Emitted(50, 40) Source(49, 27) + SourceIndex(0) + > @ +2 > ParameterDecorator1 +1->Emitted(50, 20) Source(49, 8) + SourceIndex(0) +2 >Emitted(50, 39) Source(49, 27) + SourceIndex(0) --- >>> __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) -2 >Emitted(51, 20) Source(50, 8) + SourceIndex(0) -3 >Emitted(51, 39) Source(50, 27) + SourceIndex(0) -4 >Emitted(51, 40) Source(50, 28) + SourceIndex(0) -5 >Emitted(51, 42) Source(50, 30) + SourceIndex(0) -6 >Emitted(51, 43) Source(50, 31) + SourceIndex(0) -7 >Emitted(51, 44) Source(50, 31) + SourceIndex(0) + > @ +2 > ParameterDecorator2 +3 > ( +4 > 90 +5 > ) +1->Emitted(51, 20) Source(50, 8) + SourceIndex(0) +2 >Emitted(51, 39) Source(50, 27) + SourceIndex(0) +3 >Emitted(51, 40) Source(50, 28) + SourceIndex(0) +4 >Emitted(51, 42) Source(50, 30) + SourceIndex(0) +5 >Emitted(51, 43) Source(50, 31) + SourceIndex(0) --- >>> ], Greeter.prototype, "greetings", null); -1->^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^ +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> -2 > greetings -3 > () { - > return this.greeting; - > } -1->Emitted(52, 8) Source(44, 9) + SourceIndex(0) -2 >Emitted(52, 38) Source(44, 18) + SourceIndex(0) -3 >Emitted(52, 46) Source(46, 6) + SourceIndex(0) +1->Emitted(52, 45) Source(43, 28) + SourceIndex(0) --- >>> __decorate([ 1 >^^^^ @@ -683,16 +619,9 @@ sourceFile:sourceMapValidationDecorators.ts 5 >Emitted(55, 31) Source(32, 28) + SourceIndex(0) --- >>> ], Greeter, "x1", void 0); -1->^^^^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^^^ -1-> - > private static -2 > x1 -3 > : number = 10; -1->Emitted(56, 8) Source(33, 20) + SourceIndex(0) -2 >Emitted(56, 21) Source(33, 22) + SourceIndex(0) -3 >Emitted(56, 31) Source(33, 36) + SourceIndex(0) +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1-> +1->Emitted(56, 30) Source(32, 28) + SourceIndex(0) --- >>> Greeter = __decorate([ 1 >^^^^ @@ -729,93 +658,83 @@ sourceFile:sourceMapValidationDecorators.ts 5 >Emitted(59, 28) Source(9, 21) + SourceIndex(0) --- >>> __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) -2 >Emitted(60, 20) Source(12, 8) + SourceIndex(0) -3 >Emitted(60, 39) Source(12, 27) + SourceIndex(0) -4 >Emitted(60, 40) Source(12, 27) + SourceIndex(0) + > @ +2 > ParameterDecorator1 +1->Emitted(60, 20) Source(12, 8) + SourceIndex(0) +2 >Emitted(60, 39) Source(12, 27) + SourceIndex(0) --- >>> __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) -2 >Emitted(61, 20) Source(13, 8) + SourceIndex(0) -3 >Emitted(61, 39) Source(13, 27) + SourceIndex(0) -4 >Emitted(61, 40) Source(13, 28) + SourceIndex(0) -5 >Emitted(61, 42) Source(13, 30) + SourceIndex(0) -6 >Emitted(61, 43) Source(13, 31) + SourceIndex(0) -7 >Emitted(61, 44) Source(13, 31) + SourceIndex(0) + > @ +2 > ParameterDecorator2 +3 > ( +4 > 20 +5 > ) +1->Emitted(61, 20) Source(13, 8) + SourceIndex(0) +2 >Emitted(61, 39) Source(13, 27) + SourceIndex(0) +3 >Emitted(61, 40) Source(13, 28) + SourceIndex(0) +4 >Emitted(61, 42) Source(13, 30) + SourceIndex(0) +5 >Emitted(61, 43) Source(13, 31) + SourceIndex(0) --- >>> __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) -2 >Emitted(62, 20) Source(16, 8) + SourceIndex(0) -3 >Emitted(62, 39) Source(16, 27) + SourceIndex(0) -4 >Emitted(62, 40) Source(16, 27) + SourceIndex(0) + > @ +2 > ParameterDecorator1 +1 >Emitted(62, 20) Source(16, 8) + SourceIndex(0) +2 >Emitted(62, 39) Source(16, 27) + SourceIndex(0) --- >>> __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) -2 >Emitted(63, 20) Source(17, 8) + SourceIndex(0) -3 >Emitted(63, 39) Source(17, 27) + SourceIndex(0) -4 >Emitted(63, 40) Source(17, 28) + SourceIndex(0) -5 >Emitted(63, 42) Source(17, 30) + SourceIndex(0) -6 >Emitted(63, 43) Source(17, 31) + SourceIndex(0) -7 >Emitted(63, 44) Source(17, 31) + SourceIndex(0) + > @ +2 > ParameterDecorator2 +3 > ( +4 > 30 +5 > ) +1->Emitted(63, 20) Source(17, 8) + SourceIndex(0) +2 >Emitted(63, 39) Source(17, 27) + SourceIndex(0) +3 >Emitted(63, 40) Source(17, 28) + SourceIndex(0) +4 >Emitted(63, 42) Source(17, 30) + SourceIndex(0) +5 >Emitted(63, 43) Source(17, 31) + SourceIndex(0) --- >>> ], Greeter); -1 >^^^^^^^^^^^^^^^^ -2 > ^^^^-> -1 > +1 >^^^^^^^^^^^^^^^ +2 > ^^^^^-> +1 > +1 >Emitted(64, 16) Source(9, 21) + SourceIndex(0) +--- +>>> 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) ---- ->>> return Greeter; -1->^^^^ -2 > ^^^^^^^^^^^^^^ -1-> + > 2 > } 1->Emitted(65, 5) Source(54, 1) + SourceIndex(0) 2 >Emitted(65, 19) Source(54, 2) + SourceIndex(0) @@ -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) 2 >Emitted(66, 2) Source(54, 2) + SourceIndex(0) -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/compiler/reachabilityChecks7.ts b/tests/cases/compiler/reachabilityChecks7.ts index 11febb320d..53702037e3 100644 --- a/tests/cases/compiler/reachabilityChecks7.ts +++ b/tests/cases/compiler/reachabilityChecks7.ts @@ -11,4 +11,22 @@ let x = async function() { // async function with which promised type is void - return can be omitted async function f2(): Promise { -} \ No newline at end of file +} + +async function f3(x) { + if (x) return 10; +} + +async function f4(): Promise { + +} + +function voidFunc(): void { +} + +function calltoVoidFunc(x) { + if (x) return voidFunc(); +} + +declare function use(s: string): void; +let x1 = () => { use("Test"); } \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/asyncMultiFile.ts b/tests/cases/conformance/async/es6/asyncMultiFile.ts new file mode 100644 index 0000000000..55f5e4b9e9 --- /dev/null +++ b/tests/cases/conformance/async/es6/asyncMultiFile.ts @@ -0,0 +1,5 @@ +// @target: es6 +// @filename: a.ts +async function f() {} +// @filename: b.ts +function g() { } \ 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 0000000000..9eb4463e00 --- /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