-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tagged templates can return any type, not just strings
Summary: Fixes #579 Closes #580 Reviewed By: @jeffmo Differential Revision: D2198666 Pulled By: @mroch
- Loading branch information
1 parent
f98eec7
commit 276f7f4
Showing
3 changed files
with
16 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
class A { } | ||
var a = new A(); | ||
var s1 = `l${a.x}r`; | ||
var s1 = `l${a.x}r`; // error: no prop x in A | ||
|
||
function tag(strings,...values) { | ||
var x:number = strings[0]; | ||
var x:number = strings[0]; // error: string ~> number | ||
return x; | ||
} | ||
var s2 = tag `l${42}r`; | ||
|
||
function tag2(strings,...values) { | ||
return { foo: "" }; // ok: tagged templates can return whatever | ||
} | ||
|
||
var s3 = tag2 `la la la`; | ||
(s3.foo: number); // error: string ~> number |