Merge branch 'master' into fixAsyncReferecedImport

This commit is contained in:
Ron Buckton 2015-11-30 16:45:34 -08:00
commit c792fd2d8e
18 changed files with 801 additions and 327 deletions

View file

@ -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.
// NOTE: having returnType !== undefined is a precondition for entering this branch so func.type will always be present
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 {
@ -14376,6 +14384,7 @@ namespace ts {
emitExtends = false;
emitDecorate = false;
emitParam = false;
emitAwaiter = false;
potentialThisCollisions.length = 0;
forEach(node.statements, checkSourceElement);

View file

@ -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<Decorator>;
let functionLikeMember: FunctionLikeDeclaration;
@ -5394,6 +5388,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
functionLikeMember = <MethodDeclaration>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;
}

View file

@ -4902,7 +4902,7 @@ namespace ts {
if (!decorators) {
decorators = <NodeArray<Decorator>>[];
decorators.pos = scanner.getStartPos();
decorators.pos = decoratorStart;
}
const decorator = <Decorator>createNode(SyntaxKind.Decorator, decoratorStart);

View file

@ -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) {

View file

@ -906,23 +906,6 @@ namespace ts {
return false;
}
export function childIsDecorated(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.ClassDeclaration:
return forEach((<ClassDeclaration>node).members, nodeOrChildIsDecorated);
case SyntaxKind.MethodDeclaration:
case SyntaxKind.SetAccessor:
return forEach((<FunctionLikeDeclaration>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;
}

View file

@ -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<T>(nodeArray: NodeArray<T>) {
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((<WithStatement>node).statement);
case SyntaxKind.Decorator:
return spanInNodeArray(node.parent.decorators);
// No breakpoint in interface, type alias
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.TypeAliasDeclaration:

View file

@ -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() { }

View file

@ -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))

View file

@ -0,0 +1,8 @@
=== tests/cases/conformance/async/es6/a.ts ===
async function f() {}
>f : () => Promise<void>
=== tests/cases/conformance/async/es6/b.ts ===
function g() { }
>g : () => void

View file

@ -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 "<h1>" + this.greeting + "</h1>";
> }
>
> @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 "<h1>" + this.greeting + "</h1>";
> }
>:=> (line 23, col 4) to (line 25, col 5)
23 > greet() {
~~~ => Pos: (923 to 925) SpanInfo: {"start":934,"length":39}
>return "<h1>" + this.greeting + "</h1>"
>:=> (line 24, col 8) to (line 24, col 47)
--------------------------------
24 > return "<h1>" + this.greeting + "</h1>";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (926 to 974) SpanInfo: {"start":934,"length":39}
>return "<h1>" + this.greeting + "</h1>"
>:=> (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)

View file

@ -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();
}

View file

@ -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<void> {
}
}
async function f3(x) {
~~
!!! error TS7030: Not all code paths return a value.
if (x) return 10;
}
async function f4(): Promise<number> {
~~~~~~~~~~~~~~~
!!! 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"); }

View file

@ -10,7 +10,25 @@ let x = async function() {
// async function with which promised type is void - return can be omitted
async function f2(): Promise<void> {
}
}
async function f3(x) {
if (x) return 10;
}
async function f4(): Promise<number> {
}
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"); };

View file

@ -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"}
{"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"}

View file

@ -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 "<h1>" + this.greeting + "</h1>";
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 "<h1>" + this.greeting + "</h1>";
> }
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 "<h1>" + this.greeting + "</h1>";
> }
>
>
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

View file

@ -11,4 +11,22 @@ let x = async function() {
// async function with which promised type is void - return can be omitted
async function f2(): Promise<void> {
}
}
async function f3(x) {
if (x) return 10;
}
async function f4(): Promise<number> {
}
function voidFunc(): void {
}
function calltoVoidFunc(x) {
if (x) return voidFunc();
}
declare function use(s: string): void;
let x1 = () => { use("Test"); }

View file

@ -0,0 +1,5 @@
// @target: es6
// @filename: a.ts
async function f() {}
// @filename: b.ts
function g() { }

View file

@ -0,0 +1,60 @@
/// <reference path='fourslash.ts' />
// @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 "<h1>" + this.greeting + "</h1>";
//// }
////
//// @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();