-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Contextually type undefined/null/[]/{}
Also: 1. Address review comments. 2. Add test cases to implementedPropertyContextualTyping.* 3. Improve some tests: bestCommonTypeOfTuple2 and destructuringParameterDeclaration2. 4. Make some tests worse due to exposing bug 6190: requiredInitializedParameter.*. I'll fix it separately.
- Loading branch information
Showing
16 changed files
with
280 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tests/baselines/reference/implementedPropertyContextualTyping1.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
tests/cases/conformance/expressions/contextualTyping/implementedPropertyContextualTyping1.ts(21,3): error TS2322: Type 'number' is not assignable to type 'string'. | ||
tests/cases/conformance/expressions/contextualTyping/implementedPropertyContextualTyping1.ts(24,3): error TS2322: Type 'number' is not assignable to type 'string'. | ||
tests/cases/conformance/expressions/contextualTyping/implementedPropertyContextualTyping1.ts(28,3): error TS2322: Type 'number' is not assignable to type 'string'. | ||
tests/cases/conformance/expressions/contextualTyping/implementedPropertyContextualTyping1.ts(31,3): error TS2322: Type 'number' is not assignable to type 'string'. | ||
|
||
|
||
==== tests/cases/conformance/expressions/contextualTyping/implementedPropertyContextualTyping1.ts (4 errors) ==== | ||
interface Event { | ||
time: number; | ||
} | ||
interface Base { | ||
superHandle: (e: Event) => number; | ||
} | ||
interface Listener extends Base { | ||
handle: (e: Event) => void; | ||
} | ||
interface Ringer { | ||
ring: (times: number) => void; | ||
} | ||
|
||
abstract class Watcher { | ||
abstract watch(e: Event): number; | ||
} | ||
|
||
class Alarm extends Watcher implements Listener, Ringer { | ||
str: string; | ||
handle = e => { | ||
this.str = e.time; // error | ||
~~~~~~~~ | ||
!!! error TS2322: Type 'number' is not assignable to type 'string'. | ||
} | ||
superHandle = e => { | ||
this.str = e.time; // error | ||
~~~~~~~~ | ||
!!! error TS2322: Type 'number' is not assignable to type 'string'. | ||
return e.time; | ||
} | ||
ring(times) { | ||
this.str = times; // error | ||
~~~~~~~~ | ||
!!! error TS2322: Type 'number' is not assignable to type 'string'. | ||
} | ||
watch(e) { | ||
this.str = e.time; // error | ||
~~~~~~~~ | ||
!!! error TS2322: Type 'number' is not assignable to type 'string'. | ||
return e.time; | ||
} | ||
} |
Oops, something went wrong.