Add unit test to show that object property type gets inferred without
@@ -1761,6 +1761,22 @@ public final class TypeInferenceTest {
verify("y", STRING_OBJECT_TYPE);
}
+ @Test
+ public void testTypeInferenceOccursInConstObjectProperties() {
+ inFunction(
+ lines(
+ "/** @return {string} */",
+ "function foo() { return ''; }",
+ "",
+ "const obj = {",
+ " prop: foo(),",
+ "}",
+ "LABEL: obj.prop;"));
+
+ assertTypeOfExpression("LABEL").toStringIsEqualTo("string");
+ assertTypeOfExpression("LABEL").isNotEqualTo(UNKNOWN_TYPE);
+ }
+
@Test
public void testReturn1() {
assuming("x", createNullableType(OBJECT_TYPE));
