use resolved signature
This commit is contained in:
Родитель
09c5efad89
Коммит
069ad69b8a
|
@ -30912,16 +30912,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
}
|
||||
}
|
||||
|
||||
function getJsxElementTypeTypeAt(location: JsxOpeningLikeElement): Type | undefined {
|
||||
function getJsxElementTypeTypeAt(location: Node): Type | undefined {
|
||||
const ns = getJsxNamespaceAt(location);
|
||||
if (!ns) return undefined;
|
||||
const sym = getJsxElementTypeSymbol(ns);
|
||||
if (!sym) return undefined;
|
||||
const type = instantiateAliasOrInterfaceWithDefaults(
|
||||
sym,
|
||||
isInJSFile(location),
|
||||
...(location.typeArguments || emptyArray).map(getTypeFromTypeNode)
|
||||
);
|
||||
const type = instantiateAliasOrInterfaceWithDefaults(sym, isInJSFile(location));
|
||||
if (!type || isErrorType(type)) return undefined;
|
||||
return type;
|
||||
}
|
||||
|
@ -31016,7 +31012,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
const tagName = jsxOpeningLikeNode.tagName;
|
||||
const tagType = isJsxIntrinsicTagName(tagName)
|
||||
? getStringLiteralType(intrinsicTagNameToString(tagName))
|
||||
: checkExpression(tagName);
|
||||
: intersectTypes(getOrCreateTypeFromSignature(sig), checkExpression(tagName));
|
||||
checkTypeRelatedTo(tagType, elementTypeConstraint, assignableRelation, tagName, Diagnostics.Its_type_0_is_not_a_valid_JSX_element_type, () => {
|
||||
const componentName = getTextOfNode(tagName);
|
||||
return chainDiagnosticMessages(/*details*/ undefined, Diagnostics._0_cannot_be_used_as_a_JSX_component, componentName);
|
||||
|
|
|
@ -28,8 +28,8 @@ jsxElementType.tsx(72,20): error TS2769: No overload matches this call.
|
|||
jsxElementType.tsx(78,1): error TS2339: Property 'boop' does not exist on type 'JSX.IntrinsicElements'.
|
||||
jsxElementType.tsx(79,1): error TS2339: Property 'my-undeclared-custom-element' does not exist on type 'JSX.IntrinsicElements'.
|
||||
jsxElementType.tsx(91,2): error TS2786: 'ReactNativeFlatList' cannot be used as a JSX component.
|
||||
Its type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not a valid JSX element type.
|
||||
Type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not assignable to type '(props: any) => React18ReactNode'.
|
||||
Its type '((props: {}, ref: ForwardedRef<(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null>) => null) & ((props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null)' is not a valid JSX element type.
|
||||
Type '((props: {}, ref: ForwardedRef<(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null>) => null) & ((props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null)' is not assignable to type '(props: any) => React18ReactNode'.
|
||||
Target signature provides too few arguments. Expected 2 or more, but got 1.
|
||||
jsxElementType.tsx(95,11): error TS2322: Type '{}' is not assignable to type 'LibraryManagedAttributes<T, {}>'.
|
||||
jsxElementType.tsx(98,2): error TS2304: Cannot find name 'Unresolved'.
|
||||
|
@ -39,8 +39,9 @@ jsxElementType.tsx(110,6): error TS2322: Type '{ b: string; }' is not assignable
|
|||
jsxElementType.tsx(111,19): error TS2322: Type '{ a: string; b: string; }' is not assignable to type '{ a: string; }'.
|
||||
Property 'b' does not exist on type '{ a: string; }'.
|
||||
jsxElementType.tsx(125,22): error TS2786: 'A' cannot be used as a JSX component.
|
||||
Its return type 'Error' is not a valid JSX element.
|
||||
Type 'Error' is missing the following properties from type 'ReactElement<any>': type, props, key
|
||||
Its type '(({ a }: { a: number; }) => Error) & (<T extends unknown>({ a }: { a: T; }) => T extends string ? null : Error)' is not a valid JSX element type.
|
||||
Type '(({ a }: { a: number; }) => Error) & (<T extends unknown>({ a }: { a: T; }) => T extends string ? null : Error)' is not assignable to type '(props: any) => React18ReactNode'.
|
||||
Type 'Error' is not assignable to type 'React18ReactNode'.
|
||||
jsxElementType.tsx(125,32): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
|
@ -188,8 +189,8 @@ jsxElementType.tsx(125,32): error TS2322: Type 'string' is not assignable to typ
|
|||
<ReactNativeFlatList />;
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2786: 'ReactNativeFlatList' cannot be used as a JSX component.
|
||||
!!! error TS2786: Its type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not a valid JSX element type.
|
||||
!!! error TS2786: Type '(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null' is not assignable to type '(props: any) => React18ReactNode'.
|
||||
!!! error TS2786: Its type '((props: {}, ref: ForwardedRef<(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null>) => null) & ((props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null)' is not a valid JSX element type.
|
||||
!!! error TS2786: Type '((props: {}, ref: ForwardedRef<(props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null>) => null) & ((props: {}, ref: ForwardedRef<typeof ReactNativeFlatList>) => null)' is not assignable to type '(props: any) => React18ReactNode'.
|
||||
!!! error TS2786: Target signature provides too few arguments. Expected 2 or more, but got 1.
|
||||
|
||||
// testing higher-order component compat
|
||||
|
@ -239,8 +240,9 @@ jsxElementType.tsx(125,32): error TS2322: Type 'string' is not assignable to typ
|
|||
const jsxGeneric3 = <A<number> a="a" />;
|
||||
~
|
||||
!!! error TS2786: 'A' cannot be used as a JSX component.
|
||||
!!! error TS2786: Its return type 'Error' is not a valid JSX element.
|
||||
!!! error TS2786: Type 'Error' is missing the following properties from type 'ReactElement<any>': type, props, key
|
||||
!!! error TS2786: Its type '(({ a }: { a: number; }) => Error) & (<T extends unknown>({ a }: { a: T; }) => T extends string ? null : Error)' is not a valid JSX element type.
|
||||
!!! error TS2786: Type '(({ a }: { a: number; }) => Error) & (<T extends unknown>({ a }: { a: T; }) => T extends string ? null : Error)' is not assignable to type '(props: any) => React18ReactNode'.
|
||||
!!! error TS2786: Type 'Error' is not assignable to type 'React18ReactNode'.
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! related TS6500 jsxElementType.tsx:114:40: The expected type comes from property 'a' which is declared here on type 'IntrinsicAttributes & { a: number; }'
|
||||
|
|
Загрузка…
Ссылка в новой задаче