Conversation
This handles support for microsoft/TypeScript#22415
src/compiler/checker.ts Outdated
min = Math.min(min, getMinTypeArgumentCount(sig.typeParameters)); | ||
max = Math.max(max, length(sig.typeParameters)); | ||
} | ||
const paramCount = min < max ? min + "-" + max : min; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would find min === max ? min : min + "-" + max
clearer
src/compiler/checker.ts Outdated
@@ -17337,6 +17380,17 @@ namespace ts { | |||
} | |||
} | |||
function getTypeArgumentArityError(node: Node, signatures: Signature[], typeArguments: NodeArray<TypeNode>) { | |||
let min = Number.POSITIVE_INFINITY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why the original author didn't just use Infinity
/ -Infinity
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have nitty comments in moved code that can be ignored 👍
I don't think we have a formal process right now, but pinging @Andy-MS seems like a decent way to check. 😝 |
@weswigham Really great this finally made it into the language! Question: When tsconfig is set to |
It seems that one has to explicitly specify the type, as oppose to that the compiler can infer the type from the value. What I mean is that in JSX, say I have the component below
when I use MyComp, in the code below, specify the type number, otherwise the val variable will not have type of number.
However, If I omit specifying the type number, the val variable will be type of {}.
This seems to be a bug, because compare to Generics in regular class, like below., the type of number does not have to be explicitly specified.
|
@marty-wang IIUC, I think what you're seeing is #22636 |
@andrewbranch yes, it is the same issue. In #22636 @mhegazy seems saying it would be addressed in 2.9. However, at least it is not yet in 2.9.0-dev.20180503. |
#23492 has yet to be merged |
@weswigham sweet! thanks! |
Question, What would be best way to pass a generic type to a child component?
|
@weswigham i was getting a
|
Oh i guess i should of mentioned that List accepts a generic type
|
You need to constrained your |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
Allows, eg,
in
.tsx
files.Fixes #6395.
Was there a list of things we were concerned wouldn't parse well? AFAIK, this is actually easy for us to unambiguously parse.