-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Type inference in JSX broke in nightly build #27986
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
Comments
Likely a duplicate of #27948 |
@DanielRosenwasser Sure? I've created a a more simple repro. import * as React from "react";
interface ErrorResult { error: true }
interface AsyncLoaderProps<TResult> {
readonly prop1: () => Promise<TResult>;
readonly prop2: (result: Exclude<TResult, ErrorResult>) => any;
// readonly prop2: (result: TResult) => any; // No error without the `Exclude<>`
}
class AsyncLoader<TResult> extends React.Component<AsyncLoaderProps<TResult>> {
render() { return null; }
}
async function load(): Promise<{ success: true } | ErrorResult> {
return { success: true };
}
const loader = <AsyncLoader
prop1={load}
prop2={result => result}
/>; Note that when replacing the So it seems that the parameter type of |
:doubt: It's probably not; that only has to do with tags with multiple signatures. |
@weswigham I really don't know why, ... but since updating I've tacked it down and it happened exactly with I've generated a diff of these two versions: Compare.pdf And here are the full packages: both_versions.zip Could you maybe have a look at this? |
@ulrichb could you open a new issue so it's easier to track? |
@weswigham Of course. Here it is. |
TypeScript Version: 3.2.0-dev.20181019
Search Terms: react jsx type inference
Code
TSC call:
npx tsc -t es2017 -m commonjs --jsx react --strict src/TypeScriptIssue.tsx
(Without
--strict
there is no compile error.)Expected behavior:
No compile error.
Actual behavior:
This is a regression in 3.2.0. Code compiles in 3.1.3.
The text was updated successfully, but these errors were encountered: