mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Switch checkObjectLiteral to iterate over element declarations
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
tests/cases/compiler/lastPropertyInLiteralWins.ts(8,5): error TS2300: Duplicate identifier 'thunk'.
|
||||
tests/cases/compiler/lastPropertyInLiteralWins.ts(9,5): error TS2300: Duplicate identifier 'thunk'.
|
||||
tests/cases/compiler/lastPropertyInLiteralWins.ts(12,6): error TS2345: Argument of type '{ thunk: (num: number) => void; }' is not assignable to parameter of type 'Thing'.
|
||||
tests/cases/compiler/lastPropertyInLiteralWins.ts(7,6): error TS2345: Argument of type '{ thunk: (num: number) => void; }' is not assignable to parameter of type 'Thing'.
|
||||
Types of property 'thunk' are incompatible.
|
||||
Type '(num: number) => void' is not assignable to type '(str: string) => void'.
|
||||
tests/cases/compiler/lastPropertyInLiteralWins.ts(8,5): error TS2300: Duplicate identifier 'thunk'.
|
||||
tests/cases/compiler/lastPropertyInLiteralWins.ts(9,5): error TS2300: Duplicate identifier 'thunk'.
|
||||
tests/cases/compiler/lastPropertyInLiteralWins.ts(13,5): error TS2300: Duplicate identifier 'thunk'.
|
||||
tests/cases/compiler/lastPropertyInLiteralWins.ts(14,5): error TS2300: Duplicate identifier 'thunk'.
|
||||
|
||||
@@ -15,21 +15,12 @@ tests/cases/compiler/lastPropertyInLiteralWins.ts(14,5): error TS2300: Duplicate
|
||||
thing.thunk("str");
|
||||
}
|
||||
test({ // Should error, as last one wins, and is wrong type
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
thunk: (str: string) => {},
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'thunk'.
|
||||
thunk: (num: number) => {}
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'thunk'.
|
||||
});
|
||||
|
||||
test({ // Should be OK. Last 'thunk' is of correct type
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
thunk: (num: number) => {},
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'thunk'.
|
||||
thunk: (str: string) => {}
|
||||
thunk: (num: number) => {}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'thunk'.
|
||||
@@ -38,4 +29,13 @@ tests/cases/compiler/lastPropertyInLiteralWins.ts(14,5): error TS2300: Duplicate
|
||||
!!! error TS2345: Argument of type '{ thunk: (num: number) => void; }' is not assignable to parameter of type 'Thing'.
|
||||
!!! error TS2345: Types of property 'thunk' are incompatible.
|
||||
!!! error TS2345: Type '(num: number) => void' is not assignable to type '(str: string) => void'.
|
||||
|
||||
test({ // Should be OK. Last 'thunk' is of correct type
|
||||
thunk: (num: number) => {},
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'thunk'.
|
||||
thunk: (str: string) => {}
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'thunk'.
|
||||
});
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
tests/cases/compiler/memberOverride.ts(4,5): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/compiler/memberOverride.ts(5,5): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/compiler/memberOverride.ts(8,5): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/memberOverride.ts (3 errors) ====
|
||||
==== tests/cases/compiler/memberOverride.ts (2 errors) ====
|
||||
// An object initialiser accepts the first definition for the same property with a different type signature
|
||||
// Should compile, since the second declaration of a overrides the first
|
||||
var x = {
|
||||
@@ -15,6 +14,4 @@ tests/cases/compiler/memberOverride.ts(8,5): error TS2322: Type 'string' is not
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
}
|
||||
|
||||
var n: number = x.a;
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
var n: number = x.a;
|
||||
@@ -11,9 +11,10 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralType
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralTypesInImplementationSignatures2.ts(26,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralTypesInImplementationSignatures2.ts(26,5): error TS2381: A signature with an implementation cannot use a string literal type.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralTypesInImplementationSignatures2.ts(27,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralTypesInImplementationSignatures2.ts(27,5): error TS2381: A signature with an implementation cannot use a string literal type.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralTypesInImplementationSignatures2.ts (13 errors) ====
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralTypesInImplementationSignatures2.ts (14 errors) ====
|
||||
// String literal types are only valid in overload signatures
|
||||
|
||||
function foo(x: any);
|
||||
@@ -67,5 +68,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/stringLiteralType
|
||||
foo(x: 'a') { },
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2381: A signature with an implementation cannot use a string literal type.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user