forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(48556): throw an error on jsx spread attributes with an invalid t…
…ype (microsoft#48570)
- Loading branch information
1 parent
1611974
commit 9ef4563
Showing
10 changed files
with
165 additions
and
3 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
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/correctlyMarkAliasAsReferences3.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,18 @@ | ||
tests/cases/conformance/jsx/0.tsx(6,21): error TS2698: Spread types may only be created from object types. | ||
|
||
|
||
==== tests/cases/conformance/jsx/0.tsx (1 errors) ==== | ||
///<reference path="declaration.d.ts" /> | ||
import * as cx from 'classnames'; | ||
import * as React from "react"; | ||
|
||
let buttonProps; | ||
let k = <button {...buttonProps}> | ||
~~~~~~~~~~~ | ||
!!! error TS2698: Spread types may only be created from object types. | ||
<span className={cx('class1', { class2: true })} /> | ||
</button>; | ||
|
||
==== tests/cases/conformance/jsx/declaration.d.ts (0 errors) ==== | ||
declare module "classnames"; | ||
|
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
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
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
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,24 @@ | ||
tests/cases/conformance/jsx/a.tsx(9,21): error TS2698: Spread types may only be created from object types. | ||
tests/cases/conformance/jsx/a.tsx(10,21): error TS2698: Spread types may only be created from object types. | ||
tests/cases/conformance/jsx/a.tsx(11,21): error TS2698: Spread types may only be created from object types. | ||
|
||
|
||
==== tests/cases/conformance/jsx/a.tsx (3 errors) ==== | ||
namespace JSX { | ||
export interface IntrinsicElements { [key: string]: any } | ||
} | ||
|
||
const a = {} as never; | ||
const b = null; | ||
const c = undefined; | ||
|
||
const d = <div { ...a } /> | ||
~ | ||
!!! error TS2698: Spread types may only be created from object types. | ||
const e = <div { ...b } /> | ||
~ | ||
!!! error TS2698: Spread types may only be created from object types. | ||
const f = <div { ...c } /> | ||
~ | ||
!!! error TS2698: Spread types may only be created from object types. | ||
|
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,22 @@ | ||
//// [a.tsx] | ||
namespace JSX { | ||
export interface IntrinsicElements { [key: string]: any } | ||
} | ||
|
||
const a = {} as never; | ||
const b = null; | ||
const c = undefined; | ||
|
||
const d = <div { ...a } /> | ||
const e = <div { ...b } /> | ||
const f = <div { ...c } /> | ||
|
||
|
||
//// [a.jsx] | ||
"use strict"; | ||
var a = {}; | ||
var b = null; | ||
var c = undefined; | ||
var d = <div {...a}/>; | ||
var e = <div {...b}/>; | ||
var f = <div {...c}/>; |
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,34 @@ | ||
=== tests/cases/conformance/jsx/a.tsx === | ||
namespace JSX { | ||
>JSX : Symbol(JSX, Decl(a.tsx, 0, 0)) | ||
|
||
export interface IntrinsicElements { [key: string]: any } | ||
>IntrinsicElements : Symbol(IntrinsicElements, Decl(a.tsx, 0, 15)) | ||
>key : Symbol(key, Decl(a.tsx, 1, 42)) | ||
} | ||
|
||
const a = {} as never; | ||
>a : Symbol(a, Decl(a.tsx, 4, 5)) | ||
|
||
const b = null; | ||
>b : Symbol(b, Decl(a.tsx, 5, 5)) | ||
|
||
const c = undefined; | ||
>c : Symbol(c, Decl(a.tsx, 6, 5)) | ||
>undefined : Symbol(undefined) | ||
|
||
const d = <div { ...a } /> | ||
>d : Symbol(d, Decl(a.tsx, 8, 5)) | ||
>div : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 0, 15)) | ||
>a : Symbol(a, Decl(a.tsx, 4, 5)) | ||
|
||
const e = <div { ...b } /> | ||
>e : Symbol(e, Decl(a.tsx, 9, 5)) | ||
>div : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 0, 15)) | ||
>b : Symbol(b, Decl(a.tsx, 5, 5)) | ||
|
||
const f = <div { ...c } /> | ||
>f : Symbol(f, Decl(a.tsx, 10, 5)) | ||
>div : Symbol(JSX.IntrinsicElements, Decl(a.tsx, 0, 15)) | ||
>c : Symbol(c, Decl(a.tsx, 6, 5)) | ||
|
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,37 @@ | ||
=== tests/cases/conformance/jsx/a.tsx === | ||
namespace JSX { | ||
export interface IntrinsicElements { [key: string]: any } | ||
>key : string | ||
} | ||
|
||
const a = {} as never; | ||
>a : never | ||
>{} as never : never | ||
>{} : {} | ||
|
||
const b = null; | ||
>b : null | ||
>null : null | ||
|
||
const c = undefined; | ||
>c : undefined | ||
>undefined : undefined | ||
|
||
const d = <div { ...a } /> | ||
>d : any | ||
><div { ...a } /> : any | ||
>div : any | ||
>a : never | ||
|
||
const e = <div { ...b } /> | ||
>e : any | ||
><div { ...b } /> : any | ||
>div : any | ||
>b : null | ||
|
||
const f = <div { ...c } /> | ||
>f : any | ||
><div { ...c } /> : any | ||
>div : any | ||
>c : undefined | ||
|
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,14 @@ | ||
// @jsx: preserve | ||
// @strict: true | ||
// @filename: a.tsx | ||
namespace JSX { | ||
export interface IntrinsicElements { [key: string]: any } | ||
} | ||
|
||
const a = {} as never; | ||
const b = null; | ||
const c = undefined; | ||
|
||
const d = <div { ...a } /> | ||
const e = <div { ...b } /> | ||
const f = <div { ...c } /> |