8000 Merge branch 'master' into LSAPICleanup · ezhangle/TypeScript@2772355 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2772355

Browse files
committed
Merge branch 'master' into LSAPICleanup
2 parents 8524bfc + 6807bf8 commit 2772355

File tree

6 files changed

+45
-2
lines changed

6 files changed

+45
-2
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6553,6 +6553,9 @@ module ts {
65536553

65546554
function getReturnTypeFromBody(func: FunctionLikeDeclaration, contextualMapper?: TypeMapper): Type {
65556555
var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
6556+
if (!func.body) {
6557+
return unknownType;
6558+
}
65566559
if (func.body.kind !== SyntaxKind.Block) {
65576560
var type = checkExpressionCached(<Expression>func.body, contextualMapper);
65586561
}

src/compiler/emitter.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2461,8 +2461,11 @@ module ts {
24612461
function tryEmitConstantValue(node: PropertyAccessExpression | ElementAccessExpression): boolean {
24622462
var constantValue = resolver.getConstantValue(node);
24632463
if (constantValue !== undefined) {
2464-
var propertyName = node.kind === SyntaxKind.PropertyAccessExpression ? declarationNameToString((<PropertyAccessExpression>node).name) : getTextOfNode((<ElementAccessExpression>node).argumentExpression);
2465-
write(constantValue.toString() + " /* " + propertyName + " */");
2464+
write(constantValue.toString());
2465+
if (!compilerOptions.removeComments) {
2466+
var propertyName: string = node.kind === SyntaxKind.PropertyAccessExpression ? declarationNameToString((<PropertyAccessExpression>node).name) : getTextOfNode((<ElementAccessExpression>node).argumentExpression);
2467+
write(" /* " + propertyName + " */");
2468+
}
24662469
return true;
24672470
}
24682471
return false;

tests/baselines/reference/commentsdoNotEmitComments.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ module m1 {
8686

8787
/// this is x
8888
declare var x;
89+
90+
91+
/** const enum member value comment (generated by TS) */
92+
const enum color { red, green, blue }
93+
var shade: color = color.green;
8994

9095

9196
//// [commentsdoNotEmitComments.js]
@@ -129,6 +134,7 @@ var m1;
129134
})();
130135
m1.b = b;
131136
})(m1 || (m1 = {}));
137+
var shade = 1;
132138

133139

134140
//// [commentsdoNotEmitComments.d.ts]
@@ -161,3 +167,9 @@ declare module m1 {
161167
}
162168
}
163169
declare var x: any;
170+
declare const enum color {
171+
red = 0,
172+
green = 1,
173+
blue = 2,
174+
}
175+
declare var shade: color;

tests/baselines/reference/commentsdoNotEmitComments.types

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,18 @@ module m1 {
151151
declare var x;
152152
>x : any
153153

154+
155+
/** const enum member value comment (generated by TS) */
156+
const enum color { red, green, blue }
157+
>color : color
158+
>red : color
159+
>green : color
160+
>blue : color
161+
162+
var shade: color = color.green;
163+
>shade : color
164+
>color : color
165+
>color.green : color
166+
>color : typeof color
167+
>green : color
168+

tests/cases/compiler/commentsdoNotEmitComments.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,8 @@ module m1 {
8888

8989
/// this is x
9090
declare var x;
91+
92+
93+
/** const enum member value comment (generated by TS) */
94+
const enum color { red, green, blue }
95+
var shade: color = color.green;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
//// var x: { f(): string } = { f( }
4+
5+
verify.numberOfErrorsInCurrentFile(1);

0 commit comments

Comments
 (0)
0