mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-15 03:09:59 -05:00
Use first declaration, not valueDeclaration
valueDeclaration is frequently not set
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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" };
|
||||
|
||||
Reference in New Issue
Block a user