-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4106 from RyanCavanaugh/allowTsxStringIndexers
Implements #4105 - a string indexer in 'props' disables errors due to surplus attributes
- Loading branch information
Showing
4 changed files
with
129 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tests/baselines/reference/tsxAttributeResolution10.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
tests/cases/conformance/jsx/file.tsx(11,14): error TS2322: Type 'string' is not assignable to type 'boolean'. | ||
|
||
|
||
==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== | ||
|
||
declare module JSX { | ||
interface Element { } | ||
interface IntrinsicElements { | ||
} | ||
interface ElementAttributesProperty { | ||
props; | ||
} | ||
} | ||
|
||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== | ||
export class MyComponent { | ||
render() { | ||
} | ||
|
||
props: { | ||
[s: string]: boolean; | ||
} | ||
} | ||
|
||
// Should be an error | ||
<MyComponent bar='world' />; | ||
~~~~~~~~~~~ | ||
!!! error TS2322: Type 'string' is not assignable to type 'boolean'. | ||
|
||
// Should be OK | ||
<MyComponent bar={true} />; | ||
|
||
// Should be ok | ||
<MyComponent data-bar='hello' />; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//// [tests/cases/conformance/jsx/tsxAttributeResolution10.tsx] //// | ||
|
||
//// [react.d.ts] | ||
|
||
declare module JSX { | ||
interface Element { } | ||
interface IntrinsicElements { | ||
} | ||
interface ElementAttributesProperty { | ||
props; | ||
} | ||
} | ||
|
||
//// [file.tsx] | ||
export class MyComponent { | ||
render() { | ||
} | ||
|
||
props: { | ||
[s: string]: boolean; | ||
} | ||
} | ||
|
||
// Should be an error | ||
<MyComponent bar='world' />; | ||
|
||
// Should be OK | ||
<MyComponent bar={true} />; | ||
|
||
// Should be ok | ||
<MyComponent data-bar='hello' />; | ||
|
||
|
||
//// [file.jsx] | ||
define(["require", "exports"], function (require, exports) { | ||
var MyComponent = (function () { | ||
function MyComponent() { | ||
} | ||
MyComponent.prototype.render = function () { | ||
}; | ||
return MyComponent; | ||
})(); | ||
exports.MyComponent = MyComponent; | ||
// Should be an error | ||
<MyComponent bar='world'/>; | ||
// Should be OK | ||
<MyComponent bar={true}/>; | ||
// Should be ok | ||
<MyComponent data-bar='hello'/>; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//@jsx: preserve | ||
//@module: amd | ||
|
||
//@filename: react.d.ts | ||
declare module JSX { | ||
interface Element { } | ||
interface IntrinsicElements { | ||
} | ||
interface ElementAttributesProperty { | ||
props; | ||
} | ||
} | ||
|
||
//@filename: file.tsx | ||
export class MyComponent { | ||
render() { | ||
} | ||
|
||
props: { | ||
[s: string]: boolean; | ||
} | ||
} | ||
|
||
// Should be an error | ||
<MyComponent bar='world' />; | ||
|
||
// Should be OK | ||
<MyComponent bar={true} />; | ||
|
||
// Should be ok | ||
<MyComponent data-bar='hello' />; |