Skip to content

Commit 4d0de1c

Browse files
authored
[react] Backport recent changes to TS 5.0 fork (DefinitelyTyped#74452)
1 parent 7e7c5ca commit 4d0de1c

File tree

6 files changed

+17
-11
lines changed

6 files changed

+17
-11
lines changed

types/react/test/hooks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import * as React from "react";
22

33
const { useSyncExternalStore } = React;
44

types/react/test/managedAttributes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import * as React from "react";
22

33
interface Props {
44
bool?: boolean;

types/react/ts5.0/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3598,6 +3598,9 @@ declare namespace React {
35983598
method?: string | undefined;
35993599
min?: number | string | undefined;
36003600
name?: string | undefined;
3601+
nonce?: string | undefined;
3602+
part?: string | undefined;
3603+
slot?: string | undefined;
36013604
style?: CSSProperties | undefined;
36023605
target?: string | undefined;
36033606
type?: string | undefined;

types/react/ts5.0/test/elementAttributes.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const testCases = [
2929
<span lang="art-x-tokipona" />,
3030
<input placeholder="placeholder" />,
3131
<span slot="my-text" />,
32+
<svg slot="my-svg" />,
3233
<span spellCheck />,
3334
<span tabIndex={0} />,
3435
<span title="title" />,
@@ -101,6 +102,7 @@ const testCases = [
101102
open
102103
/>,
103104
<link nonce="8IBTHwOdqNKAWeKl7plt8g==" />,
105+
<svg nonce="8IBTHwOdqNKAWeKl7plt8g==" />,
104106
<center></center>,
105107
// Float
106108
<>
@@ -171,6 +173,7 @@ const testCases = [
171173
<>
172174
<template>
173175
<div part="base" />
176+
<svg part="svg" />
174177
<custom-element exportparts="nested" />
175178
</template>
176179
</>,

types/react/ts5.0/test/index.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,16 @@ class ModernComponent extends React.Component<Props, State, Snapshot> implements
135135
static propTypes = {};
136136

137137
static contextType = SomeContext;
138-
context: Context;
138+
declare context: Context;
139139

140140
constructor(props: Props, context: Context) {
141141
super(props, context);
142+
this.state = {
143+
inputValue: this.context.someValue,
144+
seconds: this.props.foo,
145+
};
142146
}
143147

144-
state = {
145-
inputValue: this.context.someValue,
146-
seconds: this.props.foo,
147-
};
148-
149148
reset() {
150149
this._myComponent.reset();
151150
this.setState({
@@ -154,8 +153,8 @@ class ModernComponent extends React.Component<Props, State, Snapshot> implements
154153
});
155154
}
156155

157-
private readonly _myComponent: MyComponent;
158-
private _input: HTMLInputElement | null;
156+
private readonly _myComponent!: MyComponent;
157+
private _input: HTMLInputElement | null = null;
159158

160159
render() {
161160
return React.createElement(

types/react/ts5.0/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"types": [],
2626
"noEmit": true,
2727
"forceConsistentCasingInFileNames": true,
28-
"jsx": "preserve"
28+
"jsx": "preserve",
29+
"esModuleInterop": true
2930
}
3031
}

0 commit comments

Comments
 (0)