Skip to content

Commit 880e958

Browse files
author
Yui T
committed
Fix comment
1 parent 03e0722 commit 880e958

7 files changed

Lines changed: 55 additions & 9 deletions

src/compiler/emitter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,8 @@ module ts {
10471047
// Emit identifier as an identifier
10481048
emit(node.name);
10491049
write(": ");
1050-
// Even though this is stored as identified because it is in short-hand property assignment, treated it as expression
1050+
// Even though this is stored as identified because it is in short-hand property assignment,
1051+
// treated it as expression
10511052
emitExpressionIdentifier(node.name);
10521053
emitTrailingComments(node);
10531054
}

src/compiler/parser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2687,6 +2687,7 @@ module ts {
26872687
(<PropertyDeclaration>node).initializer = makeFunctionExpression(SyntaxKind.FunctionExpression, node.pos, undefined, sig, body);
26882688
return finishNode(node);
26892689
}
2690+
// Disallow optional property assignment
26902691
if (token === SyntaxKind.QuestionToken) {
26912692
var questionStart = scanner.getTokenPos();
26922693
grammarErrorAtPos(questionStart, scanner.getStartPos() - questionStart, Diagnostics.A_object_member_cannot_be_declared_optional);

tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.errors.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr
1111
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(16,6): error TS1005: ',' expected.
1212
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(17,6): error TS1005: '=' expected.
1313
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(18,1): error TS1128: Declaration or statement expected.
14+
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(20,17): error TS1005: ':' expected.
1415
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
1516
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(15,5): error TS2300: Duplicate identifier 'a'.
1617
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(15,7): error TS2304: Cannot find name 'b'.
1718
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts(16,5): error TS2300: Duplicate identifier 'a'.
1819

1920

20-
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts (17 errors) ====
21+
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts (18 errors) ====
2122
// errors
2223
var y = {
2324
"stringLiteral",
@@ -69,4 +70,8 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr
6970
!!! error TS1005: '=' expected.
7071
};
7172
~
72-
!!! error TS1128: Declaration or statement expected.
73+
!!! error TS1128: Declaration or statement expected.
74+
75+
var v = { class }; // error
76+
~
77+
!!! error TS1005: ':' expected.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorWithModule.ts(10,10): error TS1005: ',' expected.
2+
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorWithModule.ts(14,3): error TS2339: Property 'y' does not exist on type 'typeof m'.
3+
4+
5+
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorWithModule.ts (2 errors) ====
6+
// module export
7+
var x = "Foo";
8+
module m {
9+
export var x;
10+
}
11+
12+
module n {
13+
var z = 10000;
14+
export var y = {
15+
m.x // error
16+
~
17+
!!! error TS1005: ',' expected.
18+
};
19+
}
20+
21+
m.y.x;
22+
~
23+
!!! error TS2339: Property 'y' does not exist on type 'typeof m'.
24+

tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ var x = {
1515
a.b,
1616
a["ss"],
1717
a[1],
18-
};
18+
};
19+
20+
var v = { class }; // error
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// module export
2+
var x = "Foo";
3+
module m {
4+
export var x;
5+
}
6+
7+
module n {
8+
var z = 10000;
9+
export var y = {
10+
m.x // error
11+
};
12+
}
13+
14+
m.y.x;
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
// module export
2-
var x = "Foo";
2+
33
module m {
44
export var x;
55
}
66

77
module m {
8-
var z = 10000;
9-
export var y = {
8+
var z = x;
9+
var y = {
10+
a: x,
1011
x
1112
};
1213
}
13-
14-
m.y.x;

0 commit comments

Comments
 (0)