回答編集履歴
8
あ
test
CHANGED
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
+
クラスフィールドシンタックスというものです。
|
6
|
+
|
7
|
+
|
8
|
+
|
5
|
-
|
9
|
+
どういった開発環境でコピペして、その結果、「=が期待されていない演算子とvscodeに指摘されてしまいました。」となったのかが具体的に記されていないので、何とも言えませんが、おそらく、それに対応したbabelのプラグインを追加する必要があるかと思います。
|
6
10
|
|
7
11
|
|
8
12
|
|
@@ -12,14 +16,12 @@
|
|
12
16
|
|
13
17
|
|
14
18
|
|
15
|
-
[demo](https://babeljs.io/repl/#?babili=false&evaluate=false&lineWrap=true&presets=es2015%2Cstage-0%2Creact&code=%20%20class%20Bork%20%7B%0A%20%20%20%20%2F%2FProperty%20initializer%20syntax%0A%20%20%20%20instanceProperty%20%3D%20%22bork%22%3B%0A%20%20%20%20boundFunction%20%3D%20()%20%3D%3E%20%7B%0A%20%20%20%20%20%20return%20this.instanceProperty%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20%2F%2FStatic%20class%20properties%0A%20%20%20%20static%20staticProperty%20%3D%20%22babelIsCool%22%3B%0A%20%20%20%20static%20staticFunction%20%3D%20function()%20%7B%0A%20%20%20%20%20%20return%20Bork.staticProperty%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%0A%20%20let%20myBork%20%3D%20new%20Bork%3B%0A%0A%20%20%2F%2FProperty%20initializers%20are%20not%20on%20the%20prototype.%0A%20%20console.log(myBork.__proto__.boundFunction)%3B%20%2F%2F%20%3E%20undefined%0A%0A%20%20%2F%2FBound%20functions%20are%20bound%20to%20the%20class%20instance.%0A%20%20console.log(myBork.boundFunction.call(undefined))%3B%20%2F%2F%20%3E%20%22bork%22%0A%0A%20%20%2F%2FStatic%20function%20exists%20on%20the%20class.%0A%20%20console.log(Bork.staticFunction())%3B%20%2F%2F%20%3E%20%22babelIsCool%22%0A)
|
16
19
|
|
17
20
|
|
18
21
|
|
19
|
-
どういった開発環境でコピペして、その結果、「=が期待されていない演算子とvscodeに指摘されてしまいました。」となったのかが具体的に記されていないので、これ以上のことは言えませんが。
|
20
22
|
|
21
23
|
|
22
24
|
|
23
25
|
**参考**
|
24
26
|
|
25
|
-
https://babeljs.io/
|
27
|
+
[https://babeljs.io/](https://babeljs.io/)
|
7
a
test
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
[リンク内容](https://babeljs.io/
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
[https://github.com/tc39/proposal-class-fields/blob/master/README.md](https://github.com/tc39/proposal-class-fields/blob/master/README.md)
|
6
2
|
|
7
3
|
|
8
4
|
|
@@ -14,7 +10,9 @@
|
|
14
10
|
|
15
11
|
](https://babeljs.io/docs/plugins/transform-class-properties/)
|
16
12
|
|
17
|
-
|
13
|
+
|
14
|
+
|
15
|
+
[demo](https://babeljs.io/repl/#?babili=false&evaluate=false&lineWrap=true&presets=es2015%2Cstage-0%2Creact&code=%20%20class%20Bork%20%7B%0A%20%20%20%20%2F%2FProperty%20initializer%20syntax%0A%20%20%20%20instanceProperty%20%3D%20%22bork%22%3B%0A%20%20%20%20boundFunction%20%3D%20()%20%3D%3E%20%7B%0A%20%20%20%20%20%20return%20this.instanceProperty%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20%2F%2FStatic%20class%20properties%0A%20%20%20%20static%20staticProperty%20%3D%20%22babelIsCool%22%3B%0A%20%20%20%20static%20staticFunction%20%3D%20function()%20%7B%0A%20%20%20%20%20%20return%20Bork.staticProperty%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%0A%20%20let%20myBork%20%3D%20new%20Bork%3B%0A%0A%20%20%2F%2FProperty%20initializers%20are%20not%20on%20the%20prototype.%0A%20%20console.log(myBork.__proto__.boundFunction)%3B%20%2F%2F%20%3E%20undefined%0A%0A%20%20%2F%2FBound%20functions%20are%20bound%20to%20the%20class%20instance.%0A%20%20console.log(myBork.boundFunction.call(undefined))%3B%20%2F%2F%20%3E%20%22bork%22%0A%0A%20%20%2F%2FStatic%20function%20exists%20on%20the%20class.%0A%20%20console.log(Bork.staticFunction())%3B%20%2F%2F%20%3E%20%22babelIsCool%22%0A)
|
18
16
|
|
19
17
|
|
20
18
|
|
6
あ
test
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
+
[リンク内容](https://babeljs.io/
|
2
|
+
|
3
|
+
|
4
|
+
|
1
|
-
[https://github.com/tc39/proposal-class-fields/blob/master/README.md](https://github.com/tc39/proposal-class-fields/blob/master/README.md)
|
5
|
+
)[https://github.com/tc39/proposal-class-fields/blob/master/README.md](https://github.com/tc39/proposal-class-fields/blob/master/README.md)
|
2
6
|
|
3
7
|
|
4
8
|
|
5
https://babeljs.io/docs/plugins/transform-class-properties/
test
CHANGED
@@ -6,14 +6,18 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
https://babeljs.io/docs/plugins/transform-class-properties/
|
9
|
+
[https://babeljs.io/docs/plugins/transform-class-properties/
|
10
|
+
|
11
|
+
](https://babeljs.io/docs/plugins/transform-class-properties/)
|
12
|
+
|
13
|
+
というか、普通に[babel-preset-env](https://babeljs.io/docs/plugins/preset-env/)入れてれば、その中にクラスフィールドに対応したプラグインも含まれてると思いますけども。
|
10
14
|
|
11
15
|
|
12
16
|
|
13
|
-
|
17
|
+
どういった開発環境でコピペして、その結果、「=が期待されていない演算子とvscodeに指摘されてしまいました。」となったのかが具体的に記されていないので、これ以上のことは言えませんが。
|
14
18
|
|
15
19
|
|
16
20
|
|
17
|
-
参考
|
21
|
+
**参考**
|
18
22
|
|
19
23
|
https://babeljs.io/
|
4
https://github.com/tc39/proposal-class-fields/blob/master/README.md
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[https://
|
1
|
+
[https://github.com/tc39/proposal-class-fields/blob/master/README.md](https://github.com/tc39/proposal-class-fields/blob/master/README.md)
|
2
2
|
|
3
3
|
|
4
4
|
|
3
j
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
クラスフィールドシンタックスという
|
5
|
+
クラスフィールドシンタックスというものです。おそらく、それに対応したbabelのプラグインを追加する必要があるのかもしれません。
|
6
6
|
|
7
7
|
|
8
8
|
|
2
や
test
CHANGED
@@ -7,3 +7,13 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
https://babeljs.io/docs/plugins/transform-class-properties/
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
というか、普通にbabel-preset-env入れてれば、その中にクラスフィールドに対応したプラグインも含まれてると思いますけども。
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
参考
|
18
|
+
|
19
|
+
https://babeljs.io/
|
1
あ
test
CHANGED
@@ -2,4 +2,8 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
クラスフィールドシンタックスという書き方です。おそらく、
|
5
|
+
クラスフィールドシンタックスという書き方です。おそらく、それに対応したbabelのプラグインを追加する必要があるのかもしれません。
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
https://babeljs.io/docs/plugins/transform-class-properties/
|