Use first declaration, not valueDeclaration

valueDeclaration is frequently not set
This commit is contained in:
Nathan Shively-Sanders
2017-06-14 11:43:51 -07:00
parent 0913ef66e6
commit a7d7a4cedf
2 changed files with 3 additions and 3 deletions

View File

@@ -8955,7 +8955,7 @@ namespace ts {
reportError(Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target));
}
else {
const objectLiteralDeclaration = source.symbol && source.symbol.valueDeclaration;
const objectLiteralDeclaration = source.symbol && firstOrUndefined(source.symbol.declarations);
if (prop.valueDeclaration && findAncestor(prop.valueDeclaration, d => d === objectLiteralDeclaration)) {
errorNode = prop.valueDeclaration;
}

View File

@@ -17,7 +17,7 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(52,9): error TS2339
tests/cases/conformance/types/spread/objectSpreadNegative.ts(57,11): error TS2339: Property 'a' does not exist on type '{}'.
tests/cases/conformance/types/spread/objectSpreadNegative.ts(61,14): error TS2698: Spread types may only be created from object types.
tests/cases/conformance/types/spread/objectSpreadNegative.ts(64,14): error TS2698: Spread types may only be created from object types.
tests/cases/conformance/types/spread/objectSpreadNegative.ts(78,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'.
tests/cases/conformance/types/spread/objectSpreadNegative.ts(78,37): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'.
Object literal may only specify known properties, and 'extra' does not exist in type 'A'.
tests/cases/conformance/types/spread/objectSpreadNegative.ts(81,7): error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'.
Object literal may only specify known properties, and 'extra' does not exist in type 'A'.
@@ -139,7 +139,7 @@ tests/cases/conformance/types/spread/objectSpreadNegative.ts(83,7): error TS2322
type A = { a: string, b: string };
type Extra = { a: string, b: string, extra: string };
const extra1: A = { a: "a", b: "b", extra: "extra" };
~~~~~~
~~~~~~~~~~~~~~
!!! error TS2322: Type '{ a: string; b: string; extra: string; }' is not assignable to type 'A'.
!!! error TS2322: Object literal may only specify known properties, and 'extra' does not exist in type 'A'.
const extra2 = { a: "a", b: "b", extra: "extra" };