mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
Fix bug #3737 (exported JSX classes props not validated)
This commit is contained in:
31
tests/baselines/reference/tsxAttributeResolution9.errors.txt
Normal file
31
tests/baselines/reference/tsxAttributeResolution9.errors.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
tests/cases/conformance/jsx/file.tsx(9,14): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/react.d.ts (0 errors) ====
|
||||
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
}
|
||||
interface ElementAttributesProperty {
|
||||
props;
|
||||
}
|
||||
}
|
||||
|
||||
interface Props {
|
||||
foo: string;
|
||||
}
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
export class MyComponent {
|
||||
render() {
|
||||
}
|
||||
|
||||
props: { foo: string; }
|
||||
}
|
||||
|
||||
<MyComponent foo="bar" />; // ok
|
||||
<MyComponent foo={0} />; // should be an error
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
|
||||
42
tests/baselines/reference/tsxAttributeResolution9.js
Normal file
42
tests/baselines/reference/tsxAttributeResolution9.js
Normal file
@@ -0,0 +1,42 @@
|
||||
//// [tests/cases/conformance/jsx/tsxAttributeResolution9.tsx] ////
|
||||
|
||||
//// [react.d.ts]
|
||||
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
}
|
||||
interface ElementAttributesProperty {
|
||||
props;
|
||||
}
|
||||
}
|
||||
|
||||
interface Props {
|
||||
foo: string;
|
||||
}
|
||||
|
||||
//// [file.tsx]
|
||||
export class MyComponent {
|
||||
render() {
|
||||
}
|
||||
|
||||
props: { foo: string; }
|
||||
}
|
||||
|
||||
<MyComponent foo="bar" />; // ok
|
||||
<MyComponent foo={0} />; // should be an error
|
||||
|
||||
|
||||
//// [file.jsx]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var MyComponent = (function () {
|
||||
function MyComponent() {
|
||||
}
|
||||
MyComponent.prototype.render = function () {
|
||||
};
|
||||
return MyComponent;
|
||||
})();
|
||||
exports.MyComponent = MyComponent;
|
||||
<MyComponent foo="bar"/>; // ok
|
||||
<MyComponent foo={0}/>; // should be an error
|
||||
});
|
||||
45
tests/baselines/reference/tsxAttributeResolution9.symbols
Normal file
45
tests/baselines/reference/tsxAttributeResolution9.symbols
Normal file
@@ -0,0 +1,45 @@
|
||||
=== tests/cases/conformance/jsx/tsxAttributeResolution9.tsx ===
|
||||
declare module JSX {
|
||||
>JSX : Symbol(JSX, Decl(tsxAttributeResolution9.tsx, 0, 0))
|
||||
|
||||
interface Element { }
|
||||
>Element : Symbol(Element, Decl(tsxAttributeResolution9.tsx, 0, 20))
|
||||
|
||||
interface IntrinsicElements {
|
||||
>IntrinsicElements : Symbol(IntrinsicElements, Decl(tsxAttributeResolution9.tsx, 1, 22))
|
||||
}
|
||||
interface ElementAttributesProperty {
|
||||
>ElementAttributesProperty : Symbol(ElementAttributesProperty, Decl(tsxAttributeResolution9.tsx, 3, 2))
|
||||
|
||||
props;
|
||||
>props : Symbol(props, Decl(tsxAttributeResolution9.tsx, 4, 38))
|
||||
}
|
||||
}
|
||||
|
||||
interface Props {
|
||||
>Props : Symbol(Props, Decl(tsxAttributeResolution9.tsx, 7, 1))
|
||||
|
||||
foo: string;
|
||||
>foo : Symbol(foo, Decl(tsxAttributeResolution9.tsx, 9, 17))
|
||||
}
|
||||
|
||||
export class MyComponent {
|
||||
>MyComponent : Symbol(MyComponent, Decl(tsxAttributeResolution9.tsx, 11, 1))
|
||||
|
||||
render() {
|
||||
>render : Symbol(render, Decl(tsxAttributeResolution9.tsx, 13, 26))
|
||||
}
|
||||
|
||||
props: { foo: string; }
|
||||
>props : Symbol(props, Decl(tsxAttributeResolution9.tsx, 15, 3))
|
||||
>foo : Symbol(foo, Decl(tsxAttributeResolution9.tsx, 17, 10))
|
||||
}
|
||||
|
||||
<MyComponent foo="bar" />; // ok
|
||||
>MyComponent : Symbol(MyComponent, Decl(tsxAttributeResolution9.tsx, 11, 1))
|
||||
>foo : Symbol(unknown)
|
||||
|
||||
<MyComponent foo={0} />; // should be an error
|
||||
>MyComponent : Symbol(MyComponent, Decl(tsxAttributeResolution9.tsx, 11, 1))
|
||||
>foo : Symbol(unknown)
|
||||
|
||||
47
tests/baselines/reference/tsxAttributeResolution9.types
Normal file
47
tests/baselines/reference/tsxAttributeResolution9.types
Normal file
@@ -0,0 +1,47 @@
|
||||
=== tests/cases/conformance/jsx/tsxAttributeResolution9.tsx ===
|
||||
declare module JSX {
|
||||
>JSX : any
|
||||
|
||||
interface Element { }
|
||||
>Element : Element
|
||||
|
||||
interface IntrinsicElements {
|
||||
>IntrinsicElements : IntrinsicElements
|
||||
}
|
||||
interface ElementAttributesProperty {
|
||||
>ElementAttributesProperty : ElementAttributesProperty
|
||||
|
||||
props;
|
||||
>props : any
|
||||
}
|
||||
}
|
||||
|
||||
interface Props {
|
||||
>Props : Props
|
||||
|
||||
foo: string;
|
||||
>foo : string
|
||||
}
|
||||
|
||||
export class MyComponent {
|
||||
>MyComponent : MyComponent
|
||||
|
||||
render() {
|
||||
>render : () => void
|
||||
}
|
||||
|
||||
props: { foo: string; }
|
||||
>props : { foo: string; }
|
||||
>foo : string
|
||||
}
|
||||
|
||||
<MyComponent foo="bar" />; // ok
|
||||
><MyComponent foo="bar" /> : any
|
||||
>MyComponent : typeof MyComponent
|
||||
>foo : any
|
||||
|
||||
<MyComponent foo={0} />; // should be an error
|
||||
><MyComponent foo={0} /> : any
|
||||
>MyComponent : typeof MyComponent
|
||||
>foo : any
|
||||
|
||||
27
tests/cases/conformance/jsx/tsxAttributeResolution9.tsx
Normal file
27
tests/cases/conformance/jsx/tsxAttributeResolution9.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
//@jsx: preserve
|
||||
//@module: amd
|
||||
|
||||
//@filename: react.d.ts
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
}
|
||||
interface ElementAttributesProperty {
|
||||
props;
|
||||
}
|
||||
}
|
||||
|
||||
interface Props {
|
||||
foo: string;
|
||||
}
|
||||
|
||||
//@filename: file.tsx
|
||||
export class MyComponent {
|
||||
render() {
|
||||
}
|
||||
|
||||
props: { foo: string; }
|
||||
}
|
||||
|
||||
<MyComponent foo="bar" />; // ok
|
||||
<MyComponent foo={0} />; // should be an error
|
||||
Reference in New Issue
Block a user