Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arguments to tagged templates are not checked #3936

Closed
vkurchatkin opened this issue May 15, 2017 · 4 comments
Closed

Arguments to tagged templates are not checked #3936

vkurchatkin opened this issue May 15, 2017 · 4 comments
Assignees
Labels
incompleteness Something is missing Typing: soundness No false negatives (type checker claims that there is no error in the incorrect program)

Comments

@vkurchatkin
Copy link
Contributor

This should be an error:

declare function foo(a: Array<string>, b: string): string;

foo`x${1}`;
@bwestergard
Copy link

Relatedly, can we ensure that if treated as a variadic function, that arguments 1..N have a given type? This, for instance, should error:

function myTag(strings, ...exps: Array<number>) {
  return exps.reduce((a, b) = a + b, 0)
}

var output = myTag`foo ${ null } bar ${ 3 }`;

console.log(output);

https://flow.org/try/#0GYVwdgxgLglg9mABAWwJ4BUCGBzAFAZygCcYxt8AaRAOloFMAPAB3wC5EBBIozVAHjAhkAIzpEAfAEpEAbwBQjFnIC+cuQDdMRRHBBQmexAF4UGHAANgcOIgAkMxIIA2TxMsTCtdhwGY35gG41CAR8OCc6aic4PF19PUkAoA

@sibelius
Copy link

this would be good for styled-components

any progress on this?

@mroch mroch added the Typing: soundness No false negatives (type checker claims that there is no error in the incorrect program) label Jan 18, 2019
@mroch mroch self-assigned this Jan 18, 2019
@mroch
Copy link
Contributor

mroch commented Jan 18, 2019

fix incoming

@kitten
Copy link

kitten commented Jan 22, 2019

@mroch I'd like to say thank you for fixing this ❤️ I tried to fix this myself before but I've only ever dived into the parser implementation. I knew it was going to be a short fix but wow! I'm glad that it's finally going to be possible to properly implement styled-components/emotion Flow typings 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incompleteness Something is missing Typing: soundness No false negatives (type checker claims that there is no error in the incorrect program)
Projects
None yet
Development

No branches or pull requests

5 participants