test: add test for it

This commit is contained in:
Jack Works
2020-05-07 10:41:52 +08:00
parent c36fe2339a
commit ffb35a3eb1
8 changed files with 273 additions and 6 deletions

View File

@@ -0,0 +1,79 @@
tests/cases/compiler/spellingSuggestionJSXAttribute.tsx(8,4): error TS2322: Type '{ class: string; }' is not assignable to type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'.
Property 'class' does not exist on type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'. Did you mean 'className'?
tests/cases/compiler/spellingSuggestionJSXAttribute.tsx(9,4): error TS2322: Type '{ for: string; }' is not assignable to type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'.
Property 'for' does not exist on type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'.
tests/cases/compiler/spellingSuggestionJSXAttribute.tsx(10,8): error TS2322: Type '{ for: string; }' is not assignable to type 'DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>'.
Property 'for' does not exist on type 'DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>'. Did you mean 'htmlFor'?
tests/cases/compiler/spellingSuggestionJSXAttribute.tsx(11,8): error TS2322: Type '{ for: string; class: string; }' is not assignable to type 'DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>'.
Property 'for' does not exist on type 'DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>'. Did you mean 'htmlFor'?
tests/cases/compiler/spellingSuggestionJSXAttribute.tsx(12,9): error TS2769: No overload matches this call.
Overload 1 of 2, '(props: Readonly<{ className?: string; htmlFor?: string; }>): MyComp', gave the following error.
Type '{ class: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp> & Readonly<{ children?: ReactNode; }> & Readonly<{ className?: string; htmlFor?: string; }>'.
Property 'class' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp> & Readonly<{ children?: ReactNode; }> & Readonly<{ className?: string; htmlFor?: string; }>'. Did you mean 'className'?
Overload 2 of 2, '(props: { className?: string; htmlFor?: string; }, context?: any): MyComp', gave the following error.
Type '{ class: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp> & Readonly<{ children?: ReactNode; }> & Readonly<{ className?: string; htmlFor?: string; }>'.
Property 'class' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp> & Readonly<{ children?: ReactNode; }> & Readonly<{ className?: string; htmlFor?: string; }>'. Did you mean 'className'?
tests/cases/compiler/spellingSuggestionJSXAttribute.tsx(13,10): error TS2322: Type '{ class: string; }' is not assignable to type 'IntrinsicAttributes & { className?: string; htmlFor?: string; }'.
Property 'class' does not exist on type 'IntrinsicAttributes & { className?: string; htmlFor?: string; }'. Did you mean 'className'?
tests/cases/compiler/spellingSuggestionJSXAttribute.tsx(14,9): error TS2769: No overload matches this call.
Overload 1 of 2, '(props: Readonly<{ className?: string; htmlFor?: string; }>): MyComp', gave the following error.
Type '{ for: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp> & Readonly<{ children?: ReactNode; }> & Readonly<{ className?: string; htmlFor?: string; }>'.
Property 'for' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp> & Readonly<{ children?: ReactNode; }> & Readonly<{ className?: string; htmlFor?: string; }>'. Did you mean 'htmlFor'?
Overload 2 of 2, '(props: { className?: string; htmlFor?: string; }, context?: any): MyComp', gave the following error.
Type '{ for: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp> & Readonly<{ children?: ReactNode; }> & Readonly<{ className?: string; htmlFor?: string; }>'.
Property 'for' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp> & Readonly<{ children?: ReactNode; }> & Readonly<{ className?: string; htmlFor?: string; }>'. Did you mean 'htmlFor'?
tests/cases/compiler/spellingSuggestionJSXAttribute.tsx(15,10): error TS2322: Type '{ for: string; }' is not assignable to type 'IntrinsicAttributes & { className?: string; htmlFor?: string; }'.
Property 'for' does not exist on type 'IntrinsicAttributes & { className?: string; htmlFor?: string; }'. Did you mean 'htmlFor'?
==== tests/cases/compiler/spellingSuggestionJSXAttribute.tsx (8 errors) ====
/// <reference path="/.lib/react16.d.ts" />
import * as React from "react";
function MyComp2(props: { className?: string, htmlFor?: string }) {
return null!;
}
class MyComp extends React.Component<{ className?: string, htmlFor?: string }> { }
<a class="" />;
~~~~~
!!! error TS2322: Type '{ class: string; }' is not assignable to type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'.
!!! error TS2322: Property 'class' does not exist on type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'. Did you mean 'className'?
<a for="" />; // should have no fix
~~~
!!! error TS2322: Type '{ for: string; }' is not assignable to type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'.
!!! error TS2322: Property 'for' does not exist on type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'.
<label for="" />;
~~~
!!! error TS2322: Type '{ for: string; }' is not assignable to type 'DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>'.
!!! error TS2322: Property 'for' does not exist on type 'DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>'. Did you mean 'htmlFor'?
<label for="" class="" />;
~~~
!!! error TS2322: Type '{ for: string; class: string; }' is not assignable to type 'DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>'.
!!! error TS2322: Property 'for' does not exist on type 'DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>'. Did you mean 'htmlFor'?
<MyComp class="" />;
~~~~~
!!! error TS2769: No overload matches this call.
!!! error TS2769: Overload 1 of 2, '(props: Readonly<{ className?: string; htmlFor?: string; }>): MyComp', gave the following error.
!!! error TS2769: Type '{ class: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp> & Readonly<{ children?: ReactNode; }> & Readonly<{ className?: string; htmlFor?: string; }>'.
!!! error TS2769: Property 'class' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp> & Readonly<{ children?: ReactNode; }> & Readonly<{ className?: string; htmlFor?: string; }>'. Did you mean 'className'?
!!! error TS2769: Overload 2 of 2, '(props: { className?: string; htmlFor?: string; }, context?: any): MyComp', gave the following error.
!!! error TS2769: Type '{ class: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp> & Readonly<{ children?: ReactNode; }> & Readonly<{ className?: string; htmlFor?: string; }>'.
!!! error TS2769: Property 'class' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp> & Readonly<{ children?: ReactNode; }> & Readonly<{ className?: string; htmlFor?: string; }>'. Did you mean 'className'?
<MyComp2 class="" />;
~~~~~
!!! error TS2322: Type '{ class: string; }' is not assignable to type 'IntrinsicAttributes & { className?: string; htmlFor?: string; }'.
!!! error TS2322: Property 'class' does not exist on type 'IntrinsicAttributes & { className?: string; htmlFor?: string; }'. Did you mean 'className'?
<MyComp for="" />;
~~~
!!! error TS2769: No overload matches this call.
!!! error TS2769: Overload 1 of 2, '(props: Readonly<{ className?: string; htmlFor?: string; }>): MyComp', gave the following error.
!!! error TS2769: Type '{ for: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp> & Readonly<{ children?: ReactNode; }> & Readonly<{ className?: string; htmlFor?: string; }>'.
!!! error TS2769: Property 'for' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp> & Readonly<{ children?: ReactNode; }> & Readonly<{ className?: string; htmlFor?: string; }>'. Did you mean 'htmlFor'?
!!! error TS2769: Overload 2 of 2, '(props: { className?: string; htmlFor?: string; }, context?: any): MyComp', gave the following error.
!!! error TS2769: Type '{ for: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp> & Readonly<{ children?: ReactNode; }> & Readonly<{ className?: string; htmlFor?: string; }>'.
!!! error TS2769: Property 'for' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<MyComp> & Readonly<{ children?: ReactNode; }> & Readonly<{ className?: string; htmlFor?: string; }>'. Did you mean 'htmlFor'?
<MyComp2 for="" />;
~~~
!!! error TS2322: Type '{ for: string; }' is not assignable to type 'IntrinsicAttributes & { className?: string; htmlFor?: string; }'.
!!! error TS2322: Property 'for' does not exist on type 'IntrinsicAttributes & { className?: string; htmlFor?: string; }'. Did you mean 'htmlFor'?

View File

@@ -0,0 +1,54 @@
//// [spellingSuggestionJSXAttribute.tsx]
/// <reference path="/.lib/react16.d.ts" />
import * as React from "react";
function MyComp2(props: { className?: string, htmlFor?: string }) {
return null!;
}
class MyComp extends React.Component<{ className?: string, htmlFor?: string }> { }
<a class="" />;
<a for="" />; // should have no fix
<label for="" />;
<label for="" class="" />;
<MyComp class="" />;
<MyComp2 class="" />;
<MyComp for="" />;
<MyComp2 for="" />;
//// [spellingSuggestionJSXAttribute.js]
"use strict";
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 __());
};
})();
exports.__esModule = true;
/// <reference path="react16.d.ts" />
var React = require("react");
function MyComp2(props) {
return null;
}
var MyComp = /** @class */ (function (_super) {
__extends(MyComp, _super);
function MyComp() {
return _super !== null && _super.apply(this, arguments) || this;
}
return MyComp;
}(React.Component));
React.createElement("a", { "class": "" });
React.createElement("a", { "for": "" }); // should have no fix
React.createElement("label", { "for": "" });
React.createElement("label", { "for": "", "class": "" });
React.createElement(MyComp, { "class": "" });
React.createElement(MyComp2, { "class": "" });
React.createElement(MyComp, { "for": "" });
React.createElement(MyComp2, { "for": "" });

View File

@@ -0,0 +1,54 @@
=== tests/cases/compiler/spellingSuggestionJSXAttribute.tsx ===
/// <reference path="react16.d.ts" />
import * as React from "react";
>React : Symbol(React, Decl(spellingSuggestionJSXAttribute.tsx, 1, 6))
function MyComp2(props: { className?: string, htmlFor?: string }) {
>MyComp2 : Symbol(MyComp2, Decl(spellingSuggestionJSXAttribute.tsx, 1, 31))
>props : Symbol(props, Decl(spellingSuggestionJSXAttribute.tsx, 3, 17))
>className : Symbol(className, Decl(spellingSuggestionJSXAttribute.tsx, 3, 25))
>htmlFor : Symbol(htmlFor, Decl(spellingSuggestionJSXAttribute.tsx, 3, 45))
return null!;
}
class MyComp extends React.Component<{ className?: string, htmlFor?: string }> { }
>MyComp : Symbol(MyComp, Decl(spellingSuggestionJSXAttribute.tsx, 5, 1))
>React.Component : Symbol(React.Component, Decl(react16.d.ts, 345, 54), Decl(react16.d.ts, 349, 94))
>React : Symbol(React, Decl(spellingSuggestionJSXAttribute.tsx, 1, 6))
>Component : Symbol(React.Component, Decl(react16.d.ts, 345, 54), Decl(react16.d.ts, 349, 94))
>className : Symbol(className, Decl(spellingSuggestionJSXAttribute.tsx, 6, 38))
>htmlFor : Symbol(htmlFor, Decl(spellingSuggestionJSXAttribute.tsx, 6, 58))
<a class="" />;
>a : Symbol(JSX.IntrinsicElements.a, Decl(react16.d.ts, 2390, 41))
>class : Symbol(class, Decl(spellingSuggestionJSXAttribute.tsx, 7, 2))
<a for="" />; // should have no fix
>a : Symbol(JSX.IntrinsicElements.a, Decl(react16.d.ts, 2390, 41))
>for : Symbol(for, Decl(spellingSuggestionJSXAttribute.tsx, 8, 2))
<label for="" />;
>label : Symbol(JSX.IntrinsicElements.label, Decl(react16.d.ts, 2448, 102))
>for : Symbol(for, Decl(spellingSuggestionJSXAttribute.tsx, 9, 6))
<label for="" class="" />;
>label : Symbol(JSX.IntrinsicElements.label, Decl(react16.d.ts, 2448, 102))
>for : Symbol(for, Decl(spellingSuggestionJSXAttribute.tsx, 10, 6))
>class : Symbol(class, Decl(spellingSuggestionJSXAttribute.tsx, 10, 13))
<MyComp class="" />;
>MyComp : Symbol(MyComp, Decl(spellingSuggestionJSXAttribute.tsx, 5, 1))
>class : Symbol(class, Decl(spellingSuggestionJSXAttribute.tsx, 11, 7))
<MyComp2 class="" />;
>MyComp2 : Symbol(MyComp2, Decl(spellingSuggestionJSXAttribute.tsx, 1, 31))
>class : Symbol(class, Decl(spellingSuggestionJSXAttribute.tsx, 12, 8))
<MyComp for="" />;
>MyComp : Symbol(MyComp, Decl(spellingSuggestionJSXAttribute.tsx, 5, 1))
>for : Symbol(for, Decl(spellingSuggestionJSXAttribute.tsx, 13, 7))
<MyComp2 for="" />;
>MyComp2 : Symbol(MyComp2, Decl(spellingSuggestionJSXAttribute.tsx, 1, 31))
>for : Symbol(for, Decl(spellingSuggestionJSXAttribute.tsx, 14, 8))

View File

@@ -0,0 +1,64 @@
=== tests/cases/compiler/spellingSuggestionJSXAttribute.tsx ===
/// <reference path="react16.d.ts" />
import * as React from "react";
>React : typeof React
function MyComp2(props: { className?: string, htmlFor?: string }) {
>MyComp2 : (props: { className?: string; htmlFor?: string;}) => any
>props : { className?: string; htmlFor?: string; }
>className : string
>htmlFor : string
return null!;
>null! : null
>null : null
}
class MyComp extends React.Component<{ className?: string, htmlFor?: string }> { }
>MyComp : MyComp
>React.Component : React.Component<{ className?: string; htmlFor?: string; }, {}, any>
>React : typeof React
>Component : typeof React.Component
>className : string
>htmlFor : string
<a class="" />;
><a class="" /> : JSX.Element
>a : any
>class : string
<a for="" />; // should have no fix
><a for="" /> : JSX.Element
>a : any
>for : string
<label for="" />;
><label for="" /> : JSX.Element
>label : any
>for : string
<label for="" class="" />;
><label for="" class="" /> : JSX.Element
>label : any
>for : string
>class : string
<MyComp class="" />;
><MyComp class="" /> : JSX.Element
>MyComp : typeof MyComp
>class : string
<MyComp2 class="" />;
><MyComp2 class="" /> : JSX.Element
>MyComp2 : (props: { className?: string; htmlFor?: string; }) => any
>class : string
<MyComp for="" />;
><MyComp for="" /> : JSX.Element
>MyComp : typeof MyComp
>for : string
<MyComp2 for="" />;
><MyComp2 for="" /> : JSX.Element
>MyComp2 : (props: { className?: string; htmlFor?: string; }) => any
>for : string

View File

@@ -1,5 +1,5 @@
tests/cases/conformance/jsx/file.tsx(11,38): 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'.
Property 'Property1' does not exist on type 'IntrinsicAttributes & AnotherComponentProps'. Did you mean 'property1'?
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
@@ -16,7 +16,7 @@ tests/cases/conformance/jsx/file.tsx(11,38): error TS2322: Type '{ Property1: tr
<AnotherComponent {...props} Property1/>
~~~~~~~~~
!!! 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'.
!!! error TS2322: Property 'Property1' does not exist on type 'IntrinsicAttributes & AnotherComponentProps'. Did you mean 'property1'?
);
}

View File

@@ -6,7 +6,7 @@ tests/cases/conformance/jsx/file.tsx(23,10): error TS2322: Type '{ x: number; y:
Types of property 'x' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/jsx/file.tsx(24,40): 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; }'.
Property 'X' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Poisoned> & PoisonedProp & { children?: ReactNode; }'. Did you mean 'x'?
==== tests/cases/conformance/jsx/file.tsx (6 errors) ====
@@ -50,4 +50,4 @@ tests/cases/conformance/jsx/file.tsx(24,40): error TS2322: Type '{ X: string; x:
let w1 = <Poisoned {...{x: 5, y: "2"}} X="hi" />;
~
!!! 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; }'.
!!! error TS2322: Property 'X' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Poisoned> & PoisonedProp & { children?: ReactNode; }'. Did you mean 'x'?

View File

@@ -1,5 +1,5 @@
tests/cases/conformance/jsx/file.tsx(19,16): error TS2322: Type '{ naaame: string; }' is not assignable to type 'IntrinsicAttributes & { name: string; }'.
Property 'naaame' does not exist on type 'IntrinsicAttributes & { name: string; }'.
Property 'naaame' does not exist on type 'IntrinsicAttributes & { name: string; }'. Did you mean 'name'?
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,15): error TS2322: Type '{ naaaaaaame: string; }' is not assignable to type 'IntrinsicAttributes & { name?: string; }'.
Property 'naaaaaaame' does not exist on type 'IntrinsicAttributes & { name?: string; }'.
@@ -34,7 +34,7 @@ tests/cases/conformance/jsx/file.tsx(45,11): error TS2559: Type '{ prop1: boolea
let b = <Greet naaame='world' />;
~~~~~~
!!! 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; }'.
!!! error TS2322: Property 'naaame' does not exist on type 'IntrinsicAttributes & { name: string; }'. Did you mean 'name'?
// OK
let c = <Meet />;

View File

@@ -0,0 +1,16 @@
// @jsx: react
/// <reference path="/.lib/react16.d.ts" />
import * as React from "react";
function MyComp2(props: { className?: string, htmlFor?: string }) {
return null!;
}
class MyComp extends React.Component<{ className?: string, htmlFor?: string }> { }
<a class="" />;
<a for="" />; // should have no fix
<label for="" />;
<label for="" class="" />;
<MyComp class="" />;
<MyComp2 class="" />;
<MyComp for="" />;
<MyComp2 for="" />;