Fix/jsx syntax quickinfo (#42124)
* feat: add jsx type invalid check * feat: update jsxGenericQuickInfo test cases
This commit is contained in:
parent
fe297df9df
commit
ea03c2966b
|
@ -2695,7 +2695,7 @@ namespace ts {
|
|||
return symbol ? [symbol] : emptyArray;
|
||||
}
|
||||
|
||||
const discriminatedPropertySymbols = mapDefined(contextualType.types, t => isObjectLiteralExpression(node.parent) && checker.isTypeInvalidDueToUnionDiscriminant(t, node.parent) ? undefined : t.getProperty(name));
|
||||
const discriminatedPropertySymbols = mapDefined(contextualType.types, t => (isObjectLiteralExpression(node.parent)|| isJsxAttributes(node.parent)) && checker.isTypeInvalidDueToUnionDiscriminant(t, node.parent) ? undefined : t.getProperty(name));
|
||||
if (unionSymbolOk && (discriminatedPropertySymbols.length === 0 || discriminatedPropertySymbols.length === contextualType.types.length)) {
|
||||
const symbol = contextualType.getProperty(name);
|
||||
if (symbol) return [symbol];
|
||||
|
|
|
@ -6,17 +6,29 @@
|
|||
//// }
|
||||
//// interface ElementAttributesProperty { props }
|
||||
//// }
|
||||
//// interface Props<T> {
|
||||
//// items: T[];
|
||||
//// renderItem: (item: T) => string;
|
||||
//// interface PropsA<T> {
|
||||
//// /** comments for A */
|
||||
//// name: 'A',
|
||||
//// items: T[];
|
||||
//// renderItem: (item: T) => string;
|
||||
//// }
|
||||
//// interface PropsB<T> {
|
||||
//// /** comments for B */
|
||||
//// name: 'B',
|
||||
//// items: T[];
|
||||
//// renderItem: (item: T) => string;
|
||||
//// }
|
||||
//// class Component<T> {
|
||||
//// constructor(props: Props<T>) {}
|
||||
//// props: Props<T>;
|
||||
//// }
|
||||
//// var b = new Component({items: [0, 1, 2], render/*0*/Item: it/*1*/em => item.toFixed()});
|
||||
//// var c = <Component items={[0, 1, 2]} render/*2*/Item={it/*3*/em => item.toFixed()}
|
||||
verify.quickInfoAt("0", "(property) Props<number>.renderItem: (item: number) => string");
|
||||
//// constructor(props: PropsA<T> | PropsB<T>) {}
|
||||
//// props: PropsA<T> | PropsB<T>;
|
||||
//// }
|
||||
//// var b = new Component({items: [0, 1, 2], render/*0*/Item: it/*1*/em => item.toFixed(), name/*2*/: 'A',});
|
||||
//// var c = <Component items={[0, 1, 2]} render/*3*/Item={it/*4*/em => item.toFixed()} name/*5*/="A" />
|
||||
|
||||
|
||||
verify.quickInfoAt("0", "(property) PropsA<number>.renderItem: (item: number) => string");
|
||||
verify.quickInfoAt("1", "(parameter) item: number");
|
||||
verify.quickInfoAt("2", "(JSX attribute) Props<number>.renderItem: (item: number) => string");
|
||||
verify.quickInfoAt("3", "(parameter) item: number");
|
||||
verify.quickInfoAt("2", `(property) PropsA<T>.name: "A"`, 'comments for A');
|
||||
verify.quickInfoAt("3", "(JSX attribute) PropsA<number>.renderItem: (item: number) => string");
|
||||
verify.quickInfoAt("4", "(parameter) item: number");
|
||||
verify.quickInfoAt("5", `(JSX attribute) PropsA<T>.name: "A"`, 'comments for A');
|
||||
|
|
Loading…
Reference in a new issue