mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Unify JSX And Normal Call Checking Codepaths (#27627)
* Unify JSX Call Checking Codepaths * Add tests for fixed issues * Fix lint, move all error checking into the only-run-once resolveSignature call * Remove unused (unreachable?) code path * Consolidate a little more duplicated logic into signature checking * Fix #19775 a bit more * Cosmetic changes from CR
This commit is contained in:
+224
-565
File diff suppressed because it is too large
Load Diff
@@ -3103,8 +3103,6 @@ namespace ts {
|
||||
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
|
||||
/** Unlike `getExportsOfModule`, this includes properties of an `export =` value. */
|
||||
/* @internal */ getExportsAndPropertiesOfModule(moduleSymbol: Symbol): Symbol[];
|
||||
|
||||
getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type | undefined;
|
||||
getJsxIntrinsicTagNamesAt(location: Node): Symbol[];
|
||||
isOptionalParameter(node: ParameterDeclaration): boolean;
|
||||
getAmbientModules(): Symbol[];
|
||||
@@ -3171,7 +3169,7 @@ namespace ts {
|
||||
* True if `contextualType` should not be considered for completions because
|
||||
* e.g. it specifies `kind: "a"` and obj has `kind: "b"`.
|
||||
*/
|
||||
/* @internal */ isTypeInvalidDueToUnionDiscriminant(contextualType: Type, obj: ObjectLiteralExpression): boolean;
|
||||
/* @internal */ isTypeInvalidDueToUnionDiscriminant(contextualType: Type, obj: ObjectLiteralExpression | JsxAttributes): boolean;
|
||||
/**
|
||||
* For a union, will include a property if it's defined in *any* of the member types.
|
||||
* So for `{ a } | { b }`, this will include both `a` and `b`.
|
||||
@@ -3769,7 +3767,6 @@ namespace ts {
|
||||
resolvedType?: Type; // Cached type of type node
|
||||
resolvedEnumType?: Type; // Cached constraint type from enum jsdoc tag
|
||||
resolvedSignature?: Signature; // Cached signature of signature node or call expression
|
||||
resolvedSignatures?: Map<Signature[]>; // Cached signatures of jsx node
|
||||
resolvedSymbol?: Symbol; // Cached name resolution result
|
||||
resolvedIndexInfo?: IndexInfo; // Cached indexing info resolution result
|
||||
maybeTypePredicate?: boolean; // Cached check whether call expression might reference a type predicate
|
||||
|
||||
@@ -1200,9 +1200,9 @@ namespace ts.Completions {
|
||||
function tryGetJsxCompletionSymbols(): GlobalsSearch {
|
||||
const jsxContainer = tryGetContainingJsxElement(contextToken);
|
||||
// Cursor is inside a JSX self-closing element or opening element
|
||||
const attrsType = jsxContainer && typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer);
|
||||
const attrsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes);
|
||||
if (!attrsType) return GlobalsSearch.Continue;
|
||||
symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer!.attributes.properties);
|
||||
symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, jsxContainer!.attributes, typeChecker), jsxContainer!.attributes.properties);
|
||||
completionKind = CompletionKind.MemberLike;
|
||||
isNewIdentifierLocation = false;
|
||||
return GlobalsSearch.Success;
|
||||
@@ -2211,7 +2211,7 @@ namespace ts.Completions {
|
||||
return jsdoc && jsdoc.tags && (rangeContainsPosition(jsdoc, position) ? findLast(jsdoc.tags, tag => tag.pos < position) : undefined);
|
||||
}
|
||||
|
||||
function getPropertiesForObjectExpression(contextualType: Type, obj: ObjectLiteralExpression, checker: TypeChecker): Symbol[] {
|
||||
function getPropertiesForObjectExpression(contextualType: Type, obj: ObjectLiteralExpression | JsxAttributes, checker: TypeChecker): Symbol[] {
|
||||
return contextualType.isUnion()
|
||||
? checker.getAllPossiblePropertiesOfTypes(contextualType.types.filter(memberType =>
|
||||
// If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals.
|
||||
|
||||
@@ -1941,7 +1941,6 @@ declare namespace ts {
|
||||
/** Follow all aliases to get the original symbol. */
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
|
||||
getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type | undefined;
|
||||
getJsxIntrinsicTagNamesAt(location: Node): Symbol[];
|
||||
isOptionalParameter(node: ParameterDeclaration): boolean;
|
||||
getAmbientModules(): Symbol[];
|
||||
|
||||
@@ -1941,7 +1941,6 @@ declare namespace ts {
|
||||
/** Follow all aliases to get the original symbol. */
|
||||
getAliasedSymbol(symbol: Symbol): Symbol;
|
||||
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
|
||||
getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type | undefined;
|
||||
getJsxIntrinsicTagNamesAt(location: Node): Symbol[];
|
||||
isOptionalParameter(node: ParameterDeclaration): boolean;
|
||||
getAmbientModules(): Symbol[];
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
tests/cases/conformance/jsx/file.tsx(42,11): error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'SingleChildProp'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type 'Element[]' is not assignable to type 'Element'.
|
||||
Property 'type' is missing in type 'Element[]'.
|
||||
tests/cases/conformance/jsx/file.tsx(42,11): error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & SingleChildProp'.
|
||||
Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'SingleChildProp'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type 'Element[]' is not assignable to type 'Element'.
|
||||
Property 'type' is missing in type 'Element[]'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
@@ -48,7 +49,8 @@ tests/cases/conformance/jsx/file.tsx(42,11): error TS2322: Type '{ children: Ele
|
||||
// Error
|
||||
let k5 = <SingleChildComp a={10} b="hi"><></><Button /><AnotherButton /></SingleChildComp>;
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'SingleChildProp'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type 'Element[]' is not assignable to type 'Element'.
|
||||
!!! error TS2322: Property 'type' is missing in type 'Element[]'.
|
||||
!!! error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & SingleChildProp'.
|
||||
!!! error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'SingleChildProp'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type 'Element[]' is not assignable to type 'Element'.
|
||||
!!! error TS2322: Property 'type' is missing in type 'Element[]'.
|
||||
@@ -1,26 +1,31 @@
|
||||
tests/cases/conformance/jsx/file.tsx(14,10): error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Property 'children' is missing in type '{ a: number; b: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(14,10): error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
Type '{ a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Property 'children' is missing in type '{ a: number; b: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(17,11): error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten.
|
||||
tests/cases/conformance/jsx/file.tsx(31,6): error TS2322: Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type '(Element | ((name: string) => Element))[]' is not assignable to type 'string | Element'.
|
||||
Type '(Element | ((name: string) => Element))[]' is not assignable to type 'Element'.
|
||||
Property 'type' is missing in type '(Element | ((name: string) => Element))[]'.
|
||||
tests/cases/conformance/jsx/file.tsx(37,6): error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type '(number | Element)[]' is not assignable to type 'string | Element'.
|
||||
Type '(number | Element)[]' is not assignable to type 'Element'.
|
||||
Property 'type' is missing in type '(number | Element)[]'.
|
||||
tests/cases/conformance/jsx/file.tsx(43,6): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type '(string | Element)[]' is not assignable to type 'string | Element'.
|
||||
Type '(string | Element)[]' is not assignable to type 'Element'.
|
||||
Property 'type' is missing in type '(string | Element)[]'.
|
||||
tests/cases/conformance/jsx/file.tsx(49,6): error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type 'Element[]' is not assignable to type 'string | Element'.
|
||||
Type 'Element[]' is not assignable to type 'Element'.
|
||||
Property 'type' is missing in type 'Element[]'.
|
||||
tests/cases/conformance/jsx/file.tsx(31,6): error TS2322: Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type '(Element | ((name: string) => Element))[]' is not assignable to type 'string | Element'.
|
||||
Type '(Element | ((name: string) => Element))[]' is not assignable to type 'Element'.
|
||||
Property 'type' is missing in type '(Element | ((name: string) => Element))[]'.
|
||||
tests/cases/conformance/jsx/file.tsx(37,6): error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type '(number | Element)[]' is not assignable to type 'string | Element'.
|
||||
Type '(number | Element)[]' is not assignable to type 'Element'.
|
||||
Property 'type' is missing in type '(number | Element)[]'.
|
||||
tests/cases/conformance/jsx/file.tsx(43,6): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type '(string | Element)[]' is not assignable to type 'string | Element'.
|
||||
Type '(string | Element)[]' is not assignable to type 'Element'.
|
||||
Property 'type' is missing in type '(string | Element)[]'.
|
||||
tests/cases/conformance/jsx/file.tsx(49,6): error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type 'Element[]' is not assignable to type 'string | Element'.
|
||||
Type 'Element[]' is not assignable to type 'Element'.
|
||||
Property 'type' is missing in type 'Element[]'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (6 errors) ====
|
||||
@@ -39,8 +44,9 @@ tests/cases/conformance/jsx/file.tsx(49,6): error TS2322: Type '{ children: Elem
|
||||
// Error: missing children
|
||||
let k = <Comp a={10} b="hi" />;
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Property 'children' is missing in type '{ a: number; b: string; }'.
|
||||
!!! error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
!!! error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Property 'children' is missing in type '{ a: number; b: string; }'.
|
||||
|
||||
let k0 =
|
||||
<Comp a={10} b="hi" children="Random" >
|
||||
@@ -61,11 +67,12 @@ tests/cases/conformance/jsx/file.tsx(49,6): error TS2322: Type '{ children: Elem
|
||||
let k2 =
|
||||
<Comp a={10} b="hi">
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type '(Element | ((name: string) => Element))[]' is not assignable to type 'string | Element'.
|
||||
!!! error TS2322: Type '(Element | ((name: string) => Element))[]' is not assignable to type 'Element'.
|
||||
!!! error TS2322: Property 'type' is missing in type '(Element | ((name: string) => Element))[]'.
|
||||
!!! error TS2322: Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
!!! error TS2322: Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type '(Element | ((name: string) => Element))[]' is not assignable to type 'string | Element'.
|
||||
!!! error TS2322: Type '(Element | ((name: string) => Element))[]' is not assignable to type 'Element'.
|
||||
!!! error TS2322: Property 'type' is missing in type '(Element | ((name: string) => Element))[]'.
|
||||
<div> My Div </div>
|
||||
{(name: string) => <div> My name {name} </div>}
|
||||
</Comp>;
|
||||
@@ -73,11 +80,12 @@ tests/cases/conformance/jsx/file.tsx(49,6): error TS2322: Type '{ children: Elem
|
||||
let k3 =
|
||||
<Comp a={10} b="hi">
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type '(number | Element)[]' is not assignable to type 'string | Element'.
|
||||
!!! error TS2322: Type '(number | Element)[]' is not assignable to type 'Element'.
|
||||
!!! error TS2322: Property 'type' is missing in type '(number | Element)[]'.
|
||||
!!! error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
!!! error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type '(number | Element)[]' is not assignable to type 'string | Element'.
|
||||
!!! error TS2322: Type '(number | Element)[]' is not assignable to type 'Element'.
|
||||
!!! error TS2322: Property 'type' is missing in type '(number | Element)[]'.
|
||||
<div> My Div </div>
|
||||
{1000000}
|
||||
</Comp>;
|
||||
@@ -85,11 +93,12 @@ tests/cases/conformance/jsx/file.tsx(49,6): error TS2322: Type '{ children: Elem
|
||||
let k4 =
|
||||
<Comp a={10} b="hi" >
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'string | Element'.
|
||||
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element'.
|
||||
!!! error TS2322: Property 'type' is missing in type '(string | Element)[]'.
|
||||
!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'string | Element'.
|
||||
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element'.
|
||||
!!! error TS2322: Property 'type' is missing in type '(string | Element)[]'.
|
||||
<div> My Div </div>
|
||||
hi hi hi!
|
||||
</Comp>;
|
||||
@@ -97,11 +106,12 @@ tests/cases/conformance/jsx/file.tsx(49,6): error TS2322: Type '{ children: Elem
|
||||
let k5 =
|
||||
<Comp a={10} b="hi" >
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type 'Element[]' is not assignable to type 'string | Element'.
|
||||
!!! error TS2322: Type 'Element[]' is not assignable to type 'Element'.
|
||||
!!! error TS2322: Property 'type' is missing in type 'Element[]'.
|
||||
!!! error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
!!! error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type 'Element[]' is not assignable to type 'string | Element'.
|
||||
!!! error TS2322: Type 'Element[]' is not assignable to type 'Element'.
|
||||
!!! error TS2322: Property 'type' is missing in type 'Element[]'.
|
||||
<div> My Div </div>
|
||||
<div> My Div </div>
|
||||
</Comp>;
|
||||
@@ -1,13 +1,16 @@
|
||||
tests/cases/conformance/jsx/file.tsx(20,10): error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Property 'children' is missing in type '{ a: number; b: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(24,6): error TS2322: Type '{ children: Element; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type 'Element' is not assignable to type 'Button'.
|
||||
Property 'render' is missing in type 'Element'.
|
||||
tests/cases/conformance/jsx/file.tsx(28,6): error TS2322: Type '{ children: typeof Button; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type 'typeof Button' is not assignable to type 'Button'.
|
||||
Property 'render' is missing in type 'typeof Button'.
|
||||
tests/cases/conformance/jsx/file.tsx(20,10): error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
Type '{ a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Property 'children' is missing in type '{ a: number; b: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(24,6): error TS2322: Type '{ children: Element; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
Type '{ children: Element; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type 'Element' is not assignable to type 'Button'.
|
||||
Property 'render' is missing in type 'Element'.
|
||||
tests/cases/conformance/jsx/file.tsx(28,6): error TS2322: Type '{ children: typeof Button; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
Type '{ children: typeof Button; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type 'typeof Button' is not assignable to type 'Button'.
|
||||
Property 'render' is missing in type 'typeof Button'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
|
||||
@@ -32,25 +35,28 @@ tests/cases/conformance/jsx/file.tsx(28,6): error TS2322: Type '{ children: type
|
||||
// Error: no children specified
|
||||
let k = <Comp a={10} b="hi" />;
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Property 'children' is missing in type '{ a: number; b: string; }'.
|
||||
!!! error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
!!! error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Property 'children' is missing in type '{ a: number; b: string; }'.
|
||||
|
||||
// Error: JSX.element is not the same as JSX.ElementClass
|
||||
let k1 =
|
||||
<Comp a={10} b="hi">
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ children: Element; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type 'Element' is not assignable to type 'Button'.
|
||||
!!! error TS2322: Property 'render' is missing in type 'Element'.
|
||||
!!! error TS2322: Type '{ children: Element; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
!!! error TS2322: Type '{ children: Element; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type 'Element' is not assignable to type 'Button'.
|
||||
!!! error TS2322: Property 'render' is missing in type 'Element'.
|
||||
<Button />
|
||||
</Comp>;
|
||||
let k2 =
|
||||
<Comp a={10} b="hi">
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ children: typeof Button; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type 'typeof Button' is not assignable to type 'Button'.
|
||||
!!! error TS2322: Property 'render' is missing in type 'typeof Button'.
|
||||
!!! error TS2322: Type '{ children: typeof Button; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
!!! error TS2322: Type '{ children: typeof Button; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type 'typeof Button' is not assignable to type 'Button'.
|
||||
!!! error TS2322: Property 'render' is missing in type 'typeof Button'.
|
||||
{Button}
|
||||
</Comp>;
|
||||
@@ -1,17 +1,20 @@
|
||||
tests/cases/conformance/jsx/file.tsx(24,11): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
|
||||
Type '(string | Element)[]' is not assignable to type 'Element[]'.
|
||||
Type 'string | Element' is not assignable to type 'Element'.
|
||||
Type 'string' is not assignable to type 'Element'.
|
||||
tests/cases/conformance/jsx/file.tsx(25,11): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
|
||||
Type '(string | Element)[]' is not assignable to type 'Element[]'.
|
||||
tests/cases/conformance/jsx/file.tsx(27,11): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
|
||||
Type '(string | Element)[]' is not assignable to type 'Element[]'.
|
||||
tests/cases/conformance/jsx/file.tsx(24,11): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
|
||||
Type '(string | Element)[]' is not assignable to type 'Element[]'.
|
||||
Type 'string | Element' is not assignable to type 'Element'.
|
||||
Type 'string' is not assignable to type 'Element'.
|
||||
tests/cases/conformance/jsx/file.tsx(25,11): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
|
||||
Type '(string | Element)[]' is not assignable to type 'Element[]'.
|
||||
tests/cases/conformance/jsx/file.tsx(27,11): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
|
||||
Type '(string | Element)[]' is not assignable to type 'Element[]'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
|
||||
@@ -40,23 +43,26 @@ tests/cases/conformance/jsx/file.tsx(27,11): error TS2322: Type '{ children: (st
|
||||
// Error: whitespaces matters
|
||||
let k1 = <Comp a={10} b="hi"><Button /> <AnotherButton /></Comp>;
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
|
||||
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element[]'.
|
||||
!!! error TS2322: Type 'string | Element' is not assignable to type 'Element'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'Element'.
|
||||
!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
|
||||
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element[]'.
|
||||
!!! error TS2322: Type 'string | Element' is not assignable to type 'Element'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'Element'.
|
||||
let k2 = <Comp a={10} b="hi"><Button />
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
|
||||
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element[]'.
|
||||
!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
|
||||
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element[]'.
|
||||
<AnotherButton /> </Comp>;
|
||||
let k3 = <Comp a={10} b="hi"> <Button />
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
|
||||
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element[]'.
|
||||
!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
|
||||
!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
|
||||
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element[]'.
|
||||
<AnotherButton /></Comp>;
|
||||
@@ -1,6 +1,4 @@
|
||||
tests/cases/conformance/jsx/file.tsx(13,54): error TS2322: Type '(a: { x: string; }) => string' is not assignable to type '((a: { x: string; }) => string) & ((cur: { x: string; }) => { x: string; })'.
|
||||
Type '(a: { x: string; }) => string' is not assignable to type '(cur: { x: string; }) => { x: string; }'.
|
||||
Type 'string' is not assignable to type '{ x: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(13,71): error TS2322: Type 'string' is not assignable to type '{ x: string; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
@@ -17,8 +15,6 @@ tests/cases/conformance/jsx/file.tsx(13,54): error TS2322: Type '(a: { x: string
|
||||
let b = <GenericComponent initialValues={12} nextValues={a => a} />; // No error - Values should be reinstantiated with `number` (since `object` is a default, not a constraint)
|
||||
let c = <GenericComponent initialValues={{ x: "y" }} nextValues={a => ({ x: a.x })} />; // No Error
|
||||
let d = <GenericComponent initialValues={{ x: "y" }} nextValues={a => a.x} />; // Error - `string` is not assignable to `{x: string}`
|
||||
~~~~~~~~~~
|
||||
!!! error TS2322: Type '(a: { x: string; }) => string' is not assignable to type '((a: { x: string; }) => string) & ((cur: { x: string; }) => { x: string; })'.
|
||||
!!! error TS2322: Type '(a: { x: string; }) => string' is not assignable to type '(cur: { x: string; }) => { x: string; }'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type '{ x: string; }'.
|
||||
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:13:54: The expected type comes from property 'nextValues' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<GenericComponent<{ initialValues: { x: string; }; nextValues: (a: { x: string; }) => string; }, { x: string; }>> & { initialValues: { x: string; }; nextValues: (a: { x: string; }) => string; } & BaseProps<{ x: string; }> & { children?: ReactNode; }'
|
||||
~~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type '{ x: string; }'.
|
||||
!!! related TS6502 tests/cases/conformance/jsx/file.tsx:4:15: The expected type comes from the return type of this signature.
|
||||
@@ -36,11 +36,11 @@ const FooComponent = (props: { foo: "A" | "B" | "C" }) => <span>{props.foo}</spa
|
||||
<FooComponent foo={"f"} />;
|
||||
><FooComponent foo={"f"} /> : JSX.Element
|
||||
>FooComponent : (props: { foo: "A" | "B" | "C"; }) => JSX.Element
|
||||
>foo : "f"
|
||||
>foo : string
|
||||
>"f" : "f"
|
||||
|
||||
<FooComponent foo="f" />;
|
||||
><FooComponent foo="f" /> : JSX.Element
|
||||
>FooComponent : (props: { foo: "A" | "B" | "C"; }) => JSX.Element
|
||||
>foo : "f"
|
||||
>foo : string
|
||||
|
||||
|
||||
+28
-20
@@ -1,11 +1,15 @@
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(27,13): error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'LinkProps'.
|
||||
Property 'goTo' is missing in type '{ extra: true; onClick: (k: "left" | "right") => void; }'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(28,13): error TS2322: Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'LinkProps'.
|
||||
Property 'goTo' is missing in type '{ onClick: (k: "left" | "right") => void; extra: true; }'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(29,43): error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(30,36): error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(33,65): error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,44): error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(27,13): error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(28,13): error TS2322: Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
Property 'onClick' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(29,13): error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(30,13): error TS2322: Type '{ goTo: "home"; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(33,13): error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'.
|
||||
Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'.
|
||||
tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,13): error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx (6 errors) ====
|
||||
@@ -37,26 +41,30 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,44): err
|
||||
|
||||
const b0 = <MainButton {...{onClick: (k) => {console.log(k)}}} extra />; // k has type "left" | "right"
|
||||
~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'LinkProps'.
|
||||
!!! error TS2322: Property 'goTo' is missing in type '{ extra: true; onClick: (k: "left" | "right") => void; }'.
|
||||
!!! error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
const b2 = <MainButton onClick={(k)=>{console.log(k)}} extra />; // k has type "left" | "right"
|
||||
~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'LinkProps'.
|
||||
!!! error TS2322: Property 'goTo' is missing in type '{ onClick: (k: "left" | "right") => void; extra: true; }'.
|
||||
!!! error TS2322: Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
!!! error TS2322: Property 'onClick' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
const b3 = <MainButton {...{goTo:"home"}} extra />; // goTo has type"home" | "contact"
|
||||
~~~~~
|
||||
!!! error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
const b4 = <MainButton goTo="home" extra />; // goTo has type "home" | "contact"
|
||||
~~~~~
|
||||
!!! error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ goTo: "home"; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
|
||||
export function NoOverload(buttonProps: ButtonProps): JSX.Element { return undefined }
|
||||
const c1 = <NoOverload {...{onClick: (k) => {console.log(k)}}} extra />; // k has type any
|
||||
~~~~~
|
||||
!!! error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'.
|
||||
~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'.
|
||||
!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'.
|
||||
|
||||
export function NoOverload1(linkProps: LinkProps): JSX.Element { return undefined }
|
||||
const d1 = <NoOverload1 {...{goTo:"home"}} extra />; // goTo has type "home" | "contact"
|
||||
~~~~~
|
||||
!!! error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'.
|
||||
!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'.
|
||||
|
||||
@@ -95,8 +95,8 @@ const b3 = <MainButton {...{goTo:"home"}} extra />; // goTo has type"home" | "c
|
||||
>b3 : JSX.Element
|
||||
><MainButton {...{goTo:"home"}} extra /> : JSX.Element
|
||||
>MainButton : { (buttonProps: ButtonProps): JSX.Element; (linkProps: LinkProps): JSX.Element; }
|
||||
>{goTo:"home"} : { goTo: "home"; }
|
||||
>goTo : "home"
|
||||
>{goTo:"home"} : { goTo: string; }
|
||||
>goTo : string
|
||||
>"home" : "home"
|
||||
>extra : true
|
||||
|
||||
@@ -104,7 +104,7 @@ const b4 = <MainButton goTo="home" extra />; // goTo has type "home" | "contact
|
||||
>b4 : JSX.Element
|
||||
><MainButton goTo="home" extra /> : JSX.Element
|
||||
>MainButton : { (buttonProps: ButtonProps): JSX.Element; (linkProps: LinkProps): JSX.Element; }
|
||||
>goTo : "home"
|
||||
>goTo : string
|
||||
>extra : true
|
||||
|
||||
export function NoOverload(buttonProps: ButtonProps): JSX.Element { return undefined }
|
||||
@@ -138,8 +138,8 @@ const d1 = <NoOverload1 {...{goTo:"home"}} extra />; // goTo has type "home" |
|
||||
>d1 : JSX.Element
|
||||
><NoOverload1 {...{goTo:"home"}} extra /> : JSX.Element
|
||||
>NoOverload1 : (linkProps: LinkProps) => JSX.Element
|
||||
>{goTo:"home"} : { goTo: "home"; }
|
||||
>goTo : "home"
|
||||
>{goTo:"home"} : { goTo: string; }
|
||||
>goTo : string
|
||||
>"home" : "home"
|
||||
>extra : true
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
tests/cases/compiler/excessPropertyCheckWithSpread.ts(6,3): error TS2345: Argument of type '{ n: number; a: number; }' is not assignable to parameter of type '{ a: any; }'.
|
||||
Object literal may only specify known properties, and 'n' does not exist in type '{ a: any; }'.
|
||||
tests/cases/compiler/excessPropertyCheckWithSpread.ts(16,3): error TS2345: Argument of type '{ opt: string | number; a: number; }' is not assignable to parameter of type '{ a: any; }'.
|
||||
Object literal may only specify known properties, and 'opt' does not exist in type '{ a: any; }'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/excessPropertyCheckWithSpread.ts (2 errors) ====
|
||||
declare function f({ a: number }): void
|
||||
interface I {
|
||||
readonly n: number;
|
||||
}
|
||||
declare let i: I;
|
||||
f({ a: 1, ...i });
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ n: number; a: number; }' is not assignable to parameter of type '{ a: any; }'.
|
||||
!!! error TS2345: Object literal may only specify known properties, and 'n' does not exist in type '{ a: any; }'.
|
||||
|
||||
interface R {
|
||||
opt?: number
|
||||
}
|
||||
interface L {
|
||||
opt: string
|
||||
}
|
||||
declare let l: L;
|
||||
declare let r: R;
|
||||
f({ a: 1, ...l, ...r });
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ opt: string | number; a: number; }' is not assignable to parameter of type '{ a: any; }'.
|
||||
!!! error TS2345: Object literal may only specify known properties, and 'opt' does not exist in type '{ a: any; }'.
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
tests/cases/conformance/jsx/inline/index.tsx(5,1): error TS2322: Type 'import("tests/cases/conformance/jsx/inline/renderer").dom.JSX.Element' is not assignable to type 'import("tests/cases/conformance/jsx/inline/renderer2").predom.JSX.Element'.
|
||||
Property '__predomBrand' is missing in type 'Element'.
|
||||
tests/cases/conformance/jsx/inline/index.tsx(21,21): error TS2605: JSX element type 'Element' is not a constructor function for JSX elements.
|
||||
Property 'render' is missing in type 'Element'.
|
||||
tests/cases/conformance/jsx/inline/index.tsx(21,22): error TS2322: Type '{ children: Element[]; x: number; y: number; }' is not assignable to type '{ children?: Element[]; }'.
|
||||
tests/cases/conformance/jsx/inline/index.tsx(21,22): error TS2322: Type '{ children: Element[]; x: number; y: number; }' is not assignable to type '{ x: number; y: number; children?: Element[]; }'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type 'import("tests/cases/conformance/jsx/inline/renderer").dom.JSX.Element[]' is not assignable to type 'import("tests/cases/conformance/jsx/inline/renderer2").predom.JSX.Element[]'.
|
||||
Type 'import("tests/cases/conformance/jsx/inline/renderer").dom.JSX.Element' is not assignable to type 'import("tests/cases/conformance/jsx/inline/renderer2").predom.JSX.Element'.
|
||||
@@ -76,7 +74,7 @@ tests/cases/conformance/jsx/inline/index.tsx(24,23): error TS2322: Type '{ child
|
||||
|
||||
export default <h></h>
|
||||
|
||||
==== tests/cases/conformance/jsx/inline/index.tsx (6 errors) ====
|
||||
==== tests/cases/conformance/jsx/inline/index.tsx (5 errors) ====
|
||||
/** @jsx dom */
|
||||
import { dom } from "./renderer"
|
||||
import prerendered, {MySFC, MyClass, tree} from "./component";
|
||||
@@ -101,11 +99,8 @@ tests/cases/conformance/jsx/inline/index.tsx(24,23): error TS2322: Type '{ child
|
||||
|
||||
// Should fail, no dom elements
|
||||
const _brokenTree = <MySFC x={1} y={2}><MyClass x={3} y={4} /><MyClass x={5} y={6} /></MySFC>
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2605: JSX element type 'Element' is not a constructor function for JSX elements.
|
||||
!!! error TS2605: Property 'render' is missing in type 'Element'.
|
||||
~~~~~
|
||||
!!! error TS2322: Type '{ children: Element[]; x: number; y: number; }' is not assignable to type '{ children?: Element[]; }'.
|
||||
!!! error TS2322: Type '{ children: Element[]; x: number; y: number; }' is not assignable to type '{ x: number; y: number; children?: Element[]; }'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type 'import("tests/cases/conformance/jsx/inline/renderer").dom.JSX.Element[]' is not assignable to type 'import("tests/cases/conformance/jsx/inline/renderer2").predom.JSX.Element[]'.
|
||||
!!! error TS2322: Type 'import("tests/cases/conformance/jsx/inline/renderer").dom.JSX.Element' is not assignable to type 'import("tests/cases/conformance/jsx/inline/renderer2").predom.JSX.Element'.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx(20,46): error TS2322: Type '"y"' is not assignable to type '"x"'.
|
||||
tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx(21,19): error TS2322: Type '{ children: (p: LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x">'.
|
||||
Type '{ children: (p: LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'LitProps<"x">'.
|
||||
tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx(21,19): error TS2322: Type '{ children: (p: IntrinsicAttributes & LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x">'.
|
||||
Type '{ children: (p: IntrinsicAttributes & LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'LitProps<"x">'.
|
||||
Types of property 'children' are incompatible.
|
||||
Type '(p: LitProps<"x">) => "y"' is not assignable to type '(x: LitProps<"x">) => "x"'.
|
||||
Type '(p: IntrinsicAttributes & LitProps<"x">) => "y"' is not assignable to type '(x: LitProps<"x">) => "x"'.
|
||||
Type '"y"' is not assignable to type '"x"'.
|
||||
tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx(22,21): error TS2322: Type '{ children: () => number; prop: "x"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x">'.
|
||||
Type '{ children: () => number; prop: "x"; }' is not assignable to type 'LitProps<"x">'.
|
||||
@@ -37,10 +37,10 @@ tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx(22,21): error TS2322:
|
||||
!!! related TS6502 tests/cases/compiler/jsxChildrenGenericContextualTypes.tsx:13:44: The expected type comes from the return type of this signature.
|
||||
const argchild = <ElemLit prop="x">{p => "y"}</ElemLit>
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type '{ children: (p: LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x">'.
|
||||
!!! error TS2322: Type '{ children: (p: LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'LitProps<"x">'.
|
||||
!!! error TS2322: Type '{ children: (p: IntrinsicAttributes & LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'IntrinsicAttributes & LitProps<"x">'.
|
||||
!!! error TS2322: Type '{ children: (p: IntrinsicAttributes & LitProps<"x">) => "y"; prop: "x"; }' is not assignable to type 'LitProps<"x">'.
|
||||
!!! error TS2322: Types of property 'children' are incompatible.
|
||||
!!! error TS2322: Type '(p: LitProps<"x">) => "y"' is not assignable to type '(x: LitProps<"x">) => "x"'.
|
||||
!!! error TS2322: Type '(p: IntrinsicAttributes & LitProps<"x">) => "y"' is not assignable to type '(x: LitProps<"x">) => "x"'.
|
||||
!!! error TS2322: Type '"y"' is not assignable to type '"x"'.
|
||||
const mismatched = <ElemLit prop="x">{() => 12}</ElemLit>
|
||||
~~~~~~~
|
||||
|
||||
@@ -116,19 +116,19 @@ const arg = <ElemLit prop="x" children={p => "y"} />
|
||||
>arg : JSX.Element
|
||||
><ElemLit prop="x" children={p => "y"} /> : JSX.Element
|
||||
>ElemLit : <T extends string>(p: LitProps<T>) => JSX.Element
|
||||
>prop : "x"
|
||||
>children : (p: LitProps<"x">) => "y"
|
||||
>p => "y" : (p: LitProps<"x">) => "y"
|
||||
>p : LitProps<"x">
|
||||
>prop : string
|
||||
>children : (p: JSX.IntrinsicAttributes & LitProps<"x">) => "y"
|
||||
>p => "y" : (p: JSX.IntrinsicAttributes & LitProps<"x">) => "y"
|
||||
>p : JSX.IntrinsicAttributes & LitProps<"x">
|
||||
>"y" : "y"
|
||||
|
||||
const argchild = <ElemLit prop="x">{p => "y"}</ElemLit>
|
||||
>argchild : JSX.Element
|
||||
><ElemLit prop="x">{p => "y"}</ElemLit> : JSX.Element
|
||||
>ElemLit : <T extends string>(p: LitProps<T>) => JSX.Element
|
||||
>prop : "x"
|
||||
>p => "y" : (p: LitProps<"x">) => "y"
|
||||
>p : LitProps<"x">
|
||||
>prop : string
|
||||
>p => "y" : (p: JSX.IntrinsicAttributes & LitProps<"x">) => "y"
|
||||
>p : JSX.IntrinsicAttributes & LitProps<"x">
|
||||
>"y" : "y"
|
||||
>ElemLit : <T extends string>(p: LitProps<T>) => JSX.Element
|
||||
|
||||
@@ -136,7 +136,7 @@ const mismatched = <ElemLit prop="x">{() => 12}</ElemLit>
|
||||
>mismatched : JSX.Element
|
||||
><ElemLit prop="x">{() => 12}</ElemLit> : JSX.Element
|
||||
>ElemLit : <T extends string>(p: LitProps<T>) => JSX.Element
|
||||
>prop : "x"
|
||||
>prop : string
|
||||
>() => 12 : () => number
|
||||
>12 : 12
|
||||
>ElemLit : <T extends string>(p: LitProps<T>) => JSX.Element
|
||||
|
||||
@@ -40,7 +40,7 @@ tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx(64,37): error TS2322:
|
||||
!!! error TS2322: Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'.
|
||||
!!! error TS2322: Type '(value: string) => void' is not assignable to type '(value: string) => boolean'.
|
||||
!!! error TS2322: Type 'void' is not assignable to type 'boolean'.
|
||||
!!! related TS6500 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:6:3: The expected type comes from property 'when' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<FieldFeedback<Props>> & Pick<Readonly<{ children?: ReactNode; }> & Readonly<Props>, "children" | "error"> & Partial<Pick<Readonly<{ children?: ReactNode; }> & Readonly<Props>, "when">> & Partial<Pick<{ when: () => boolean; }, never>>'
|
||||
!!! related TS6500 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:6:3: The expected type comes from property 'when' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<FieldFeedback<BaseProps>> & Pick<Readonly<{ children?: ReactNode; }> & Readonly<BaseProps>, "children" | "error"> & Partial<Pick<Readonly<{ children?: ReactNode; }> & Readonly<BaseProps>, "when">> & Partial<Pick<{ when: () => boolean; }, never>>'
|
||||
|
||||
class FieldFeedbackBeta<P extends Props = BaseProps> extends React.Component<P> {
|
||||
static defaultProps: BaseProps = {
|
||||
@@ -61,7 +61,7 @@ tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx(64,37): error TS2322:
|
||||
!!! error TS2322: Type '(value: string) => void' is not assignable to type '"a" | "b" | ((value: string) => boolean) | undefined'.
|
||||
!!! error TS2322: Type '(value: string) => void' is not assignable to type '(value: string) => boolean'.
|
||||
!!! error TS2322: Type 'void' is not assignable to type 'boolean'.
|
||||
!!! related TS6500 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:6:3: The expected type comes from property 'when' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<FieldFeedbackBeta<Props>> & Pick<Readonly<{ children?: ReactNode; }> & Readonly<Props>, "children"> & Partial<Pick<Readonly<{ children?: ReactNode; }> & Readonly<Props>, "when" | "error">> & Partial<Pick<BaseProps, never>>'
|
||||
!!! related TS6500 tests/cases/compiler/reactDefaultPropsInferenceSuccess.tsx:6:3: The expected type comes from property 'when' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<FieldFeedbackBeta<BaseProps>> & Pick<Readonly<{ children?: ReactNode; }> & Readonly<BaseProps>, "children"> & Partial<Pick<Readonly<{ children?: ReactNode; }> & Readonly<BaseProps>, "when" | "error">> & Partial<Pick<BaseProps, never>>'
|
||||
|
||||
interface MyPropsProps extends Props {
|
||||
when: (value: string) => boolean;
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
tests/cases/conformance/jsx/file.tsx(23,8): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/jsx/file.tsx(24,2): error TS2559: Type '{ y: number; }' has no properties in common with type 'Attribs1'.
|
||||
tests/cases/conformance/jsx/file.tsx(25,2): error TS2559: Type '{ y: string; }' has no properties in common with type 'Attribs1'.
|
||||
tests/cases/conformance/jsx/file.tsx(24,2): error TS2322: Type '{ y: number; }' is not assignable to type 'Attribs1'.
|
||||
Property 'y' does not exist on type 'Attribs1'.
|
||||
tests/cases/conformance/jsx/file.tsx(25,2): error TS2322: Type '{ y: string; }' is not assignable to type 'Attribs1'.
|
||||
Property 'y' does not exist on type 'Attribs1'.
|
||||
tests/cases/conformance/jsx/file.tsx(26,8): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/jsx/file.tsx(27,2): error TS2559: Type '{ var: string; }' has no properties in common with type 'Attribs1'.
|
||||
tests/cases/conformance/jsx/file.tsx(27,2): error TS2322: Type '{ var: string; }' is not assignable to type 'Attribs1'.
|
||||
Property 'var' does not exist on type 'Attribs1'.
|
||||
tests/cases/conformance/jsx/file.tsx(29,2): error TS2322: Type '{}' is not assignable to type '{ reqd: string; }'.
|
||||
Property 'reqd' is missing in type '{}'.
|
||||
tests/cases/conformance/jsx/file.tsx(30,8): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
@@ -37,17 +40,20 @@ tests/cases/conformance/jsx/file.tsx(30,8): error TS2322: Type 'number' is not a
|
||||
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:10:2: The expected type comes from property 'x' which is declared here on type 'Attribs1'
|
||||
<test1 y={0} />; // Error, no property "y"
|
||||
~~~~~
|
||||
!!! error TS2559: Type '{ y: number; }' has no properties in common with type 'Attribs1'.
|
||||
!!! error TS2322: Type '{ y: number; }' is not assignable to type 'Attribs1'.
|
||||
!!! error TS2322: Property 'y' does not exist on type 'Attribs1'.
|
||||
<test1 y="foo" />; // Error, no property "y"
|
||||
~~~~~
|
||||
!!! error TS2559: Type '{ y: string; }' has no properties in common with type 'Attribs1'.
|
||||
!!! error TS2322: Type '{ y: string; }' is not assignable to type 'Attribs1'.
|
||||
!!! error TS2322: Property 'y' does not exist on type 'Attribs1'.
|
||||
<test1 x="32" />; // Error, "32" is not number
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:10:2: The expected type comes from property 'x' which is declared here on type 'Attribs1'
|
||||
<test1 var="10" />; // Error, no 'var' property
|
||||
~~~~~
|
||||
!!! error TS2559: Type '{ var: string; }' has no properties in common with type 'Attribs1'.
|
||||
!!! error TS2322: Type '{ var: string; }' is not assignable to type 'Attribs1'.
|
||||
!!! error TS2322: Property 'var' does not exist on type 'Attribs1'.
|
||||
|
||||
<test2 />; // Error, missing reqd
|
||||
~~~~~
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
tests/cases/conformance/jsx/file.tsx(11,10): error TS2559: Type '{ bar: string; }' has no properties in common with type 'IntrinsicAttributes & { ref?: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(11,10): error TS2322: Type '{ bar: string; }' is not assignable to type 'IntrinsicAttributes & { ref?: string; }'.
|
||||
Property 'bar' does not exist on type 'IntrinsicAttributes & { ref?: string; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/react.d.ts (0 errors) ====
|
||||
@@ -27,6 +28,7 @@ tests/cases/conformance/jsx/file.tsx(11,10): error TS2559: Type '{ bar: string;
|
||||
// Should be an OK
|
||||
var x = <MyComponent bar='world' />;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2559: Type '{ bar: string; }' has no properties in common with type 'IntrinsicAttributes & { ref?: string; }'.
|
||||
!!! error TS2322: Type '{ bar: string; }' is not assignable to type 'IntrinsicAttributes & { ref?: string; }'.
|
||||
!!! error TS2322: Property 'bar' does not exist on type 'IntrinsicAttributes & { ref?: string; }'.
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
tests/cases/conformance/jsx/file.tsx(11,10): error TS2559: Type '{ prop1: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes<BigGreeter> & { children?: ReactNode; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(11,10): error TS2322: Type '{ prop1: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<BigGreeter> & { children?: ReactNode; }'.
|
||||
Property 'prop1' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<BigGreeter> & { children?: ReactNode; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
@@ -14,7 +15,8 @@ tests/cases/conformance/jsx/file.tsx(11,10): error TS2559: Type '{ prop1: string
|
||||
// Error
|
||||
let a = <BigGreeter prop1="hello" />
|
||||
~~~~~~~~~~
|
||||
!!! error TS2559: Type '{ prop1: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes<BigGreeter> & { children?: ReactNode; }'.
|
||||
!!! error TS2322: Type '{ prop1: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<BigGreeter> & { children?: ReactNode; }'.
|
||||
!!! error TS2322: Property 'prop1' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<BigGreeter> & { children?: ReactNode; }'.
|
||||
|
||||
// OK
|
||||
let b = <BigGreeter ref={(input) => { this.textInput = input; }} />
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
tests/cases/conformance/jsx/file.tsx(13,1): error TS2605: JSX element type '{ x: number; }' is not a constructor function for JSX elements.
|
||||
Property 'render' is missing in type '{ x: number; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(13,2): error TS2322: Type '{ x: number; }' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsx/file.tsx(19,2): error TS2322: Type '{ x: number; render: number; }' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
|
||||
==== tests/cases/conformance/jsx/file.tsx (2 errors) ====
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface ElementClass {
|
||||
@@ -18,9 +16,6 @@ tests/cases/conformance/jsx/file.tsx(19,2): error TS2322: Type '{ x: number; ren
|
||||
}
|
||||
var Obj1: Obj1type;
|
||||
<Obj1 x={10} />; // Error, no render member
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2605: JSX element type '{ x: number; }' is not a constructor function for JSX elements.
|
||||
!!! error TS2605: Property 'render' is missing in type '{ x: number; }'.
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ x: number; }' is not assignable to type 'string'.
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
tests/cases/conformance/jsx/file.tsx(17,2): error TS2559: Type '{ x: number; }' has no properties in common with type '{ q?: number; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(17,2): error TS2322: Type '{ x: number; }' is not assignable to type '{ q?: number; }'.
|
||||
Property 'x' does not exist on type '{ q?: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
@@ -20,7 +21,8 @@ tests/cases/conformance/jsx/file.tsx(17,2): error TS2559: Type '{ x: number; }'
|
||||
var Obj2: Obj2type;
|
||||
<Obj2 x={10} />; // Error
|
||||
~~~~
|
||||
!!! error TS2559: Type '{ x: number; }' has no properties in common with type '{ q?: number; }'.
|
||||
!!! error TS2322: Type '{ x: number; }' is not assignable to type '{ q?: number; }'.
|
||||
!!! error TS2322: Property 'x' does not exist on type '{ q?: number; }'.
|
||||
|
||||
interface Obj3type {
|
||||
new(n: string): { x: number; };
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
tests/cases/conformance/jsx/file.tsx(23,1): error TS2607: JSX element class does not support attributes because it does not have a 'pr' property.
|
||||
tests/cases/conformance/jsx/file.tsx(23,7): error TS2339: Property 'x' does not exist on type '{}'.
|
||||
tests/cases/conformance/jsx/file.tsx(23,2): error TS2322: Type '{ x: number; }' is not assignable to type '{}'.
|
||||
Property 'x' does not exist on type '{}'.
|
||||
tests/cases/conformance/jsx/file.tsx(25,1): error TS2607: JSX element class does not support attributes because it does not have a 'pr' property.
|
||||
tests/cases/conformance/jsx/file.tsx(26,1): error TS2607: JSX element class does not support attributes because it does not have a 'pr' property.
|
||||
tests/cases/conformance/jsx/file.tsx(33,7): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
@@ -31,8 +32,9 @@ tests/cases/conformance/jsx/file.tsx(33,7): error TS2322: Type 'string' is not a
|
||||
<Obj3 x={10} />; // Error
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2607: JSX element class does not support attributes because it does not have a 'pr' property.
|
||||
~~~~~~
|
||||
!!! error TS2339: Property 'x' does not exist on type '{}'.
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ x: number; }' is not assignable to type '{}'.
|
||||
!!! error TS2322: Property 'x' does not exist on type '{}'.
|
||||
var attributes: any;
|
||||
<Obj3 {...attributes} />; // Error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/jsx/file.tsx(12,2): error TS2322: Type '{ w: string; }' is not assignable to type '{ n: string; }'.
|
||||
Property 'n' is missing in type '{ w: string; }'.
|
||||
Property 'w' does not exist on type '{ n: string; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
@@ -17,4 +17,4 @@ tests/cases/conformance/jsx/file.tsx(12,2): error TS2322: Type '{ w: string; }'
|
||||
<span w='err' />;
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ w: string; }' is not assignable to type '{ n: string; }'.
|
||||
!!! error TS2322: Property 'n' is missing in type '{ w: string; }'.
|
||||
!!! error TS2322: Property 'w' does not exist on type '{ n: string; }'.
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/jsx/file.tsx(16,2): error TS2322: Type '{ q: string; }' is not assignable to type '{ m: string; }'.
|
||||
Property 'm' is missing in type '{ q: string; }'.
|
||||
Property 'q' does not exist on type '{ m: string; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
@@ -21,5 +21,5 @@ tests/cases/conformance/jsx/file.tsx(16,2): error TS2322: Type '{ q: string; }'
|
||||
<span q='' />;
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ q: string; }' is not assignable to type '{ m: string; }'.
|
||||
!!! error TS2322: Property 'm' is missing in type '{ q: string; }'.
|
||||
!!! error TS2322: Property 'q' does not exist on type '{ m: string; }'.
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
tests/cases/conformance/jsx/file.tsx(11,2): error TS2322: Type '{}' is not assignable to type 'string | number'.
|
||||
Type '{}' is not assignable to type 'number'.
|
||||
tests/cases/conformance/jsx/file.tsx(18,2): error TS2322: Type '{}' is not assignable to type 'string | number'.
|
||||
Type '{}' is not assignable to type 'number'.
|
||||
tests/cases/conformance/jsx/file.tsx(25,2): error TS2322: Type '{ x: number; }' is not assignable to type 'string | number'.
|
||||
Type '{ x: number; }' is not assignable to type 'number'.
|
||||
tests/cases/conformance/jsx/file.tsx(11,2): error TS2322: Type '{}' is not assignable to type 'number'.
|
||||
tests/cases/conformance/jsx/file.tsx(18,2): error TS2322: Type '{}' is not assignable to type 'number'.
|
||||
tests/cases/conformance/jsx/file.tsx(25,2): error TS2322: Type '{ x: number; }' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
|
||||
@@ -19,8 +16,7 @@ tests/cases/conformance/jsx/file.tsx(25,2): error TS2322: Type '{ x: number; }'
|
||||
var Obj1: Obj1;
|
||||
<Obj1 />; // Error, return type is not an object type
|
||||
~~~~
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'string | number'.
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'number'.
|
||||
|
||||
interface Obj2 {
|
||||
(n: string): { x: number };
|
||||
@@ -29,8 +25,7 @@ tests/cases/conformance/jsx/file.tsx(25,2): error TS2322: Type '{ x: number; }'
|
||||
var Obj2: Obj2;
|
||||
<Obj2 />; // Error, return type is not an object type
|
||||
~~~~
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'string | number'.
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'number'.
|
||||
|
||||
interface Obj3 {
|
||||
(n: string): { x: number };
|
||||
@@ -39,6 +34,5 @@ tests/cases/conformance/jsx/file.tsx(25,2): error TS2322: Type '{ x: number; }'
|
||||
var Obj3: Obj3;
|
||||
<Obj3 x={42} />; // OK
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ x: number; }' is not assignable to type 'string | number'.
|
||||
!!! error TS2322: Type '{ x: number; }' is not assignable to type 'number'.
|
||||
!!! error TS2322: Type '{ x: number; }' is not assignable to type 'number'.
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
tests/cases/conformance/jsx/file.tsx(4,45): error TS2339: Property 'y' does not exist on type 'IntrinsicAttributes & { x: number; } & { children?: ReactNode; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
import React = require('react');
|
||||
|
||||
const decorator4 = function <T extends { x: number }>(Component: React.StatelessComponent<T>): React.StatelessComponent<T> {
|
||||
return (props) => <Component {...props} y={"blah"} ></Component>
|
||||
~~~~~~~~~~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'IntrinsicAttributes & { x: number; } & { children?: ReactNode; }'.
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/jsx/tsxIntrinsicAttributeErrors.tsx(29,2): error TS2322: Type '{ x: number; }' is not assignable to type 'IntrinsicAttributes'.
|
||||
Property 'key' is missing in type '{ x: number; }'.
|
||||
tests/cases/conformance/jsx/tsxIntrinsicAttributeErrors.tsx(29,2): error TS2322: Type '{ x: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<{ x: number; render(): void; }> & string'.
|
||||
Property 'x' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<{ x: number; render(): void; }> & string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/tsxIntrinsicAttributeErrors.tsx (1 errors) ====
|
||||
@@ -33,6 +33,6 @@ tests/cases/conformance/jsx/tsxIntrinsicAttributeErrors.tsx(29,2): error TS2322:
|
||||
var E: I;
|
||||
<E x={10} />
|
||||
~
|
||||
!!! error TS2322: Type '{ x: number; }' is not assignable to type 'IntrinsicAttributes'.
|
||||
!!! error TS2322: Property 'key' is missing in type '{ x: number; }'.
|
||||
!!! error TS2322: Type '{ x: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<{ x: number; render(): void; }> & string'.
|
||||
!!! error TS2322: Property 'x' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<{ x: number; render(): void; }> & string'.
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(55,12): error TS2322: Type '{ foo: number; }' is not assignable to type 'Defaultize<InferredPropTypes<{ foo: PropTypeChecker<number, false>; bar: PropTypeChecker<ReactNode, false>; baz: PropTypeChecker<string, true>; }>, { foo: number; }>'.
|
||||
Type '{ foo: number; }' is not assignable to type '{ bar: string | number | ReactComponent<{}, {}> | null | undefined; baz: string; }'.
|
||||
Property 'bar' is missing in type '{ foo: number; }'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(57,41): error TS2339: Property 'bat' does not exist on type 'Defaultize<InferredPropTypes<{ foo: PropTypeChecker<number, false>; bar: PropTypeChecker<ReactNode, false>; baz: PropTypeChecker<string, true>; }>, { foo: number; }>'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(57,12): error TS2322: Type '{ bar: string; baz: string; bat: string; }' is not assignable to type 'Defaultize<InferredPropTypes<{ foo: PropTypeChecker<number, false>; bar: PropTypeChecker<ReactNode, false>; baz: PropTypeChecker<string, true>; }>, { foo: number; }>'.
|
||||
Property 'bat' does not exist on type 'Defaultize<InferredPropTypes<{ foo: PropTypeChecker<number, false>; bar: PropTypeChecker<ReactNode, false>; baz: PropTypeChecker<string, true>; }>, { foo: number; }>'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(59,42): error TS2322: Type 'null' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(69,26): error TS2322: Type 'string' is not assignable to type 'number | null | undefined'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(71,35): error TS2322: Type 'null' is not assignable to type 'ReactNode'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(80,38): error TS2339: Property 'bar' does not exist on type 'Defaultize<{}, { foo: number; }>'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(80,12): error TS2322: Type '{ foo: number; bar: string; }' is not assignable to type 'Defaultize<{}, { foo: number; }>'.
|
||||
Property 'bar' does not exist on type 'Defaultize<{}, { foo: number; }>'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(81,29): error TS2322: Type 'string' is not assignable to type 'number | undefined'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(98,12): error TS2322: Type '{ foo: string; }' is not assignable to type 'Defaultize<FooProps & InferredPropTypes<{ foo: PropTypeChecker<string, false>; bar: PropTypeChecker<ReactNode, false>; baz: PropTypeChecker<number, true>; }>, { foo: string; }>'.
|
||||
Type '{ foo: string; }' is not assignable to type '{ bar: string | number | ReactComponent<{}, {}> | null | undefined; baz: number; }'.
|
||||
Property 'bar' is missing in type '{ foo: string; }'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(100,56): error TS2339: Property 'bat' does not exist on type 'Defaultize<FooProps & InferredPropTypes<{ foo: PropTypeChecker<string, false>; bar: PropTypeChecker<ReactNode, false>; baz: PropTypeChecker<number, true>; }>, { foo: string; }>'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(100,12): error TS2322: Type '{ bar: string; baz: number; bat: string; }' is not assignable to type 'Defaultize<FooProps & InferredPropTypes<{ foo: PropTypeChecker<string, false>; bar: PropTypeChecker<ReactNode, false>; baz: PropTypeChecker<number, true>; }>, { foo: string; }>'.
|
||||
Property 'bat' does not exist on type 'Defaultize<FooProps & InferredPropTypes<{ foo: PropTypeChecker<string, false>; bar: PropTypeChecker<ReactNode, false>; baz: PropTypeChecker<number, true>; }>, { foo: string; }>'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(102,57): error TS2322: Type 'null' is not assignable to type 'number'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(111,46): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(112,46): error TS2322: Type 'null' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(113,57): error TS2322: Type 'null' is not assignable to type 'ReactNode'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(122,58): error TS2339: Property 'bar' does not exist on type 'Defaultize<FooProps, { foo: string; }>'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(122,12): error TS2322: Type '{ foo: string; bar: string; }' is not assignable to type 'Defaultize<FooProps, { foo: string; }>'.
|
||||
Property 'bar' does not exist on type 'Defaultize<FooProps, { foo: string; }>'.
|
||||
tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(123,49): error TS2322: Type 'number' is not assignable to type 'string | undefined'.
|
||||
|
||||
|
||||
@@ -81,8 +85,9 @@ tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(123,49): error TS232
|
||||
!!! error TS2322: Property 'bar' is missing in type '{ foo: number; }'.
|
||||
const c = <Component bar="yes" baz="yeah" />;
|
||||
const d = <Component bar="yes" baz="yo" bat="ohno" />; // Error, baz not a valid prop
|
||||
~~~~~~~~~~
|
||||
!!! error TS2339: Property 'bat' does not exist on type 'Defaultize<InferredPropTypes<{ foo: PropTypeChecker<number, false>; bar: PropTypeChecker<ReactNode, false>; baz: PropTypeChecker<string, true>; }>, { foo: number; }>'.
|
||||
~~~~~~~~~
|
||||
!!! error TS2322: Type '{ bar: string; baz: string; bat: string; }' is not assignable to type 'Defaultize<InferredPropTypes<{ foo: PropTypeChecker<number, false>; bar: PropTypeChecker<ReactNode, false>; baz: PropTypeChecker<string, true>; }>, { foo: number; }>'.
|
||||
!!! error TS2322: Property 'bat' does not exist on type 'Defaultize<InferredPropTypes<{ foo: PropTypeChecker<number, false>; bar: PropTypeChecker<ReactNode, false>; baz: PropTypeChecker<string, true>; }>, { foo: number; }>'.
|
||||
const e = <Component foo={12} bar={null} baz="cool" />; // bar is nullable/undefinable since it's not marked `isRequired`
|
||||
const f = <Component foo={12} bar="yeah" baz={null} />; // Error, baz is _not_ nullable/undefinable since it's marked `isRequired`
|
||||
~~~
|
||||
@@ -114,8 +119,9 @@ tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(123,49): error TS232
|
||||
|
||||
const k = <JustDefaultProps foo={12} />;
|
||||
const l = <JustDefaultProps foo={12} bar="ok" />; // error, no prop named bar
|
||||
~~~~~~~~
|
||||
!!! error TS2339: Property 'bar' does not exist on type 'Defaultize<{}, { foo: number; }>'.
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ foo: number; bar: string; }' is not assignable to type 'Defaultize<{}, { foo: number; }>'.
|
||||
!!! error TS2322: Property 'bar' does not exist on type 'Defaultize<{}, { foo: number; }>'.
|
||||
const m = <JustDefaultProps foo="no" />; // error, wrong type
|
||||
~~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'.
|
||||
@@ -143,8 +149,9 @@ tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(123,49): error TS232
|
||||
!!! error TS2322: Property 'bar' is missing in type '{ foo: string; }'.
|
||||
const p = <BothWithSpecifiedGeneric bar="yes" baz={12} />;
|
||||
const q = <BothWithSpecifiedGeneric bar="yes" baz={12} bat="ohno" />; // Error, baz not a valid prop
|
||||
~~~~~~~~~~
|
||||
!!! error TS2339: Property 'bat' does not exist on type 'Defaultize<FooProps & InferredPropTypes<{ foo: PropTypeChecker<string, false>; bar: PropTypeChecker<ReactNode, false>; baz: PropTypeChecker<number, true>; }>, { foo: string; }>'.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ bar: string; baz: number; bat: string; }' is not assignable to type 'Defaultize<FooProps & InferredPropTypes<{ foo: PropTypeChecker<string, false>; bar: PropTypeChecker<ReactNode, false>; baz: PropTypeChecker<number, true>; }>, { foo: string; }>'.
|
||||
!!! error TS2322: Property 'bat' does not exist on type 'Defaultize<FooProps & InferredPropTypes<{ foo: PropTypeChecker<string, false>; bar: PropTypeChecker<ReactNode, false>; baz: PropTypeChecker<number, true>; }>, { foo: string; }>'.
|
||||
const r = <BothWithSpecifiedGeneric foo="no" bar={null} baz={0} />; // bar is nullable/undefinable since it's not marked `isRequired`
|
||||
const s = <BothWithSpecifiedGeneric foo="eh" bar="yeah" baz={null} />; // Error, baz is _not_ nullable/undefinable since it's marked `isRequired`
|
||||
~~~
|
||||
@@ -178,8 +185,9 @@ tests/cases/conformance/jsx/tsxLibraryManagedAttributes.tsx(123,49): error TS232
|
||||
|
||||
const x = <JustDefaultPropsWithSpecifiedGeneric foo="eh" />;
|
||||
const y = <JustDefaultPropsWithSpecifiedGeneric foo="no" bar="ok" />; // error, no prop named bar
|
||||
~~~~~~~~
|
||||
!!! error TS2339: Property 'bar' does not exist on type 'Defaultize<FooProps, { foo: string; }>'.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ foo: string; bar: string; }' is not assignable to type 'Defaultize<FooProps, { foo: string; }>'.
|
||||
!!! error TS2322: Property 'bar' does not exist on type 'Defaultize<FooProps, { foo: string; }>'.
|
||||
const z = <JustDefaultPropsWithSpecifiedGeneric foo={12} />; // error, wrong type
|
||||
~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string | undefined'.
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx(14,14): error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & P'.
|
||||
Type '{}' is not assignable to type 'P'.
|
||||
tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx(15,14): error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComponent> & Readonly<{ children?: ReactNode; }> & Readonly<P>'.
|
||||
Type '{}' is not assignable to type 'Readonly<P>'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx (2 errors) ====
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
|
||||
import React from 'react';
|
||||
|
||||
function test<P>(wrappedProps: P) {
|
||||
let MySFC = function(props: P) {
|
||||
return <>hello</>;
|
||||
};
|
||||
class MyComponent extends React.Component<P> {
|
||||
render() {
|
||||
return <>hello</>;
|
||||
}
|
||||
}
|
||||
let x = <MySFC />; // should error
|
||||
~~~~~
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & P'.
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'P'.
|
||||
let y = <MyComponent />; // should error
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComponent> & Readonly<{ children?: ReactNode; }> & Readonly<P>'.
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'Readonly<P>'.
|
||||
|
||||
let z = <MySFC {...wrappedProps} /> // should work
|
||||
let q = <MyComponent {...wrappedProps} /> // should work
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
//// [tsxNotUsingApparentTypeOfSFC.tsx]
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
|
||||
import React from 'react';
|
||||
|
||||
function test<P>(wrappedProps: P) {
|
||||
let MySFC = function(props: P) {
|
||||
return <>hello</>;
|
||||
};
|
||||
class MyComponent extends React.Component<P> {
|
||||
render() {
|
||||
return <>hello</>;
|
||||
}
|
||||
}
|
||||
let x = <MySFC />; // should error
|
||||
let y = <MyComponent />; // should error
|
||||
|
||||
let z = <MySFC {...wrappedProps} /> // should work
|
||||
let q = <MyComponent {...wrappedProps} /> // should work
|
||||
}
|
||||
|
||||
//// [tsxNotUsingApparentTypeOfSFC.js]
|
||||
"use strict";
|
||||
/// <reference path="react16.d.ts" />
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
exports.__esModule = true;
|
||||
var react_1 = __importDefault(require("react"));
|
||||
function test(wrappedProps) {
|
||||
var MySFC = function (props) {
|
||||
return react_1["default"].createElement(react_1["default"].Fragment, null, "hello");
|
||||
};
|
||||
var MyComponent = /** @class */ (function (_super) {
|
||||
__extends(MyComponent, _super);
|
||||
function MyComponent() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
MyComponent.prototype.render = function () {
|
||||
return react_1["default"].createElement(react_1["default"].Fragment, null, "hello");
|
||||
};
|
||||
return MyComponent;
|
||||
}(react_1["default"].Component));
|
||||
var x = react_1["default"].createElement(MySFC, null); // should error
|
||||
var y = react_1["default"].createElement(MyComponent, null); // should error
|
||||
var z = react_1["default"].createElement(MySFC, __assign({}, wrappedProps)); // should work
|
||||
var q = react_1["default"].createElement(MyComponent, __assign({}, wrappedProps)); // should work
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
=== tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx ===
|
||||
/// <reference path="react16.d.ts" />
|
||||
|
||||
import React from 'react';
|
||||
>React : Symbol(React, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 2, 6))
|
||||
|
||||
function test<P>(wrappedProps: P) {
|
||||
>test : Symbol(test, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 2, 26))
|
||||
>P : Symbol(P, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 4, 14))
|
||||
>wrappedProps : Symbol(wrappedProps, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 4, 17))
|
||||
>P : Symbol(P, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 4, 14))
|
||||
|
||||
let MySFC = function(props: P) {
|
||||
>MySFC : Symbol(MySFC, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 5, 7))
|
||||
>props : Symbol(props, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 5, 25))
|
||||
>P : Symbol(P, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 4, 14))
|
||||
|
||||
return <>hello</>;
|
||||
};
|
||||
class MyComponent extends React.Component<P> {
|
||||
>MyComponent : Symbol(MyComponent, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 7, 6))
|
||||
>React.Component : Symbol(React.Component, Decl(react16.d.ts, 345, 54), Decl(react16.d.ts, 349, 94))
|
||||
>React : Symbol(React, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 2, 6))
|
||||
>Component : Symbol(React.Component, Decl(react16.d.ts, 345, 54), Decl(react16.d.ts, 349, 94))
|
||||
>P : Symbol(P, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 4, 14))
|
||||
|
||||
render() {
|
||||
>render : Symbol(MyComponent.render, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 8, 50))
|
||||
|
||||
return <>hello</>;
|
||||
}
|
||||
}
|
||||
let x = <MySFC />; // should error
|
||||
>x : Symbol(x, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 13, 7))
|
||||
>MySFC : Symbol(MySFC, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 5, 7))
|
||||
|
||||
let y = <MyComponent />; // should error
|
||||
>y : Symbol(y, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 14, 7))
|
||||
>MyComponent : Symbol(MyComponent, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 7, 6))
|
||||
|
||||
let z = <MySFC {...wrappedProps} /> // should work
|
||||
>z : Symbol(z, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 16, 7))
|
||||
>MySFC : Symbol(MySFC, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 5, 7))
|
||||
>wrappedProps : Symbol(wrappedProps, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 4, 17))
|
||||
|
||||
let q = <MyComponent {...wrappedProps} /> // should work
|
||||
>q : Symbol(q, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 17, 7))
|
||||
>MyComponent : Symbol(MyComponent, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 7, 6))
|
||||
>wrappedProps : Symbol(wrappedProps, Decl(tsxNotUsingApparentTypeOfSFC.tsx, 4, 17))
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
=== tests/cases/compiler/tsxNotUsingApparentTypeOfSFC.tsx ===
|
||||
/// <reference path="react16.d.ts" />
|
||||
|
||||
import React from 'react';
|
||||
>React : typeof React
|
||||
|
||||
function test<P>(wrappedProps: P) {
|
||||
>test : <P>(wrappedProps: P) => void
|
||||
>wrappedProps : P
|
||||
|
||||
let MySFC = function(props: P) {
|
||||
>MySFC : (props: P) => JSX.Element
|
||||
>function(props: P) { return <>hello</>; } : (props: P) => JSX.Element
|
||||
>props : P
|
||||
|
||||
return <>hello</>;
|
||||
><>hello</> : JSX.Element
|
||||
|
||||
};
|
||||
class MyComponent extends React.Component<P> {
|
||||
>MyComponent : MyComponent
|
||||
>React.Component : React.Component<P, {}, any>
|
||||
>React : typeof React
|
||||
>Component : typeof React.Component
|
||||
|
||||
render() {
|
||||
>render : () => JSX.Element
|
||||
|
||||
return <>hello</>;
|
||||
><>hello</> : JSX.Element
|
||||
}
|
||||
}
|
||||
let x = <MySFC />; // should error
|
||||
>x : JSX.Element
|
||||
><MySFC /> : JSX.Element
|
||||
>MySFC : (props: P) => JSX.Element
|
||||
|
||||
let y = <MyComponent />; // should error
|
||||
>y : JSX.Element
|
||||
><MyComponent /> : JSX.Element
|
||||
>MyComponent : typeof MyComponent
|
||||
|
||||
let z = <MySFC {...wrappedProps} /> // should work
|
||||
>z : JSX.Element
|
||||
><MySFC {...wrappedProps} /> : JSX.Element
|
||||
>MySFC : (props: P) => JSX.Element
|
||||
>wrappedProps : P
|
||||
|
||||
let q = <MyComponent {...wrappedProps} /> // should work
|
||||
>q : JSX.Element
|
||||
><MyComponent {...wrappedProps} /> : JSX.Element
|
||||
>MyComponent : typeof MyComponent
|
||||
>wrappedProps : P
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
tests/cases/conformance/jsx/file.tsx(13,11): error TS2322: Type '{}' is not assignable to type 'Prop'.
|
||||
Property 'a' is missing in type '{}'.
|
||||
tests/cases/conformance/jsx/file.tsx(13,11): error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp<Prop>> & Prop & { children?: ReactNode; }'.
|
||||
Type '{}' is not assignable to type 'Prop'.
|
||||
Property 'a' is missing in type '{}'.
|
||||
tests/cases/conformance/jsx/file.tsx(19,18): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
@@ -18,8 +19,9 @@ tests/cases/conformance/jsx/file.tsx(19,18): error TS2322: Type 'string' is not
|
||||
// Error
|
||||
let x1 = <MyComp />
|
||||
~~~~~~
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Property 'a' is missing in type '{}'.
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp<Prop>> & Prop & { children?: ReactNode; }'.
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Property 'a' is missing in type '{}'.
|
||||
|
||||
// OK
|
||||
let x = <MyComp a={10} b="hi" />
|
||||
|
||||
@@ -42,7 +42,7 @@ let y = <Opt {...obj} x={3}/>;
|
||||
><Opt {...obj} x={3}/> : JSX.Element
|
||||
>Opt : typeof Opt
|
||||
>obj : OptionProp
|
||||
>x : 3
|
||||
>x : number
|
||||
>3 : 3
|
||||
|
||||
let y1 = <Opt {...obj1} x="Hi"/>;
|
||||
@@ -57,7 +57,7 @@ let y2 = <Opt {...obj1} x={3}/>;
|
||||
><Opt {...obj1} x={3}/> : JSX.Element
|
||||
>Opt : typeof Opt
|
||||
>obj1 : OptionProp
|
||||
>x : 3
|
||||
>x : number
|
||||
>3 : 3
|
||||
|
||||
let y3 = <Opt x />;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
tests/cases/conformance/jsx/file.tsx(27,33): error TS2322: Type 'true' is not assignable to type 'false'.
|
||||
tests/cases/conformance/jsx/file.tsx(28,50): error TS2322: Type '3' is not assignable to type '2'.
|
||||
tests/cases/conformance/jsx/file.tsx(30,11): error TS2322: Type '{ y: true; x: 2; overwrite: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'y' are incompatible.
|
||||
Type 'true' is not assignable to type 'false'.
|
||||
tests/cases/conformance/jsx/file.tsx(30,11): error TS2322: Type '{ y: true; x: 2; overwrite: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<OverWriteAttr> & Prop & { children?: ReactNode; }'.
|
||||
Type '{ y: true; x: 2; overwrite: string; }' is not assignable to type 'Prop'.
|
||||
Types of property 'y' are incompatible.
|
||||
Type 'true' is not assignable to type 'false'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
|
||||
@@ -43,8 +44,9 @@ tests/cases/conformance/jsx/file.tsx(30,11): error TS2322: Type '{ y: true; x: 2
|
||||
let x2 = <OverWriteAttr {...anyobj} x={3} />
|
||||
let x3 = <OverWriteAttr overwrite="hi" {...obj1} {...{y: true}} />
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ y: true; x: 2; overwrite: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'y' are incompatible.
|
||||
!!! error TS2322: Type 'true' is not assignable to type 'false'.
|
||||
!!! error TS2322: Type '{ y: true; x: 2; overwrite: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<OverWriteAttr> & Prop & { children?: ReactNode; }'.
|
||||
!!! error TS2322: Type '{ y: true; x: 2; overwrite: string; }' is not assignable to type 'Prop'.
|
||||
!!! error TS2322: Types of property 'y' are incompatible.
|
||||
!!! error TS2322: Type 'true' is not assignable to type 'false'.
|
||||
|
||||
|
||||
@@ -78,10 +78,10 @@ let x1 = <OverWriteAttr overwrite="hi" {...obj1} x={3} {...{y: true}} />
|
||||
>OverWriteAttr : typeof OverWriteAttr
|
||||
>overwrite : string
|
||||
>obj1 : { x: 2; }
|
||||
>x : 3
|
||||
>x : number
|
||||
>3 : 3
|
||||
>{y: true} : { y: true; }
|
||||
>y : true
|
||||
>{y: true} : { y: boolean; }
|
||||
>y : boolean
|
||||
>true : true
|
||||
|
||||
let x2 = <OverWriteAttr {...anyobj} x={3} />
|
||||
@@ -98,8 +98,8 @@ let x3 = <OverWriteAttr overwrite="hi" {...obj1} {...{y: true}} />
|
||||
>OverWriteAttr : typeof OverWriteAttr
|
||||
>overwrite : string
|
||||
>obj1 : { x: 2; }
|
||||
>{y: true} : { y: true; }
|
||||
>y : true
|
||||
>{y: true} : { y: boolean; }
|
||||
>y : boolean
|
||||
>true : true
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
tests/cases/conformance/jsx/file.tsx(11,38): error TS2339: Property 'Property1' does not exist on type 'IntrinsicAttributes & AnotherComponentProps'.
|
||||
tests/cases/conformance/jsx/file.tsx(11,10): error TS2322: Type '{ Property1: true; property1: string; property2: number; }' is not assignable to type 'IntrinsicAttributes & AnotherComponentProps'.
|
||||
Property 'Property1' does not exist on type 'IntrinsicAttributes & AnotherComponentProps'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
@@ -13,8 +14,9 @@ tests/cases/conformance/jsx/file.tsx(11,38): error TS2339: Property 'Property1'
|
||||
return (
|
||||
// Error extra property
|
||||
<AnotherComponent {...props} Property1/>
|
||||
~~~~~~~~~
|
||||
!!! error TS2339: Property 'Property1' does not exist on type 'IntrinsicAttributes & AnotherComponentProps'.
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ Property1: true; property1: string; property2: number; }' is not assignable to type 'IntrinsicAttributes & AnotherComponentProps'.
|
||||
!!! error TS2322: Property 'Property1' does not exist on type 'IntrinsicAttributes & AnotherComponentProps'.
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
tests/cases/conformance/jsx/file.tsx(17,10): error TS2322: Type '{}' is not assignable to type 'PoisonedProp'.
|
||||
tests/cases/conformance/jsx/file.tsx(20,10): error TS2322: Type '{}' is not assignable to type 'PoisonedProp'.
|
||||
Property 'x' is missing in type '{}'.
|
||||
tests/cases/conformance/jsx/file.tsx(18,10): error TS2322: Type '{}' is not assignable to type 'PoisonedProp'.
|
||||
Property 'x' is missing in type '{}'.
|
||||
tests/cases/conformance/jsx/file.tsx(19,19): error TS2322: Type 'true' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsx/file.tsx(19,21): error TS2322: Type 'true' is not assignable to type '"2"'.
|
||||
tests/cases/conformance/jsx/file.tsx(20,10): error TS2322: Type '{ x: number; y: "2"; }' is not assignable to type 'PoisonedProp'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsx/file.tsx(21,11): error TS2322: Type '{ X: string; x: number; y: "2"; }' is not assignable to type 'PoisonedProp'.
|
||||
tests/cases/conformance/jsx/file.tsx(21,10): error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Poisoned> & PoisonedProp & { children?: ReactNode; }'.
|
||||
Type '{}' is not assignable to type 'PoisonedProp'.
|
||||
Property 'x' is missing in type '{}'.
|
||||
tests/cases/conformance/jsx/file.tsx(22,19): error TS2322: Type 'true' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsx/file.tsx(22,21): error TS2322: Type 'true' is not assignable to type '"2"'.
|
||||
tests/cases/conformance/jsx/file.tsx(23,10): error TS2322: Type '{ x: number; y: "2"; }' is not assignable to type 'PoisonedProp'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsx/file.tsx(24,11): error TS2322: Type '{ X: string; x: number; y: "2"; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Poisoned> & PoisonedProp & { children?: ReactNode; }'.
|
||||
Property 'X' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Poisoned> & PoisonedProp & { children?: ReactNode; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (6 errors) ====
|
||||
@@ -28,6 +28,9 @@ tests/cases/conformance/jsx/file.tsx(21,11): error TS2322: Type '{ X: string; x:
|
||||
|
||||
const obj = {};
|
||||
|
||||
// OK
|
||||
<Poisoned {...{x: "ok", y: "2"}} />;
|
||||
|
||||
// Error
|
||||
let p = <Poisoned {...obj} />;
|
||||
~~~~~~~~
|
||||
@@ -35,8 +38,9 @@ tests/cases/conformance/jsx/file.tsx(21,11): error TS2322: Type '{ X: string; x:
|
||||
!!! error TS2322: Property 'x' is missing in type '{}'.
|
||||
let y = <Poisoned />;
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'PoisonedProp'.
|
||||
!!! error TS2322: Property 'x' is missing in type '{}'.
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Poisoned> & PoisonedProp & { children?: ReactNode; }'.
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'PoisonedProp'.
|
||||
!!! error TS2322: Property 'x' is missing in type '{}'.
|
||||
let z = <Poisoned x y/>;
|
||||
~
|
||||
!!! error TS2322: Type 'true' is not assignable to type 'string'.
|
||||
@@ -51,6 +55,5 @@ tests/cases/conformance/jsx/file.tsx(21,11): error TS2322: Type '{ X: string; x:
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
let w1 = <Poisoned {...{x: 5, y: "2"}} X="hi" />;
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type '{ X: string; x: number; y: "2"; }' is not assignable to type 'PoisonedProp'.
|
||||
!!! error TS2322: Types of property 'x' are incompatible.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type '{ X: string; x: number; y: "2"; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Poisoned> & PoisonedProp & { children?: ReactNode; }'.
|
||||
!!! error TS2322: Property 'X' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Poisoned> & PoisonedProp & { children?: ReactNode; }'.
|
||||
@@ -14,6 +14,9 @@ class Poisoned extends React.Component<PoisonedProp, {}> {
|
||||
|
||||
const obj = {};
|
||||
|
||||
// OK
|
||||
<Poisoned {...{x: "ok", y: "2"}} />;
|
||||
|
||||
// Error
|
||||
let p = <Poisoned {...obj} />;
|
||||
let y = <Poisoned />;
|
||||
@@ -49,6 +52,8 @@ var Poisoned = /** @class */ (function (_super) {
|
||||
return Poisoned;
|
||||
}(React.Component));
|
||||
var obj = {};
|
||||
// OK
|
||||
<Poisoned {...{ x: "ok", y: "2" }}/>;
|
||||
// Error
|
||||
var p = <Poisoned {...obj}/>;
|
||||
var y = <Poisoned />;
|
||||
|
||||
@@ -31,32 +31,38 @@ class Poisoned extends React.Component<PoisonedProp, {}> {
|
||||
const obj = {};
|
||||
>obj : Symbol(obj, Decl(file.tsx, 13, 5))
|
||||
|
||||
// OK
|
||||
<Poisoned {...{x: "ok", y: "2"}} />;
|
||||
>Poisoned : Symbol(Poisoned, Decl(file.tsx, 5, 1))
|
||||
>x : Symbol(x, Decl(file.tsx, 16, 15))
|
||||
>y : Symbol(y, Decl(file.tsx, 16, 23))
|
||||
|
||||
// Error
|
||||
let p = <Poisoned {...obj} />;
|
||||
>p : Symbol(p, Decl(file.tsx, 16, 3))
|
||||
>p : Symbol(p, Decl(file.tsx, 19, 3))
|
||||
>Poisoned : Symbol(Poisoned, Decl(file.tsx, 5, 1))
|
||||
>obj : Symbol(obj, Decl(file.tsx, 13, 5))
|
||||
|
||||
let y = <Poisoned />;
|
||||
>y : Symbol(y, Decl(file.tsx, 17, 3))
|
||||
>y : Symbol(y, Decl(file.tsx, 20, 3))
|
||||
>Poisoned : Symbol(Poisoned, Decl(file.tsx, 5, 1))
|
||||
|
||||
let z = <Poisoned x y/>;
|
||||
>z : Symbol(z, Decl(file.tsx, 18, 3))
|
||||
>z : Symbol(z, Decl(file.tsx, 21, 3))
|
||||
>Poisoned : Symbol(Poisoned, Decl(file.tsx, 5, 1))
|
||||
>x : Symbol(x, Decl(file.tsx, 18, 17))
|
||||
>y : Symbol(y, Decl(file.tsx, 18, 19))
|
||||
>x : Symbol(x, Decl(file.tsx, 21, 17))
|
||||
>y : Symbol(y, Decl(file.tsx, 21, 19))
|
||||
|
||||
let w = <Poisoned {...{x: 5, y: "2"}}/>;
|
||||
>w : Symbol(w, Decl(file.tsx, 19, 3))
|
||||
>w : Symbol(w, Decl(file.tsx, 22, 3))
|
||||
>Poisoned : Symbol(Poisoned, Decl(file.tsx, 5, 1))
|
||||
>x : Symbol(x, Decl(file.tsx, 19, 23))
|
||||
>y : Symbol(y, Decl(file.tsx, 19, 28))
|
||||
>x : Symbol(x, Decl(file.tsx, 22, 23))
|
||||
>y : Symbol(y, Decl(file.tsx, 22, 28))
|
||||
|
||||
let w1 = <Poisoned {...{x: 5, y: "2"}} X="hi" />;
|
||||
>w1 : Symbol(w1, Decl(file.tsx, 20, 3))
|
||||
>w1 : Symbol(w1, Decl(file.tsx, 23, 3))
|
||||
>Poisoned : Symbol(Poisoned, Decl(file.tsx, 5, 1))
|
||||
>x : Symbol(x, Decl(file.tsx, 20, 24))
|
||||
>y : Symbol(y, Decl(file.tsx, 20, 29))
|
||||
>X : Symbol(X, Decl(file.tsx, 20, 38))
|
||||
>x : Symbol(x, Decl(file.tsx, 23, 24))
|
||||
>y : Symbol(y, Decl(file.tsx, 23, 29))
|
||||
>X : Symbol(X, Decl(file.tsx, 23, 38))
|
||||
|
||||
|
||||
@@ -30,6 +30,16 @@ const obj = {};
|
||||
>obj : {}
|
||||
>{} : {}
|
||||
|
||||
// OK
|
||||
<Poisoned {...{x: "ok", y: "2"}} />;
|
||||
><Poisoned {...{x: "ok", y: "2"}} /> : JSX.Element
|
||||
>Poisoned : typeof Poisoned
|
||||
>{x: "ok", y: "2"} : { x: string; y: "2"; }
|
||||
>x : string
|
||||
>"ok" : "ok"
|
||||
>y : "2"
|
||||
>"2" : "2"
|
||||
|
||||
// Error
|
||||
let p = <Poisoned {...obj} />;
|
||||
>p : JSX.Element
|
||||
@@ -53,20 +63,20 @@ let w = <Poisoned {...{x: 5, y: "2"}}/>;
|
||||
>w : JSX.Element
|
||||
><Poisoned {...{x: 5, y: "2"}}/> : JSX.Element
|
||||
>Poisoned : typeof Poisoned
|
||||
>{x: 5, y: "2"} : { x: number; y: "2"; }
|
||||
>{x: 5, y: "2"} : { x: number; y: string; }
|
||||
>x : number
|
||||
>5 : 5
|
||||
>y : "2"
|
||||
>y : string
|
||||
>"2" : "2"
|
||||
|
||||
let w1 = <Poisoned {...{x: 5, y: "2"}} X="hi" />;
|
||||
>w1 : JSX.Element
|
||||
><Poisoned {...{x: 5, y: "2"}} X="hi" /> : JSX.Element
|
||||
>Poisoned : typeof Poisoned
|
||||
>{x: 5, y: "2"} : { x: number; y: "2"; }
|
||||
>{x: 5, y: "2"} : { x: number; y: string; }
|
||||
>x : number
|
||||
>5 : 5
|
||||
>y : "2"
|
||||
>y : string
|
||||
>"2" : "2"
|
||||
>X : string
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
tests/cases/conformance/jsx/file.tsx(13,10): error TS2322: Type '{ editable: true; }' is not assignable to type '(IntrinsicAttributes & IntrinsicClassAttributes<TextComponent> & { editable: false; } & { children?: ReactNode; }) | (IntrinsicAttributes & IntrinsicClassAttributes<TextComponent> & { editable: true; onEdit: (newText: string) => void; } & { children?: ReactNode; })'.
|
||||
Type '{ editable: true; }' is not assignable to type '{ editable: true; onEdit: (newText: string) => void; }'.
|
||||
Property 'onEdit' is missing in type '{ editable: true; }'.
|
||||
Type '{ editable: true; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<TextComponent> & { editable: true; onEdit: (newText: string) => void; } & { children?: ReactNode; }'.
|
||||
Type '{ editable: true; }' is not assignable to type '{ editable: true; onEdit: (newText: string) => void; }'.
|
||||
Property 'onEdit' is missing in type '{ editable: true; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
@@ -19,8 +20,9 @@ tests/cases/conformance/jsx/file.tsx(13,10): error TS2322: Type '{ editable: tru
|
||||
let x = <TextComponent editable={true} />
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ editable: true; }' is not assignable to type '(IntrinsicAttributes & IntrinsicClassAttributes<TextComponent> & { editable: false; } & { children?: ReactNode; }) | (IntrinsicAttributes & IntrinsicClassAttributes<TextComponent> & { editable: true; onEdit: (newText: string) => void; } & { children?: ReactNode; })'.
|
||||
!!! error TS2322: Type '{ editable: true; }' is not assignable to type '{ editable: true; onEdit: (newText: string) => void; }'.
|
||||
!!! error TS2322: Property 'onEdit' is missing in type '{ editable: true; }'.
|
||||
!!! error TS2322: Type '{ editable: true; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<TextComponent> & { editable: true; onEdit: (newText: string) => void; } & { children?: ReactNode; }'.
|
||||
!!! error TS2322: Type '{ editable: true; }' is not assignable to type '{ editable: true; onEdit: (newText: string) => void; }'.
|
||||
!!! error TS2322: Property 'onEdit' is missing in type '{ editable: true; }'.
|
||||
|
||||
const textProps: TextProps = {
|
||||
editable: false
|
||||
|
||||
@@ -34,7 +34,7 @@ let x = <TextComponent editable={true} />
|
||||
>x : JSX.Element
|
||||
><TextComponent editable={true} /> : JSX.Element
|
||||
>TextComponent : typeof TextComponent
|
||||
>editable : true
|
||||
>editable : boolean
|
||||
>true : true
|
||||
|
||||
const textProps: TextProps = {
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
//// [tsxSpreadDoesNotReportExcessProps.tsx]
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
|
||||
import React from "react";
|
||||
|
||||
class MyComponent extends React.Component<{dataSource: number[], onClick?: any}, {}> {
|
||||
render() {
|
||||
return (<div {...this.props} className="ok"></div>);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [tsxSpreadDoesNotReportExcessProps.js]
|
||||
"use strict";
|
||||
/// <reference path="react16.d.ts" />
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
exports.__esModule = true;
|
||||
var react_1 = __importDefault(require("react"));
|
||||
var MyComponent = /** @class */ (function (_super) {
|
||||
__extends(MyComponent, _super);
|
||||
function MyComponent() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
MyComponent.prototype.render = function () {
|
||||
return (react_1["default"].createElement("div", __assign({}, this.props, { className: "ok" })));
|
||||
};
|
||||
return MyComponent;
|
||||
}(react_1["default"].Component));
|
||||
@@ -0,0 +1,27 @@
|
||||
=== tests/cases/compiler/tsxSpreadDoesNotReportExcessProps.tsx ===
|
||||
/// <reference path="react16.d.ts" />
|
||||
|
||||
import React from "react";
|
||||
>React : Symbol(React, Decl(tsxSpreadDoesNotReportExcessProps.tsx, 2, 6))
|
||||
|
||||
class MyComponent extends React.Component<{dataSource: number[], onClick?: any}, {}> {
|
||||
>MyComponent : Symbol(MyComponent, Decl(tsxSpreadDoesNotReportExcessProps.tsx, 2, 26))
|
||||
>React.Component : Symbol(React.Component, Decl(react16.d.ts, 345, 54), Decl(react16.d.ts, 349, 94))
|
||||
>React : Symbol(React, Decl(tsxSpreadDoesNotReportExcessProps.tsx, 2, 6))
|
||||
>Component : Symbol(React.Component, Decl(react16.d.ts, 345, 54), Decl(react16.d.ts, 349, 94))
|
||||
>dataSource : Symbol(dataSource, Decl(tsxSpreadDoesNotReportExcessProps.tsx, 4, 43))
|
||||
>onClick : Symbol(onClick, Decl(tsxSpreadDoesNotReportExcessProps.tsx, 4, 64))
|
||||
|
||||
render() {
|
||||
>render : Symbol(MyComponent.render, Decl(tsxSpreadDoesNotReportExcessProps.tsx, 4, 86))
|
||||
|
||||
return (<div {...this.props} className="ok"></div>);
|
||||
>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2420, 114))
|
||||
>this.props : Symbol(React.Component.props, Decl(react16.d.ts, 367, 32))
|
||||
>this : Symbol(MyComponent, Decl(tsxSpreadDoesNotReportExcessProps.tsx, 2, 26))
|
||||
>props : Symbol(React.Component.props, Decl(react16.d.ts, 367, 32))
|
||||
>className : Symbol(className, Decl(tsxSpreadDoesNotReportExcessProps.tsx, 6, 36))
|
||||
>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2420, 114))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
=== tests/cases/compiler/tsxSpreadDoesNotReportExcessProps.tsx ===
|
||||
/// <reference path="react16.d.ts" />
|
||||
|
||||
import React from "react";
|
||||
>React : typeof React
|
||||
|
||||
class MyComponent extends React.Component<{dataSource: number[], onClick?: any}, {}> {
|
||||
>MyComponent : MyComponent
|
||||
>React.Component : React.Component<{ dataSource: number[]; onClick?: any; }, {}, any>
|
||||
>React : typeof React
|
||||
>Component : typeof React.Component
|
||||
>dataSource : number[]
|
||||
>onClick : any
|
||||
|
||||
render() {
|
||||
>render : () => JSX.Element
|
||||
|
||||
return (<div {...this.props} className="ok"></div>);
|
||||
>(<div {...this.props} className="ok"></div>) : JSX.Element
|
||||
><div {...this.props} className="ok"></div> : JSX.Element
|
||||
>div : any
|
||||
>this.props : Readonly<{ children?: React.ReactNode; }> & Readonly<{ dataSource: number[]; onClick?: any; }>
|
||||
>this : this
|
||||
>props : Readonly<{ children?: React.ReactNode; }> & Readonly<{ dataSource: number[]; onClick?: any; }>
|
||||
>className : string
|
||||
>div : any
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
//// [tsxStatelessComponentDefaultProps.tsx]
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
|
||||
import React from 'react';
|
||||
interface Props {
|
||||
text: string;
|
||||
}
|
||||
|
||||
function BackButton(_props: Props) {
|
||||
return <div />
|
||||
}
|
||||
BackButton.defaultProps = {
|
||||
text: 'Go Back',
|
||||
};
|
||||
let a = <BackButton />
|
||||
|
||||
|
||||
//// [tsxStatelessComponentDefaultProps.js]
|
||||
"use strict";
|
||||
/// <reference path="react16.d.ts" />
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
exports.__esModule = true;
|
||||
var react_1 = __importDefault(require("react"));
|
||||
function BackButton(_props) {
|
||||
return react_1["default"].createElement("div", null);
|
||||
}
|
||||
BackButton.defaultProps = {
|
||||
text: 'Go Back'
|
||||
};
|
||||
var a = react_1["default"].createElement(BackButton, null);
|
||||
@@ -0,0 +1,34 @@
|
||||
=== tests/cases/compiler/tsxStatelessComponentDefaultProps.tsx ===
|
||||
/// <reference path="react16.d.ts" />
|
||||
|
||||
import React from 'react';
|
||||
>React : Symbol(React, Decl(tsxStatelessComponentDefaultProps.tsx, 2, 6))
|
||||
|
||||
interface Props {
|
||||
>Props : Symbol(Props, Decl(tsxStatelessComponentDefaultProps.tsx, 2, 26))
|
||||
|
||||
text: string;
|
||||
>text : Symbol(Props.text, Decl(tsxStatelessComponentDefaultProps.tsx, 3, 17))
|
||||
}
|
||||
|
||||
function BackButton(_props: Props) {
|
||||
>BackButton : Symbol(BackButton, Decl(tsxStatelessComponentDefaultProps.tsx, 5, 1), Decl(tsxStatelessComponentDefaultProps.tsx, 9, 1))
|
||||
>_props : Symbol(_props, Decl(tsxStatelessComponentDefaultProps.tsx, 7, 20))
|
||||
>Props : Symbol(Props, Decl(tsxStatelessComponentDefaultProps.tsx, 2, 26))
|
||||
|
||||
return <div />
|
||||
>div : Symbol(JSX.IntrinsicElements.div, Decl(react16.d.ts, 2420, 114))
|
||||
}
|
||||
BackButton.defaultProps = {
|
||||
>BackButton.defaultProps : Symbol(BackButton.defaultProps, Decl(tsxStatelessComponentDefaultProps.tsx, 9, 1))
|
||||
>BackButton : Symbol(BackButton, Decl(tsxStatelessComponentDefaultProps.tsx, 5, 1), Decl(tsxStatelessComponentDefaultProps.tsx, 9, 1))
|
||||
>defaultProps : Symbol(BackButton.defaultProps, Decl(tsxStatelessComponentDefaultProps.tsx, 9, 1))
|
||||
|
||||
text: 'Go Back',
|
||||
>text : Symbol(text, Decl(tsxStatelessComponentDefaultProps.tsx, 10, 27))
|
||||
|
||||
};
|
||||
let a = <BackButton />
|
||||
>a : Symbol(a, Decl(tsxStatelessComponentDefaultProps.tsx, 13, 3))
|
||||
>BackButton : Symbol(BackButton, Decl(tsxStatelessComponentDefaultProps.tsx, 5, 1), Decl(tsxStatelessComponentDefaultProps.tsx, 9, 1))
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
=== tests/cases/compiler/tsxStatelessComponentDefaultProps.tsx ===
|
||||
/// <reference path="react16.d.ts" />
|
||||
|
||||
import React from 'react';
|
||||
>React : typeof React
|
||||
|
||||
interface Props {
|
||||
text: string;
|
||||
>text : string
|
||||
}
|
||||
|
||||
function BackButton(_props: Props) {
|
||||
>BackButton : typeof BackButton
|
||||
>_props : Props
|
||||
|
||||
return <div />
|
||||
><div /> : JSX.Element
|
||||
>div : any
|
||||
}
|
||||
BackButton.defaultProps = {
|
||||
>BackButton.defaultProps = { text: 'Go Back',} : { text: string; }
|
||||
>BackButton.defaultProps : { text: string; }
|
||||
>BackButton : typeof BackButton
|
||||
>defaultProps : { text: string; }
|
||||
>{ text: 'Go Back',} : { text: string; }
|
||||
|
||||
text: 'Go Back',
|
||||
>text : string
|
||||
>'Go Back' : "Go Back"
|
||||
|
||||
};
|
||||
let a = <BackButton />
|
||||
>a : JSX.Element
|
||||
><BackButton /> : JSX.Element
|
||||
>BackButton : typeof BackButton
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
tests/cases/conformance/jsx/file.tsx(12,13): error TS2322: Type '{ extraProp: true; }' is not assignable to type '{ yy: number; yy1: string; }'.
|
||||
Property 'yy' is missing in type '{ extraProp: true; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(13,13): error TS2322: Type '{ yy: number; }' is not assignable to type '{ yy: number; yy1: string; }'.
|
||||
Property 'yy1' is missing in type '{ yy: number; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(12,13): error TS2322: Type '{ extraProp: true; }' is not assignable to type 'IntrinsicAttributes & { yy: number; yy1: string; }'.
|
||||
Property 'extraProp' does not exist on type 'IntrinsicAttributes & { yy: number; yy1: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(13,13): error TS2322: Type '{ yy: number; }' is not assignable to type 'IntrinsicAttributes & { yy: number; yy1: string; }'.
|
||||
Type '{ yy: number; }' is not assignable to type '{ yy: number; yy1: string; }'.
|
||||
Property 'yy1' is missing in type '{ yy: number; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(14,31): error TS2322: Type 'true' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsx/file.tsx(16,31): error TS2339: Property 'y1' does not exist on type 'IntrinsicAttributes & { yy: number; yy1: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(16,13): error TS2322: Type '{ y1: number; yy: number; yy1: string; }' is not assignable to type 'IntrinsicAttributes & { yy: number; yy1: string; }'.
|
||||
Property 'y1' does not exist on type 'IntrinsicAttributes & { yy: number; yy1: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(17,13): error TS2322: Type '{ yy: boolean; yy1: string; }' is not assignable to type '{ yy: number; yy1: string; }'.
|
||||
Types of property 'yy' are incompatible.
|
||||
Type 'boolean' is not assignable to type 'number'.
|
||||
tests/cases/conformance/jsx/file.tsx(25,13): error TS2322: Type '{ extra-data: true; }' is not assignable to type '{ yy: string; direction?: number; }'.
|
||||
Property 'yy' is missing in type '{ extra-data: true; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(25,13): error TS2322: Type '{ extra-data: true; }' is not assignable to type 'IntrinsicAttributes & { yy: string; direction?: number; }'.
|
||||
Type '{ extra-data: true; }' is not assignable to type '{ yy: string; direction?: number; }'.
|
||||
Property 'yy' is missing in type '{ extra-data: true; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(26,40): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/jsx/file.tsx(33,32): error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
tests/cases/conformance/jsx/file.tsx(34,29): error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
tests/cases/conformance/jsx/file.tsx(35,29): error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
tests/cases/conformance/jsx/file.tsx(36,29): error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (11 errors) ====
|
||||
==== tests/cases/conformance/jsx/file.tsx (10 errors) ====
|
||||
import React = require('react')
|
||||
declare function OneThing(): JSX.Element;
|
||||
declare function OneThing(l: {yy: number, yy1: string}): JSX.Element;
|
||||
@@ -30,20 +32,22 @@ tests/cases/conformance/jsx/file.tsx(36,29): error TS2322: Type 'string' is not
|
||||
// Error
|
||||
const c0 = <OneThing extraProp />; // extra property;
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type '{ extraProp: true; }' is not assignable to type '{ yy: number; yy1: string; }'.
|
||||
!!! error TS2322: Property 'yy' is missing in type '{ extraProp: true; }'.
|
||||
!!! error TS2322: Type '{ extraProp: true; }' is not assignable to type 'IntrinsicAttributes & { yy: number; yy1: string; }'.
|
||||
!!! error TS2322: Property 'extraProp' does not exist on type 'IntrinsicAttributes & { yy: number; yy1: string; }'.
|
||||
const c1 = <OneThing yy={10}/>; // missing property;
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type '{ yy: number; }' is not assignable to type '{ yy: number; yy1: string; }'.
|
||||
!!! error TS2322: Property 'yy1' is missing in type '{ yy: number; }'.
|
||||
!!! error TS2322: Type '{ yy: number; }' is not assignable to type 'IntrinsicAttributes & { yy: number; yy1: string; }'.
|
||||
!!! error TS2322: Type '{ yy: number; }' is not assignable to type '{ yy: number; yy1: string; }'.
|
||||
!!! error TS2322: Property 'yy1' is missing in type '{ yy: number; }'.
|
||||
const c2 = <OneThing {...obj} yy1 />; // type incompatible;
|
||||
~~~
|
||||
!!! error TS2322: Type 'true' is not assignable to type 'string'.
|
||||
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:3:43: The expected type comes from property 'yy1' which is declared here on type 'IntrinsicAttributes & { yy: number; yy1: string; }'
|
||||
const c3 = <OneThing {...obj} {...{extra: "extra attr"}} />; // This is OK becuase all attribute are spread
|
||||
const c4 = <OneThing {...obj} y1={10000} />; // extra property;
|
||||
~~~~~~~~~~
|
||||
!!! error TS2339: Property 'y1' does not exist on type 'IntrinsicAttributes & { yy: number; yy1: string; }'.
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type '{ y1: number; yy: number; yy1: string; }' is not assignable to type 'IntrinsicAttributes & { yy: number; yy1: string; }'.
|
||||
!!! error TS2322: Property 'y1' does not exist on type 'IntrinsicAttributes & { yy: number; yy1: string; }'.
|
||||
const c5 = <OneThing {...obj} {...{yy: true}} />; // type incompatible;
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type '{ yy: boolean; yy1: string; }' is not assignable to type '{ yy: number; yy1: string; }'.
|
||||
@@ -58,8 +62,9 @@ tests/cases/conformance/jsx/file.tsx(36,29): error TS2322: Type 'string' is not
|
||||
// Error
|
||||
const d1 = <TestingOneThing extra-data />
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ extra-data: true; }' is not assignable to type '{ yy: string; direction?: number; }'.
|
||||
!!! error TS2322: Property 'yy' is missing in type '{ extra-data: true; }'.
|
||||
!!! error TS2322: Type '{ extra-data: true; }' is not assignable to type 'IntrinsicAttributes & { yy: string; direction?: number; }'.
|
||||
!!! error TS2322: Type '{ extra-data: true; }' is not assignable to type '{ yy: string; direction?: number; }'.
|
||||
!!! error TS2322: Property 'yy' is missing in type '{ extra-data: true; }'.
|
||||
const d2 = <TestingOneThing yy="hello" direction="left" />
|
||||
~~~~~~~~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
@@ -83,7 +88,4 @@ tests/cases/conformance/jsx/file.tsx(36,29): error TS2322: Type 'string' is not
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:30:38: The expected type comes from property 'y1' which is declared here on type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'
|
||||
const e4 = <TestingOptional y1="hello" y2={1000}>Hi</TestingOptional>
|
||||
~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:30:38: The expected type comes from property 'y1' which is declared here on type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
tests/cases/conformance/jsx/file.tsx(48,13): error TS2322: Type '{ children: string; to: string; onClick: (e: MouseEvent<any>) => void; }' is not assignable to type 'HyphenProps'.
|
||||
Property '"data-format"' is missing in type '{ children: string; to: string; onClick: (e: MouseEvent<any>) => void; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(49,13): error TS2322: Type '{ children: string; to: string; onClick: (e: any) => void; }' is not assignable to type 'HyphenProps'.
|
||||
Property '"data-format"' is missing in type '{ children: string; to: string; onClick: (e: any) => void; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(50,13): error TS2322: Type '{ onClick: () => void; to: string; }' is not assignable to type 'HyphenProps'.
|
||||
Property '"data-format"' is missing in type '{ onClick: () => void; to: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(51,13): error TS2322: Type '{ onClick: (k: MouseEvent<any>) => void; to: string; }' is not assignable to type 'HyphenProps'.
|
||||
Property '"data-format"' is missing in type '{ onClick: (k: MouseEvent<any>) => void; to: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(53,13): error TS2322: Type '{ to: string; onClick(e: any): void; }' is not assignable to type 'HyphenProps'.
|
||||
Property '"data-format"' is missing in type '{ to: string; onClick(e: any): void; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(48,13): error TS2322: Type '{ children: string; to: string; onClick: (e: MouseEvent<any>) => void; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
|
||||
Property 'to' does not exist on type 'IntrinsicAttributes & HyphenProps'.
|
||||
tests/cases/conformance/jsx/file.tsx(54,51): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsx/file.tsx(55,68): error TS2322: Type 'true' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsx/file.tsx(56,24): error TS2322: Type 'true' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (8 errors) ====
|
||||
==== tests/cases/conformance/jsx/file.tsx (4 errors) ====
|
||||
import React = require('react')
|
||||
|
||||
export interface ClickableProps {
|
||||
@@ -63,25 +55,13 @@ tests/cases/conformance/jsx/file.tsx(56,24): error TS2322: Type 'true' is not as
|
||||
// Error
|
||||
const b0 = <MainButton to='/some/path' onClick={(e)=>{}}>GO</MainButton>; // extra property;
|
||||
~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ children: string; to: string; onClick: (e: MouseEvent<any>) => void; }' is not assignable to type 'HyphenProps'.
|
||||
!!! error TS2322: Property '"data-format"' is missing in type '{ children: string; to: string; onClick: (e: MouseEvent<any>) => void; }'.
|
||||
!!! error TS2322: Type '{ children: string; to: string; onClick: (e: MouseEvent<any>) => void; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
|
||||
!!! error TS2322: Property 'to' does not exist on type 'IntrinsicAttributes & HyphenProps'.
|
||||
const b1 = <MainButton onClick={(e: any)=> {}} {...obj0}>Hello world</MainButton>; // extra property;
|
||||
~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ children: string; to: string; onClick: (e: any) => void; }' is not assignable to type 'HyphenProps'.
|
||||
!!! error TS2322: Property '"data-format"' is missing in type '{ children: string; to: string; onClick: (e: any) => void; }'.
|
||||
const b2 = <MainButton {...{to: "10000"}} {...obj2} />; // extra property
|
||||
~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ onClick: () => void; to: string; }' is not assignable to type 'HyphenProps'.
|
||||
!!! error TS2322: Property '"data-format"' is missing in type '{ onClick: () => void; to: string; }'.
|
||||
const b3 = <MainButton {...{to: "10000"}} {...{onClick: (k) => {}}} />; // extra property
|
||||
~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ onClick: (k: MouseEvent<any>) => void; to: string; }' is not assignable to type 'HyphenProps'.
|
||||
!!! error TS2322: Property '"data-format"' is missing in type '{ onClick: (k: MouseEvent<any>) => void; to: string; }'.
|
||||
const b4 = <MainButton {...obj3} to />; // Should error because Incorrect type; but attributes are any so everything is allowed
|
||||
const b5 = <MainButton {...{ onClick(e: any) { } }} {...obj0} />; // Spread retain method declaration (see GitHub #13365), so now there is an extra attributes
|
||||
~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ to: string; onClick(e: any): void; }' is not assignable to type 'HyphenProps'.
|
||||
!!! error TS2322: Property '"data-format"' is missing in type '{ to: string; onClick(e: any): void; }'.
|
||||
const b6 = <MainButton {...{ onClick(e: any){} }} children={10} />; // incorrect type for optional attribute
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
tests/cases/conformance/jsx/file.tsx(19,10): error TS2322: Type '{ naaame: string; }' is not assignable to type '{ name: string; }'.
|
||||
Property 'name' is missing in type '{ naaame: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(19,10): error TS2322: Type '{ naaame: string; }' is not assignable to type 'IntrinsicAttributes & { name: string; }'.
|
||||
Property 'naaame' does not exist on type 'IntrinsicAttributes & { name: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(27,15): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsx/file.tsx(29,10): error TS2559: Type '{ naaaaaaame: string; }' has no properties in common with type 'IntrinsicAttributes & { name?: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(34,10): error TS2322: Type '{ extra-prop-name: string; }' is not assignable to type '{ "prop-name": string; }'.
|
||||
Property '"prop-name"' is missing in type '{ extra-prop-name: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(37,10): error TS2559: Type '{ prop1: true; }' has no properties in common with type 'IntrinsicAttributes'.
|
||||
tests/cases/conformance/jsx/file.tsx(38,11): error TS2559: Type '{ ref: (x: any) => any; }' has no properties in common with type 'IntrinsicAttributes'.
|
||||
tests/cases/conformance/jsx/file.tsx(29,10): error TS2322: Type '{ naaaaaaame: string; }' is not assignable to type 'IntrinsicAttributes & { name?: string; }'.
|
||||
Property 'naaaaaaame' does not exist on type 'IntrinsicAttributes & { name?: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(34,10): error TS2322: Type '{ extra-prop-name: string; }' is not assignable to type 'IntrinsicAttributes & { "prop-name": string; }'.
|
||||
Type '{ extra-prop-name: string; }' is not assignable to type '{ "prop-name": string; }'.
|
||||
Property '"prop-name"' is missing in type '{ extra-prop-name: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(37,10): error TS2322: Type '{ prop1: true; }' is not assignable to type 'IntrinsicAttributes'.
|
||||
Property 'prop1' does not exist on type 'IntrinsicAttributes'.
|
||||
tests/cases/conformance/jsx/file.tsx(38,11): error TS2322: Type '{ ref: (x: any) => any; }' is not assignable to type 'IntrinsicAttributes'.
|
||||
Property 'ref' does not exist on type 'IntrinsicAttributes'.
|
||||
tests/cases/conformance/jsx/file.tsx(41,16): error TS1005: ',' expected.
|
||||
tests/cases/conformance/jsx/file.tsx(45,11): error TS2559: Type '{ prop1: boolean; }' has no properties in common with type 'IntrinsicAttributes'.
|
||||
|
||||
@@ -31,8 +35,8 @@ tests/cases/conformance/jsx/file.tsx(45,11): error TS2559: Type '{ prop1: boolea
|
||||
// Error
|
||||
let b = <Greet naaame='world' />;
|
||||
~~~~~
|
||||
!!! error TS2322: Type '{ naaame: string; }' is not assignable to type '{ name: string; }'.
|
||||
!!! error TS2322: Property 'name' is missing in type '{ naaame: string; }'.
|
||||
!!! error TS2322: Type '{ naaame: string; }' is not assignable to type 'IntrinsicAttributes & { name: string; }'.
|
||||
!!! error TS2322: Property 'naaame' does not exist on type 'IntrinsicAttributes & { name: string; }'.
|
||||
|
||||
// OK
|
||||
let c = <Meet />;
|
||||
@@ -46,23 +50,27 @@ tests/cases/conformance/jsx/file.tsx(45,11): error TS2559: Type '{ prop1: boolea
|
||||
// Error
|
||||
let f = <Meet naaaaaaame='no' />;
|
||||
~~~~
|
||||
!!! error TS2559: Type '{ naaaaaaame: string; }' has no properties in common with type 'IntrinsicAttributes & { name?: string; }'.
|
||||
!!! error TS2322: Type '{ naaaaaaame: string; }' is not assignable to type 'IntrinsicAttributes & { name?: string; }'.
|
||||
!!! error TS2322: Property 'naaaaaaame' does not exist on type 'IntrinsicAttributes & { name?: string; }'.
|
||||
|
||||
// OK
|
||||
let g = <MeetAndGreet prop-name="Bob" />;
|
||||
// Error
|
||||
let h = <MeetAndGreet extra-prop-name="World" />;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ extra-prop-name: string; }' is not assignable to type '{ "prop-name": string; }'.
|
||||
!!! error TS2322: Property '"prop-name"' is missing in type '{ extra-prop-name: string; }'.
|
||||
!!! error TS2322: Type '{ extra-prop-name: string; }' is not assignable to type 'IntrinsicAttributes & { "prop-name": string; }'.
|
||||
!!! error TS2322: Type '{ extra-prop-name: string; }' is not assignable to type '{ "prop-name": string; }'.
|
||||
!!! error TS2322: Property '"prop-name"' is missing in type '{ extra-prop-name: string; }'.
|
||||
|
||||
// Error
|
||||
let i = <EmptyPropSFC prop1 />
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2559: Type '{ prop1: true; }' has no properties in common with type 'IntrinsicAttributes'.
|
||||
!!! error TS2322: Type '{ prop1: true; }' is not assignable to type 'IntrinsicAttributes'.
|
||||
!!! error TS2322: Property 'prop1' does not exist on type 'IntrinsicAttributes'.
|
||||
let i1 = <EmptyPropSFC ref={x => x.greeting.substr(10)} />
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2559: Type '{ ref: (x: any) => any; }' has no properties in common with type 'IntrinsicAttributes'.
|
||||
!!! error TS2322: Type '{ ref: (x: any) => any; }' is not assignable to type 'IntrinsicAttributes'.
|
||||
!!! error TS2322: Property 'ref' does not exist on type 'IntrinsicAttributes'.
|
||||
|
||||
let o = {
|
||||
prop1: true;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
tests/cases/conformance/jsx/file.tsx(19,10): error TS2559: Type '{ ref: string; }' has no properties in common with type 'IntrinsicAttributes & { name?: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(19,10): error TS2322: Type '{ ref: string; }' is not assignable to type 'IntrinsicAttributes & { name?: string; }'.
|
||||
Property 'ref' does not exist on type 'IntrinsicAttributes & { name?: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(25,42): error TS2551: Property 'subtr' does not exist on type 'string'. Did you mean 'substr'?
|
||||
tests/cases/conformance/jsx/file.tsx(27,33): error TS2339: Property 'notARealProperty' does not exist on type 'BigGreeter'.
|
||||
tests/cases/conformance/jsx/file.tsx(35,26): error TS2339: Property 'propertyNotOnHtmlDivElement' does not exist on type 'HTMLDivElement'.
|
||||
@@ -25,7 +26,8 @@ tests/cases/conformance/jsx/file.tsx(35,26): error TS2339: Property 'propertyNot
|
||||
// Error - not allowed to specify 'ref' on SFCs
|
||||
let c = <Greet ref="myRef" />;
|
||||
~~~~~
|
||||
!!! error TS2559: Type '{ ref: string; }' has no properties in common with type 'IntrinsicAttributes & { name?: string; }'.
|
||||
!!! error TS2322: Type '{ ref: string; }' is not assignable to type 'IntrinsicAttributes & { name?: string; }'.
|
||||
!!! error TS2322: Property 'ref' does not exist on type 'IntrinsicAttributes & { name?: string; }'.
|
||||
|
||||
|
||||
// OK - ref is valid for classes
|
||||
|
||||
+6
-4
@@ -1,5 +1,6 @@
|
||||
tests/cases/conformance/jsx/file.tsx(9,15): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: {}; a: number; }'.
|
||||
Property 'b' is missing in type '{ a: number; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(9,15): error TS2322: Type '{ a: number; }' is not assignable to type 'IntrinsicAttributes & { b: {}; a: number; }'.
|
||||
Type '{ a: number; }' is not assignable to type '{ b: {}; a: number; }'.
|
||||
Property 'b' is missing in type '{ a: number; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(10,15): error TS2322: Type 'T & { ignore-prop: true; }' is not assignable to type 'IntrinsicAttributes & { b: {}; a: {}; }'.
|
||||
Type 'T & { ignore-prop: true; }' is not assignable to type '{ b: {}; a: {}; }'.
|
||||
Property 'a' is missing in type '{ b: number; } & { ignore-prop: true; }'.
|
||||
@@ -16,8 +17,9 @@ tests/cases/conformance/jsx/file.tsx(10,15): error TS2322: Type 'T & { ignore-pr
|
||||
function Baz<T extends {b: number}, U extends {a: boolean, b:string}>(arg1: T, arg2: U) {
|
||||
let a0 = <OverloadComponent a={arg1.b}/>
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: {}; a: number; }'.
|
||||
!!! error TS2322: Property 'b' is missing in type '{ a: number; }'.
|
||||
!!! error TS2322: Type '{ a: number; }' is not assignable to type 'IntrinsicAttributes & { b: {}; a: number; }'.
|
||||
!!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: {}; a: number; }'.
|
||||
!!! error TS2322: Property 'b' is missing in type '{ a: number; }'.
|
||||
let a2 = <OverloadComponent {...arg1} ignore-prop /> // missing a
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type 'T & { ignore-prop: true; }' is not assignable to type 'IntrinsicAttributes & { b: {}; a: {}; }'.
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
tests/cases/conformance/jsx/file.tsx(16,42): error TS2339: Property 'prop1' does not exist on type 'IntrinsicAttributes & { prop: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
import React = require('react')
|
||||
|
||||
declare function Component<U>(l: U): JSX.Element;
|
||||
function createComponent<T extends { prop: number }>(arg: T) {
|
||||
let a1 = <Component {...arg} />;
|
||||
let a2 = <Component {...arg} prop1 />;
|
||||
}
|
||||
|
||||
declare function ComponentSpecific<U>(l: { prop: U }): JSX.Element;
|
||||
declare function ComponentSpecific1<U>(l: { prop: U, "ignore-prop": number }): JSX.Element;
|
||||
|
||||
function Bar<T extends { prop: number }>(arg: T) {
|
||||
let a1 = <ComponentSpecific {...arg} ignore-prop="hi" />; // U is number
|
||||
let a2 = <ComponentSpecific1 {...arg} ignore-prop={10} />; // U is number
|
||||
let a3 = <ComponentSpecific {...arg} prop="hello" />; // U is "hello"
|
||||
let a4 = <ComponentSpecific {...arg} prop1="hello" />; // U is "hello"
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'prop1' does not exist on type 'IntrinsicAttributes & { prop: number; }'.
|
||||
}
|
||||
|
||||
@@ -3,22 +3,20 @@ tests/cases/conformance/jsx/file.tsx(18,26): error TS2322: Type 'number' is not
|
||||
tests/cases/conformance/jsx/file.tsx(20,13): error TS2558: Expected 1 type arguments, but got 2.
|
||||
tests/cases/conformance/jsx/file.tsx(22,13): error TS2558: Expected 1 type arguments, but got 2.
|
||||
tests/cases/conformance/jsx/file.tsx(24,12): error TS1099: Type argument list cannot be empty.
|
||||
tests/cases/conformance/jsx/file.tsx(24,13): error TS2558: Expected 1 type arguments, but got 0.
|
||||
tests/cases/conformance/jsx/file.tsx(26,12): error TS1099: Type argument list cannot be empty.
|
||||
tests/cases/conformance/jsx/file.tsx(26,13): error TS2558: Expected 1 type arguments, but got 0.
|
||||
tests/cases/conformance/jsx/file.tsx(39,14): error TS2344: Type 'Prop' does not satisfy the constraint '{ a: string; }'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsx/file.tsx(39,20): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsx/file.tsx(41,14): error TS2344: Type 'Prop' does not satisfy the constraint '{ a: string; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(41,20): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsx/file.tsx(47,14): error TS2558: Expected 1-2 type arguments, but got 3.
|
||||
tests/cases/conformance/jsx/file.tsx(47,53): error TS2339: Property 'b' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp2<{ a: string; }, {}>> & { a: string; } & { children?: ReactNode; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(49,14): error TS2558: Expected 1-2 type arguments, but got 3.
|
||||
tests/cases/conformance/jsx/file.tsx(49,53): error TS2339: Property 'b' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp2<{ a: string; }, {}>> & { a: string; } & { children?: ReactNode; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(51,47): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/jsx/file.tsx(53,47): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (16 errors) ====
|
||||
==== tests/cases/conformance/jsx/file.tsx (14 errors) ====
|
||||
import React = require('react');
|
||||
|
||||
interface Prop {
|
||||
@@ -55,10 +53,14 @@ tests/cases/conformance/jsx/file.tsx(53,47): error TS2322: Type 'string' is not
|
||||
x = <MyComp<> a={10} b="hi" />; // error
|
||||
~~
|
||||
!!! error TS1099: Type argument list cannot be empty.
|
||||
|
||||
!!! error TS2558: Expected 1 type arguments, but got 0.
|
||||
|
||||
x = <MyComp<> a={10} b="hi"></MyComp>; // error
|
||||
~~
|
||||
!!! error TS1099: Type argument list cannot be empty.
|
||||
|
||||
!!! error TS2558: Expected 1 type arguments, but got 0.
|
||||
|
||||
x= <MyComp<{}> /> // OK
|
||||
|
||||
@@ -76,16 +78,10 @@ tests/cases/conformance/jsx/file.tsx(53,47): error TS2322: Type 'string' is not
|
||||
!!! error TS2344: Type 'Prop' does not satisfy the constraint '{ a: string; }'.
|
||||
!!! error TS2344: Types of property 'a' are incompatible.
|
||||
!!! error TS2344: Type 'number' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:32:35: The expected type comes from property 'a' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp2<{ a: string; }, {}>> & { a: string; } & { children?: ReactNode; }'
|
||||
|
||||
x = <MyComp2<Prop> a={10} b="hi"></MyComp2>; // error
|
||||
~~~~
|
||||
!!! error TS2344: Type 'Prop' does not satisfy the constraint '{ a: string; }'.
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:32:35: The expected type comes from property 'a' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp2<{ a: string; }, {}>> & { a: string; } & { children?: ReactNode; }'
|
||||
|
||||
x = <MyComp2<{a: string}, {b: string}> a="hi" b="hi" />; // OK
|
||||
|
||||
@@ -94,14 +90,10 @@ tests/cases/conformance/jsx/file.tsx(53,47): error TS2322: Type 'string' is not
|
||||
x = <MyComp2<{a: string}, {b: string}, Prop> a="hi" b="hi" />; // error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2558: Expected 1-2 type arguments, but got 3.
|
||||
~~~~~~
|
||||
!!! error TS2339: Property 'b' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp2<{ a: string; }, {}>> & { a: string; } & { children?: ReactNode; }'.
|
||||
|
||||
x = <MyComp2<{a: string}, {b: string}, Prop> a="hi" b="hi"></MyComp2>; // error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2558: Expected 1-2 type arguments, but got 3.
|
||||
~~~~~~
|
||||
!!! error TS2339: Property 'b' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp2<{ a: string; }, {}>> & { a: string; } & { children?: ReactNode; }'.
|
||||
|
||||
x = <MyComp2<{a: string}, {b: number}> a="hi" b="hi" />; // error
|
||||
~
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
tests/cases/conformance/jsx/tsxTypeErrors.tsx(25,19): error TS2339: Property 'reqd' does not exist on type '{}'.
|
||||
tests/cases/conformance/jsx/tsxTypeErrors.tsx(31,19): error TS2339: Property 'pt' does not exist on type '{}'.
|
||||
tests/cases/conformance/jsx/tsxTypeErrors.tsx(25,11): error TS2322: Type '{ reqd: boolean; }' is not assignable to type '{}'.
|
||||
Property 'reqd' does not exist on type '{}'.
|
||||
tests/cases/conformance/jsx/tsxTypeErrors.tsx(31,11): error TS2322: Type '{ pt: { x: number; y: string; }; }' is not assignable to type '{}'.
|
||||
Property 'pt' does not exist on type '{}'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/tsxTypeErrors.tsx (2 errors) ====
|
||||
@@ -28,15 +30,17 @@ tests/cases/conformance/jsx/tsxTypeErrors.tsx(31,19): error TS2339: Property 'pt
|
||||
// Let's use it
|
||||
// TODO: Error on missing 'reqd'
|
||||
var b1 = <MyClass reqd={true} />;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'reqd' does not exist on type '{}'.
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type '{ reqd: boolean; }' is not assignable to type '{}'.
|
||||
!!! error TS2322: Property 'reqd' does not exist on type '{}'.
|
||||
|
||||
// Mistyped attribute member
|
||||
// sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'.
|
||||
// Types of property 'y' are incompatible.
|
||||
// Type 'string' is not assignable to type 'number'.
|
||||
var b2 = <MyClass pt={{x: 4, y: 'oops'}} />;
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'pt' does not exist on type '{}'.
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type '{ pt: { x: number; y: string; }; }' is not assignable to type '{}'.
|
||||
!!! error TS2322: Property 'pt' does not exist on type '{}'.
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
tests/cases/conformance/jsx/file.tsx(12,2): error TS2604: JSX element type 'SFCComp' does not have any construct or call signatures.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
import React = require('react');
|
||||
|
||||
function SFC1(prop: { x: number }) {
|
||||
return <div>hello</div>;
|
||||
};
|
||||
|
||||
function SFC2(prop: { x: boolean }) {
|
||||
return <h1>World </h1>;
|
||||
}
|
||||
|
||||
var SFCComp = SFC1 || SFC2;
|
||||
<SFCComp x />
|
||||
~~~~~~~
|
||||
!!! error TS2604: JSX element type 'SFCComp' does not have any construct or call signatures.
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/jsx/file.tsx(12,10): error TS2322: Type 'string' is not assignable to type 'number | boolean'.
|
||||
tests/cases/conformance/jsx/file.tsx(12,2): error TS2604: JSX element type 'SFCComp' does not have any construct or call signatures.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
@@ -14,6 +14,5 @@ tests/cases/conformance/jsx/file.tsx(12,10): error TS2322: Type 'string' is not
|
||||
|
||||
var SFCComp = SFC1 || SFC2;
|
||||
<SFCComp x={"hi"}/>
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number | boolean'.
|
||||
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:3:23: The expected type comes from property 'x' which is declared here on type '(IntrinsicAttributes & { x: number; }) | (IntrinsicAttributes & { x: boolean; })'
|
||||
~~~~~~~
|
||||
!!! error TS2604: JSX element type 'SFCComp' does not have any construct or call signatures.
|
||||
@@ -0,0 +1,42 @@
|
||||
tests/cases/conformance/jsx/file.tsx(32,10): error TS2604: JSX element type 'RCComp' does not have any construct or call signatures.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
import React = require('react');
|
||||
|
||||
class RC1 extends React.Component<{x : number}, {}> {
|
||||
render() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class RC2 extends React.Component<{ x: string }, {}> {
|
||||
render() {
|
||||
return null;
|
||||
}
|
||||
private method() { }
|
||||
}
|
||||
|
||||
class RC3 extends React.Component<{}, {}> {
|
||||
render() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class RC4 extends React.Component<{}, {}> {
|
||||
render() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
var EmptyRCComp = RC3 || RC4;
|
||||
var PartRCComp = RC1 || RC4;
|
||||
var RCComp = RC1 || RC2;
|
||||
// OK
|
||||
let a = <RCComp x="Hi" />;
|
||||
~~~~~~
|
||||
!!! error TS2604: JSX element type 'RCComp' does not have any construct or call signatures.
|
||||
let a1 = <EmptyRCComp />;
|
||||
let a2 = <EmptyRCComp data-prop="hello" />;
|
||||
let b = <PartRCComp />
|
||||
let c = <PartRCComp data-extra="hello" />
|
||||
@@ -1,6 +1,8 @@
|
||||
tests/cases/conformance/jsx/file.tsx(32,17): error TS2322: Type 'true' is not assignable to type 'ReactText'.
|
||||
tests/cases/conformance/jsx/file.tsx(33,10): error TS2559: Type '{ x: number; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes<RC4> & { children?: ReactNode; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(34,10): error TS2559: Type '{ prop: true; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes<RC3> & { children?: ReactNode; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(32,10): error TS2604: JSX element type 'RCComp' does not have any construct or call signatures.
|
||||
tests/cases/conformance/jsx/file.tsx(33,10): error TS2322: Type '{ x: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<RC4> & { children?: ReactNode; }'.
|
||||
Property 'x' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<RC4> & { children?: ReactNode; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(34,10): error TS2322: Type '{ prop: true; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<RC3> & { children?: ReactNode; }'.
|
||||
Property 'prop' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<RC3> & { children?: ReactNode; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
|
||||
@@ -36,13 +38,14 @@ tests/cases/conformance/jsx/file.tsx(34,10): error TS2559: Type '{ prop: true; }
|
||||
var PartRCComp = RC1 || RC4;
|
||||
// Error
|
||||
let a = <RCComp x />;
|
||||
~
|
||||
!!! error TS2322: Type 'true' is not assignable to type 'ReactText'.
|
||||
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:3:36: The expected type comes from property 'x' which is declared here on type '(IntrinsicAttributes & IntrinsicClassAttributes<RC1> & { x: number; } & { children?: ReactNode; }) | (IntrinsicAttributes & IntrinsicClassAttributes<RC2> & { x: string; } & { children?: ReactNode; })'
|
||||
~~~~~~
|
||||
!!! error TS2604: JSX element type 'RCComp' does not have any construct or call signatures.
|
||||
let b = <PartRCComp x={10} />
|
||||
~~~~~~~~~~
|
||||
!!! error TS2559: Type '{ x: number; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes<RC4> & { children?: ReactNode; }'.
|
||||
!!! error TS2322: Type '{ x: number; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<RC4> & { children?: ReactNode; }'.
|
||||
!!! error TS2322: Property 'x' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<RC4> & { children?: ReactNode; }'.
|
||||
let c = <EmptyRCComp prop />;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2559: Type '{ prop: true; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes<RC3> & { children?: ReactNode; }'.
|
||||
!!! error TS2322: Type '{ prop: true; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<RC3> & { children?: ReactNode; }'.
|
||||
!!! error TS2322: Property 'prop' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<RC3> & { children?: ReactNode; }'.
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
tests/cases/conformance/jsx/file.tsx(18,10): error TS2559: Type '{ x: true; }' has no properties in common with type 'IntrinsicAttributes'.
|
||||
tests/cases/conformance/jsx/file.tsx(18,10): error TS2322: Type '{ x: true; }' is not assignable to type 'IntrinsicAttributes'.
|
||||
Property 'x' does not exist on type 'IntrinsicAttributes'.
|
||||
tests/cases/conformance/jsx/file.tsx(19,27): error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
tests/cases/conformance/jsx/file.tsx(20,10): error TS2322: Type '{}' is not assignable to type '{ x: boolean; }'.
|
||||
Property 'x' is missing in type '{}'.
|
||||
tests/cases/conformance/jsx/file.tsx(21,10): error TS2322: Type '{ data-prop: true; }' is not assignable to type '{ x: boolean; }'.
|
||||
Property 'x' is missing in type '{ data-prop: true; }'.
|
||||
tests/cases/conformance/jsx/file.tsx(20,10): error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & { x: boolean; }'.
|
||||
Type '{}' is not assignable to type '{ x: boolean; }'.
|
||||
Property 'x' is missing in type '{}'.
|
||||
tests/cases/conformance/jsx/file.tsx(21,10): error TS2322: Type '{ data-prop: true; }' is not assignable to type 'IntrinsicAttributes & { x: boolean; }'.
|
||||
Type '{ data-prop: true; }' is not assignable to type '{ x: boolean; }'.
|
||||
Property 'x' is missing in type '{ data-prop: true; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (4 errors) ====
|
||||
@@ -26,18 +29,21 @@ tests/cases/conformance/jsx/file.tsx(21,10): error TS2322: Type '{ data-prop: tr
|
||||
// Error
|
||||
let a = <EmptySFCComp x />;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2559: Type '{ x: true; }' has no properties in common with type 'IntrinsicAttributes'.
|
||||
!!! error TS2322: Type '{ x: true; }' is not assignable to type 'IntrinsicAttributes'.
|
||||
!!! error TS2322: Property 'x' does not exist on type 'IntrinsicAttributes'.
|
||||
let b = <SFC2AndEmptyComp x="hi" />;
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:11:23: The expected type comes from property 'x' which is declared here on type 'IntrinsicAttributes & { x: boolean; }'
|
||||
let c = <SFC2AndEmptyComp />;
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{}' is not assignable to type '{ x: boolean; }'.
|
||||
!!! error TS2322: Property 'x' is missing in type '{}'.
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'IntrinsicAttributes & { x: boolean; }'.
|
||||
!!! error TS2322: Type '{}' is not assignable to type '{ x: boolean; }'.
|
||||
!!! error TS2322: Property 'x' is missing in type '{}'.
|
||||
let d = <SFC2AndEmptyComp data-prop />;
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ data-prop: true; }' is not assignable to type '{ x: boolean; }'.
|
||||
!!! error TS2322: Property 'x' is missing in type '{ data-prop: true; }'.
|
||||
!!! error TS2322: Type '{ data-prop: true; }' is not assignable to type 'IntrinsicAttributes & { x: boolean; }'.
|
||||
!!! error TS2322: Type '{ data-prop: true; }' is not assignable to type '{ x: boolean; }'.
|
||||
!!! error TS2322: Property 'x' is missing in type '{ data-prop: true; }'.
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
tests/cases/conformance/jsx/file.tsx(10,18): error TS2604: JSX element type 'AnyComponent' does not have any construct or call signatures.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
import React = require('react');
|
||||
|
||||
interface ComponentProps {
|
||||
AnyComponent: React.StatelessComponent<any> | React.ComponentClass<any>;
|
||||
}
|
||||
|
||||
class MyComponent extends React.Component<ComponentProps, {}> {
|
||||
render() {
|
||||
const { AnyComponent } = this.props;
|
||||
return (<AnyComponent />);
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2604: JSX element type 'AnyComponent' does not have any construct or call signatures.
|
||||
}
|
||||
}
|
||||
|
||||
// Stateless Component As Props
|
||||
<MyComponent AnyComponent={() => <button>test</button>}/>
|
||||
|
||||
// Component Class as Props
|
||||
class MyButtonComponent extends React.Component<{},{}> {
|
||||
}
|
||||
|
||||
<MyComponent AnyComponent={MyButtonComponent} />
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// @jsx: react
|
||||
// @strict: true
|
||||
// @esModuleInterop: true
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
|
||||
import React from 'react';
|
||||
|
||||
function test<P>(wrappedProps: P) {
|
||||
let MySFC = function(props: P) {
|
||||
return <>hello</>;
|
||||
};
|
||||
class MyComponent extends React.Component<P> {
|
||||
render() {
|
||||
return <>hello</>;
|
||||
}
|
||||
}
|
||||
let x = <MySFC />; // should error
|
||||
let y = <MyComponent />; // should error
|
||||
|
||||
let z = <MySFC {...wrappedProps} /> // should work
|
||||
let q = <MyComponent {...wrappedProps} /> // should work
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// @esModuleInterop: true
|
||||
// @skipLibCheck: true
|
||||
// @jsx: react
|
||||
// @strict: true
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
|
||||
import React from "react";
|
||||
|
||||
class MyComponent extends React.Component<{dataSource: number[], onClick?: any}, {}> {
|
||||
render() {
|
||||
return (<div {...this.props} className="ok"></div>);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// @jsx: react
|
||||
// @strict: true
|
||||
// @esModuleInterop: true
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
|
||||
import React from 'react';
|
||||
interface Props {
|
||||
text: string;
|
||||
}
|
||||
|
||||
function BackButton(_props: Props) {
|
||||
return <div />
|
||||
}
|
||||
BackButton.defaultProps = {
|
||||
text: 'Go Back',
|
||||
};
|
||||
let a = <BackButton />
|
||||
@@ -2,6 +2,7 @@
|
||||
// @jsx: preserve
|
||||
// @noLib: true
|
||||
// @skipLibCheck: true
|
||||
// @noImplicitAny: true
|
||||
// @libFiles: react.d.ts,lib.d.ts
|
||||
|
||||
import React = require('react');
|
||||
|
||||
@@ -19,6 +19,9 @@ class Poisoned extends React.Component<PoisonedProp, {}> {
|
||||
|
||||
const obj = {};
|
||||
|
||||
// OK
|
||||
<Poisoned {...{x: "ok", y: "2"}} />;
|
||||
|
||||
// Error
|
||||
let p = <Poisoned {...obj} />;
|
||||
let y = <Poisoned />;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
//@Filename: file.tsx
|
||||
// @jsx: preserve
|
||||
// @noLib: true
|
||||
// @skipLibCheck: true
|
||||
|
||||
//// declare module JSX {
|
||||
//// interface Element { }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
//@Filename: file.tsx
|
||||
// @jsx: preserve
|
||||
// @noLib: true
|
||||
// @skipLibCheck: true
|
||||
|
||||
//// declare module JSX {
|
||||
//// interface Element { }
|
||||
@@ -20,4 +20,4 @@
|
||||
//// <SFCComp /**/ />
|
||||
|
||||
goTo.marker();
|
||||
verify.completionListContains("x", "(property) x: number | boolean");
|
||||
verify.completionListIsEmpty();
|
||||
@@ -31,10 +31,10 @@
|
||||
//// let opt = <[|Main/*sixthTarget*/Button|] wrong />;
|
||||
|
||||
verify.goToDefinition({
|
||||
firstTarget: "thirdSource",
|
||||
secondTarget: "thirdSource",
|
||||
firstTarget: "firstSource",
|
||||
secondTarget: "firstSource",
|
||||
thirdTarget: "firstSource",
|
||||
fourthTarget: "firstSource",
|
||||
fifthTarget: "secondSource",
|
||||
sixthTarget: "thirdSource"
|
||||
sixthTarget: "firstSource"
|
||||
});
|
||||
|
||||
@@ -22,5 +22,5 @@
|
||||
//// <[|SFC/*one*/Comp|] x />
|
||||
|
||||
verify.goToDefinition({
|
||||
"one": ["def", "pt1"],
|
||||
"one": ["def"],
|
||||
});
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
// @jsx: preserve
|
||||
// @noLib: true
|
||||
|
||||
//// declare function OverloadComponent(): JSX.Element;
|
||||
//// declare function OverloadComponent<U>(attr: {b: U, a?: string, "ignore-prop": boolean}): JSX.Element;
|
||||
//// declare function OverloadComponent<T, U>(attr: {b: U, a: T}): JSX.Element;
|
||||
//// declare function OverloadComponent(): JSX.Element; // effective argument type of `{}`, needs to be last
|
||||
|
||||
//// function Baz<T extends {b: number}, U extends {a: boolean, b:string}>(arg1: T, arg2: U) {
|
||||
//// let a0 = <Overloa/*1*/dComponent {...arg1} a="hello" ignore-prop />;
|
||||
@@ -22,7 +22,7 @@ verify.quickInfos({
|
||||
1: "function OverloadComponent<number>(attr: {\n b: number;\n a?: string;\n \"ignore-prop\": boolean;\n}): any (+2 overloads)",
|
||||
2: "function OverloadComponent<boolean, string>(attr: {\n b: string;\n a: boolean;\n}): any (+2 overloads)",
|
||||
3: "function OverloadComponent<boolean, string>(attr: {\n b: string;\n a: boolean;\n}): any (+2 overloads)",
|
||||
4: "function OverloadComponent<number>(attr: {\n b: number;\n a?: string;\n \"ignore-prop\": boolean;\n}): any (+2 overloads)",
|
||||
4: "function OverloadComponent(): any (+2 overloads)", // Subtype pass chooses this overload, since `a` is missing from the top overload, and `ignore-prop` is missing from the second (while T & {ignore-prop: true} is a proper subtype of `{}`)
|
||||
5: "function OverloadComponent(): any (+2 overloads)",
|
||||
6: "function OverloadComponent<boolean, string & number>(attr: {\n b: string & number;\n a: boolean;\n}): any (+2 overloads)",
|
||||
7: "function OverloadComponent<boolean, number & string>(attr: {\n b: number & string;\n a: boolean;\n}): any (+2 overloads)",
|
||||
|
||||
Reference in New Issue
Block a user