Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12728 from Microsoft/instanceof-requires-callable…
…-rhs Instanceof requires callable or constructable right-hand side
- Loading branch information
Showing
5 changed files
with
164 additions
and
2 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
34 changes: 34 additions & 0 deletions
34
tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.js
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,34 @@ | ||
//// [instanceofOperatorWithInvalidStaticToString.ts] | ||
declare class StaticToString { | ||
static toString(): void; | ||
} | ||
|
||
function foo(staticToString: StaticToString) { | ||
return staticToString instanceof StaticToString; | ||
} | ||
|
||
declare class StaticToNumber { | ||
static toNumber(): void; | ||
} | ||
function bar(staticToNumber: StaticToNumber) { | ||
return staticToNumber instanceof StaticToNumber; | ||
} | ||
|
||
declare class NormalToString { | ||
toString(): void; | ||
} | ||
function baz(normal: NormalToString) { | ||
return normal instanceof NormalToString; | ||
} | ||
|
||
|
||
//// [instanceofOperatorWithInvalidStaticToString.js] | ||
function foo(staticToString) { | ||
return staticToString instanceof StaticToString; | ||
} | ||
function bar(staticToNumber) { | ||
return staticToNumber instanceof StaticToNumber; | ||
} | ||
function baz(normal) { | ||
return normal instanceof NormalToString; | ||
} |
50 changes: 50 additions & 0 deletions
50
tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.symbols
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,50 @@ | ||
=== tests/cases/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidStaticToString.ts === | ||
declare class StaticToString { | ||
>StaticToString : Symbol(StaticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 0, 0)) | ||
|
||
static toString(): void; | ||
>toString : Symbol(StaticToString.toString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 0, 30)) | ||
} | ||
|
||
function foo(staticToString: StaticToString) { | ||
>foo : Symbol(foo, Decl(instanceofOperatorWithInvalidStaticToString.ts, 2, 1)) | ||
>staticToString : Symbol(staticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 4, 13)) | ||
>StaticToString : Symbol(StaticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 0, 0)) | ||
|
||
return staticToString instanceof StaticToString; | ||
>staticToString : Symbol(staticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 4, 13)) | ||
>StaticToString : Symbol(StaticToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 0, 0)) | ||
} | ||
|
||
declare class StaticToNumber { | ||
>StaticToNumber : Symbol(StaticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 6, 1)) | ||
|
||
static toNumber(): void; | ||
>toNumber : Symbol(StaticToNumber.toNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 8, 30)) | ||
} | ||
function bar(staticToNumber: StaticToNumber) { | ||
>bar : Symbol(bar, Decl(instanceofOperatorWithInvalidStaticToString.ts, 10, 1)) | ||
>staticToNumber : Symbol(staticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 11, 13)) | ||
>StaticToNumber : Symbol(StaticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 6, 1)) | ||
|
||
return staticToNumber instanceof StaticToNumber; | ||
>staticToNumber : Symbol(staticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 11, 13)) | ||
>StaticToNumber : Symbol(StaticToNumber, Decl(instanceofOperatorWithInvalidStaticToString.ts, 6, 1)) | ||
} | ||
|
||
declare class NormalToString { | ||
>NormalToString : Symbol(NormalToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 13, 1)) | ||
|
||
toString(): void; | ||
>toString : Symbol(NormalToString.toString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 15, 30)) | ||
} | ||
function baz(normal: NormalToString) { | ||
>baz : Symbol(baz, Decl(instanceofOperatorWithInvalidStaticToString.ts, 17, 1)) | ||
>normal : Symbol(normal, Decl(instanceofOperatorWithInvalidStaticToString.ts, 18, 13)) | ||
>NormalToString : Symbol(NormalToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 13, 1)) | ||
|
||
return normal instanceof NormalToString; | ||
>normal : Symbol(normal, Decl(instanceofOperatorWithInvalidStaticToString.ts, 18, 13)) | ||
>NormalToString : Symbol(NormalToString, Decl(instanceofOperatorWithInvalidStaticToString.ts, 13, 1)) | ||
} | ||
|
53 changes: 53 additions & 0 deletions
53
tests/baselines/reference/instanceofOperatorWithInvalidStaticToString.types
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,53 @@ | ||
=== tests/cases/conformance/expressions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidStaticToString.ts === | ||
declare class StaticToString { | ||
>StaticToString : StaticToString | ||
|
||
static toString(): void; | ||
>toString : () => void | ||
} | ||
|
||
function foo(staticToString: StaticToString) { | ||
>foo : (staticToString: StaticToString) => boolean | ||
>staticToString : StaticToString | ||
>StaticToString : StaticToString | ||
|
||
return staticToString instanceof StaticToString; | ||
>staticToString instanceof StaticToString : boolean | ||
>staticToString : StaticToString | ||
>StaticToString : typeof StaticToString | ||
} | ||
|
||
declare class StaticToNumber { | ||
>StaticToNumber : StaticToNumber | ||
|
||
static toNumber(): void; | ||
>toNumber : () => void | ||
} | ||
function bar(staticToNumber: StaticToNumber) { | ||
>bar : (staticToNumber: StaticToNumber) => boolean | ||
>staticToNumber : StaticToNumber | ||
>StaticToNumber : StaticToNumber | ||
|
||
return staticToNumber instanceof StaticToNumber; | ||
>staticToNumber instanceof StaticToNumber : boolean | ||
>staticToNumber : StaticToNumber | ||
>StaticToNumber : typeof StaticToNumber | ||
} | ||
|
||
declare class NormalToString { | ||
>NormalToString : NormalToString | ||
|
||
toString(): void; | ||
>toString : () => void | ||
} | ||
function baz(normal: NormalToString) { | ||
>baz : (normal: NormalToString) => boolean | ||
>normal : NormalToString | ||
>NormalToString : NormalToString | ||
|
||
return normal instanceof NormalToString; | ||
>normal instanceof NormalToString : boolean | ||
>normal : NormalToString | ||
>NormalToString : typeof NormalToString | ||
} | ||
|
21 changes: 21 additions & 0 deletions
21
...essions/binaryOperators/instanceofOperator/instanceofOperatorWithInvalidStaticToString.ts
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,21 @@ | ||
declare class StaticToString { | ||
static toString(): void; | ||
} | ||
|
||
function foo(staticToString: StaticToString) { | ||
return staticToString instanceof StaticToString; | ||
} | ||
|
||
declare class StaticToNumber { | ||
static toNumber(): void; | ||
} | ||
function bar(staticToNumber: StaticToNumber) { | ||
return staticToNumber instanceof StaticToNumber; | ||
} | ||
|
||
declare class NormalToString { | ||
toString(): void; | ||
} | ||
function baz(normal: NormalToString) { | ||
return normal instanceof NormalToString; | ||
} |