質問編集履歴
9
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -28,7 +28,7 @@
|
|
28
28
|
```ここに言語を入力
|
29
29
|
②
|
30
30
|
Type '{text: string; isCheck: boolean; }' is not assignable to type 'Item[]'.
|
31
|
-
Object literal may only specify known properties, and '
|
31
|
+
Object literal may only specify known properties, and 'text' does not exist in type 'Item[]'.
|
32
32
|
|
33
33
|
```
|
34
34
|
|
8
編集
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
setState({ ...state, ...{Item: newNames}});が①のエラーになったので
|
2
2
|
const newNames:Item = {
|
3
|
-
text:
|
3
|
+
text:t,
|
4
4
|
isCheck: false,
|
5
5
|
};
|
6
6
|
のNamesに[]をつけて
|
7
7
|
const newNames:Item[] = {
|
8
|
-
text:
|
8
|
+
text:t,
|
9
9
|
isCheck: false,
|
10
10
|
};
|
11
11
|
に直したらsetState({ ...state, ...{Item: newNames}});のエラーは消えたのですが下記(②)エラーが出てしまいました。
|
7
編集
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
setState({ ...state, ...{Item: newNames}});が①のエラーになったので
|
2
2
|
const newNames:Item = {
|
3
|
-
|
3
|
+
text: string,
|
4
4
|
isCheck: false,
|
5
5
|
};
|
6
6
|
のNamesに[]をつけて
|
7
7
|
const newNames:Item[] = {
|
8
|
-
|
8
|
+
text: string,
|
9
9
|
isCheck: false,
|
10
10
|
};
|
11
11
|
に直したらsetState({ ...state, ...{Item: newNames}});のエラーは消えたのですが下記(②)エラーが出てしまいました。
|
12
12
|
|
13
13
|
const newNames:Item[] = {
|
14
|
-
|
14
|
+
text: string,
|
15
15
|
isCheck: false,
|
16
16
|
};のname:nameが②のエラーになりました。
|
17
17
|
解決方法がわからず困っています。どうしたらいいでしょうか?
|
@@ -49,9 +49,9 @@
|
|
49
49
|
names: [],
|
50
50
|
});
|
51
51
|
|
52
|
-
const onSubmit = (
|
52
|
+
const onSubmit = (t: string) => {
|
53
53
|
const newNames: Item = {
|
54
|
-
|
54
|
+
text:t,
|
55
55
|
isCheck: false,
|
56
56
|
};
|
57
57
|
|
6
編集
title
CHANGED
File without changes
|
body
CHANGED
@@ -39,8 +39,8 @@
|
|
39
39
|
}
|
40
40
|
|
41
41
|
interface NState {
|
42
|
-
name:
|
42
|
+
name: string;
|
43
|
-
names:[];
|
43
|
+
names:Item[];
|
44
44
|
}
|
45
45
|
|
46
46
|
const Index:FC<Props> = () => {
|
5
編集
title
CHANGED
File without changes
|
body
CHANGED
@@ -39,8 +39,8 @@
|
|
39
39
|
}
|
40
40
|
|
41
41
|
interface NState {
|
42
|
-
name:
|
42
|
+
name: '';
|
43
|
-
names:
|
43
|
+
names:[];
|
44
44
|
}
|
45
45
|
|
46
46
|
const Index:FC<Props> = () => {
|
4
編集
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,59 +1,59 @@
|
|
1
|
-
setState({ ...state, ...{
|
1
|
+
setState({ ...state, ...{Item: newNames}});が①のエラーになったので
|
2
|
-
const newNames:
|
2
|
+
const newNames:Item = {
|
3
3
|
name: name,
|
4
4
|
isCheck: false,
|
5
5
|
};
|
6
6
|
のNamesに[]をつけて
|
7
|
-
const newNames:
|
7
|
+
const newNames:Item[] = {
|
8
8
|
name: name,
|
9
9
|
isCheck: false,
|
10
10
|
};
|
11
|
-
に直したらsetState({ ...state, ...{
|
11
|
+
に直したらsetState({ ...state, ...{Item: newNames}});のエラーは消えたのですが下記(②)エラーが出てしまいました。
|
12
12
|
|
13
|
-
const newNames:
|
13
|
+
const newNames:Item[] = {
|
14
14
|
name: name,
|
15
15
|
isCheck: false,
|
16
16
|
};のname:nameが②のエラーになりました。
|
17
17
|
解決方法がわからず困っています。どうしたらいいでしょうか?
|
18
18
|
```
|
19
19
|
①
|
20
|
-
Argument of type '{ names:
|
20
|
+
Argument of type '{ names:Item; name: string; }' is not assignable to parameter of type 'SetStateAction<State>'.
|
21
|
-
Type '{ names:
|
21
|
+
Type '{ names:Item; name: string;}' is not assignable to type 'State'.
|
22
22
|
Types of property 'names' are incompatible.
|
23
|
-
Type '
|
23
|
+
Type 'Item' is missing the following properties from type 'Item[]': length, pop, push, concat,
|
24
24
|
|
25
25
|
```
|
26
26
|
|
27
27
|
|
28
28
|
```ここに言語を入力
|
29
29
|
②
|
30
|
-
Type '{
|
30
|
+
Type '{text: string; isCheck: boolean; }' is not assignable to type 'Item[]'.
|
31
|
-
Object literal may only specify known properties, and 'name' does not exist in type '
|
31
|
+
Object literal may only specify known properties, and 'name' does not exist in type 'Item[]'.
|
32
32
|
|
33
33
|
```
|
34
34
|
|
35
35
|
```ここに言語を入力
|
36
|
-
const type
|
36
|
+
const type Item= {
|
37
|
-
|
37
|
+
text: string
|
38
38
|
isCheck: boolean
|
39
39
|
}
|
40
40
|
|
41
|
-
interface
|
41
|
+
interface NState {
|
42
42
|
name: string;
|
43
|
-
names:
|
43
|
+
names:Item[];
|
44
44
|
}
|
45
45
|
|
46
46
|
const Index:FC<Props> = () => {
|
47
|
-
const [state, setState] = useState<
|
47
|
+
const [state, setState] = useState<NState>({
|
48
48
|
name: '',
|
49
49
|
names: [],
|
50
50
|
});
|
51
51
|
|
52
|
-
const onSubmit = (
|
52
|
+
const onSubmit = (text: string) => {
|
53
|
-
const newNames:
|
53
|
+
const newNames: Item = {
|
54
|
-
name:
|
54
|
+
name:text,
|
55
55
|
isCheck: false,
|
56
56
|
};
|
57
57
|
|
58
|
-
setState({ ...state, ...{
|
58
|
+
setState({ ...state, ...{Item: newNames}});
|
59
59
|
```
|
3
編集
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
React Typescript
|
1
|
+
React Typescript オブジェクトリテラルエラー解決できない
|
body
CHANGED
File without changes
|
2
編集
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,28 +2,29 @@
|
|
2
2
|
const newNames: Names = {
|
3
3
|
name: name,
|
4
4
|
isCheck: false,
|
5
|
+
};
|
5
|
-
|
6
|
+
のNamesに[]をつけて
|
6
|
-
```
|
7
|
-
①
|
8
|
-
Argument of type '{ names: names; name: string; }' is not assignable to parameter of type 'SetStateAction<State>'.
|
9
|
-
Type '{ names: names; ipAddress: string;}' is not assignable to type 'State'.
|
10
|
-
Types of property 'names' are incompatible.
|
11
|
-
Type 'names' is missing the following properties from type 'names[]': length, pop, push, concat,
|
12
|
-
|
13
|
-
```
|
14
|
-
|
15
7
|
const newNames: Names[] = {
|
16
8
|
name: name,
|
17
9
|
isCheck: false,
|
10
|
+
};
|
18
|
-
|
11
|
+
に直したらsetState({ ...state, ...{names: newNames}});のエラーは消えたのですが下記(②)エラーが出てしまいました。
|
19
12
|
|
20
13
|
const newNames: Names[] = {
|
21
14
|
name: name,
|
22
15
|
isCheck: false,
|
23
16
|
};のname:nameが②のエラーになりました。
|
24
17
|
解決方法がわからず困っています。どうしたらいいでしょうか?
|
18
|
+
```
|
19
|
+
①
|
20
|
+
Argument of type '{ names: names; name: string; }' is not assignable to parameter of type 'SetStateAction<State>'.
|
21
|
+
Type '{ names: names; ipAddress: string;}' is not assignable to type 'State'.
|
22
|
+
Types of property 'names' are incompatible.
|
23
|
+
Type 'names' is missing the following properties from type 'names[]': length, pop, push, concat,
|
25
24
|
|
25
|
+
```
|
26
26
|
|
27
|
+
|
27
28
|
```ここに言語を入力
|
28
29
|
②
|
29
30
|
Type '{ name: string; isCheck: boolean; }' is not assignable to type 'names[]'.
|
1
編集
title
CHANGED
File without changes
|
body
CHANGED
@@ -3,11 +3,19 @@
|
|
3
3
|
name: name,
|
4
4
|
isCheck: false,
|
5
5
|
};のNamesに[]をつけて
|
6
|
+
```
|
7
|
+
①
|
8
|
+
Argument of type '{ names: names; name: string; }' is not assignable to parameter of type 'SetStateAction<State>'.
|
9
|
+
Type '{ names: names; ipAddress: string;}' is not assignable to type 'State'.
|
10
|
+
Types of property 'names' are incompatible.
|
11
|
+
Type 'names' is missing the following properties from type 'names[]': length, pop, push, concat,
|
6
12
|
|
13
|
+
```
|
14
|
+
|
7
15
|
const newNames: Names[] = {
|
8
16
|
name: name,
|
9
17
|
isCheck: false,
|
10
|
-
};にしたらsetState({ ...state, ...{names: newNames}});のエラーは消えたのですが
|
18
|
+
};に直したらsetState({ ...state, ...{names: newNames}});のエラーは消えたのですが下記(②)エラーが出てしまいました。
|
11
19
|
|
12
20
|
const newNames: Names[] = {
|
13
21
|
name: name,
|
@@ -15,16 +23,7 @@
|
|
15
23
|
};のname:nameが②のエラーになりました。
|
16
24
|
解決方法がわからず困っています。どうしたらいいでしょうか?
|
17
25
|
|
18
|
-
```ここに言語を入力
|
19
|
-
①
|
20
|
-
Argument of type '{ names: names; name: string; }' is not assignable to parameter of type 'SetStateAction<State>'.
|
21
|
-
Type '{ names: names; ipAddress: string;}' is not assignable to type 'State'.
|
22
|
-
Types of property 'names' are incompatible.
|
23
|
-
Type 'names' is missing the following properties from type 'names[]': length, pop, push, concat,
|
24
26
|
|
25
|
-
```
|
26
|
-
|
27
|
-
|
28
27
|
```ここに言語を入力
|
29
28
|
②
|
30
29
|
Type '{ name: string; isCheck: boolean; }' is not assignable to type 'names[]'.
|