Skip to content

Commit b5b8697

Browse files
committed
bundle exec rails webpacker:install:typescript
1 parent cb7037b commit b5b8697

File tree

6 files changed

+89
-3
lines changed

6 files changed

+89
-3
lines changed
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Run this example by adding <%= javascript_pack_tag 'hello_typescript' %> to the head of your layout file,
2+
// like app/views/layouts/application.html.erb.
3+
4+
console.log('Hello world from typescript');

babel.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ module.exports = function(api) {
4343
development: isDevelopmentEnv || isTestEnv,
4444
useBuiltIns: true
4545
}
46-
]
46+
],
47+
['@babel/preset-typescript', { 'allExtensions': true, 'isTSX': true }]
4748
].filter(Boolean),
4849
plugins: [
4950
'babel-plugin-macros',

config/webpacker.yml

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ default: &default
3333
- .woff2
3434

3535
extensions:
36+
- .tsx
37+
- .ts
3638
- .jsx
3739
- .mjs
3840
- .js

package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{
22
"dependencies": {
33
"@babel/preset-react": "^7.10.4",
4+
"@babel/preset-typescript": "^7.10.4",
45
"@rails/webpacker": "5.1.1",
6+
"@types/react": "^16.9.44",
7+
"@types/react-dom": "^16.9.8",
58
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
69
"prop-types": "^15.7.2",
710
"react": "^16.13.1",
811
"react-dom": "^16.13.1",
9-
"react-on-rails": "12.0.1"
12+
"react-on-rails": "12.0.1",
13+
"typescript": "^3.9.7"
1014
},
1115
"devDependencies": {
1216
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.1",

tsconfig.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"compilerOptions": {
3+
"declaration": false,
4+
"emitDecoratorMetadata": true,
5+
"experimentalDecorators": true,
6+
"lib": ["es6", "dom"],
7+
"module": "es6",
8+
"moduleResolution": "node",
9+
"sourceMap": true,
10+
"target": "es5",
11+
"jsx": "react",
12+
"noEmit": true
13+
},
14+
"exclude": [
15+
"**/*.spec.ts",
16+
"node_modules",
17+
"vendor",
18+
"public"
19+
],
20+
"compileOnSave": false
21+
}

yarn.lock

+55-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
levenary "^1.1.1"
9393
semver "^5.5.0"
9494

95-
"@babel/helper-create-class-features-plugin@^7.10.4":
95+
"@babel/helper-create-class-features-plugin@^7.10.4", "@babel/helper-create-class-features-plugin@^7.10.5":
9696
version "7.10.5"
9797
resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.10.5.tgz#9f61446ba80e8240b0a5c85c6fdac8459d6f259d"
9898
integrity sha512-0nkdeijB7VlZoLT3r/mY3bUkw3T8WG/hNw+FATs/6+pG2039IJWjTYL0VTISqsNHMUTEnwbVnc89WIJX9Qed0A==
@@ -478,6 +478,13 @@
478478
dependencies:
479479
"@babel/helper-plugin-utils" "^7.10.4"
480480

481+
"@babel/plugin-syntax-typescript@^7.10.4":
482+
version "7.10.4"
483+
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.10.4.tgz#2f55e770d3501e83af217d782cb7517d7bb34d25"
484+
integrity sha512-oSAEz1YkBCAKr5Yiq8/BNtvSAPwkp/IyUnwZogd8p+F0RuYQQrLeRUzIQhueQTTBy/F+a40uS7OFKxnkRvmvFQ==
485+
dependencies:
486+
"@babel/helper-plugin-utils" "^7.10.4"
487+
481488
"@babel/plugin-transform-arrow-functions@^7.10.4":
482489
version "7.10.4"
483490
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.10.4.tgz#e22960d77e697c74f41c501d44d73dbf8a6a64cd"
@@ -774,6 +781,15 @@
774781
dependencies:
775782
"@babel/helper-plugin-utils" "^7.10.4"
776783

784+
"@babel/plugin-transform-typescript@^7.10.4":
785+
version "7.11.0"
786+
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.11.0.tgz#2b4879676af37342ebb278216dd090ac67f13abb"
787+
integrity sha512-edJsNzTtvb3MaXQwj8403B7mZoGu9ElDJQZOKjGUnvilquxBA3IQoEIOvkX/1O8xfAsnHS/oQhe2w/IXrr+w0w==
788+
dependencies:
789+
"@babel/helper-create-class-features-plugin" "^7.10.5"
790+
"@babel/helper-plugin-utils" "^7.10.4"
791+
"@babel/plugin-syntax-typescript" "^7.10.4"
792+
777793
"@babel/plugin-transform-unicode-escapes@^7.10.4":
778794
version "7.10.4"
779795
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.10.4.tgz#feae523391c7651ddac115dae0a9d06857892007"
@@ -887,6 +903,14 @@
887903
"@babel/plugin-transform-react-jsx-source" "^7.10.4"
888904
"@babel/plugin-transform-react-pure-annotations" "^7.10.4"
889905

906+
"@babel/preset-typescript@^7.10.4":
907+
version "7.10.4"
908+
resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.10.4.tgz#7d5d052e52a682480d6e2cc5aa31be61c8c25e36"
909+
integrity sha512-SdYnvGPv+bLlwkF2VkJnaX/ni1sMNetcGI1+nThF1gyv6Ph8Qucc4ZZAjM5yZcE/AKRXIOTZz7eSRDWOEjPyRQ==
910+
dependencies:
911+
"@babel/helper-plugin-utils" "^7.10.4"
912+
"@babel/plugin-transform-typescript" "^7.10.4"
913+
890914
"@babel/runtime-corejs3@^7.9.6":
891915
version "7.11.0"
892916
resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.11.0.tgz#db54a2251206f0f8579b41918acb14488b8dd2c0"
@@ -1024,11 +1048,31 @@
10241048
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
10251049
integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==
10261050

1051+
"@types/prop-types@*":
1052+
version "15.7.3"
1053+
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
1054+
integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==
1055+
10271056
"@types/q@^1.5.1":
10281057
version "1.5.4"
10291058
resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.4.tgz#15925414e0ad2cd765bfef58842f7e26a7accb24"
10301059
integrity sha512-1HcDas8SEj4z1Wc696tH56G8OlRaH/sqZOynNNB+HF0WOeXPaxTtbYzJY2oEfiUxjSKjhCKr+MvR7dCHcEelug==
10311060

1061+
"@types/react-dom@^16.9.8":
1062+
version "16.9.8"
1063+
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.8.tgz#fe4c1e11dfc67155733dfa6aa65108b4971cb423"
1064+
integrity sha512-ykkPQ+5nFknnlU6lDd947WbQ6TE3NNzbQAkInC2EKY1qeYdTKp7onFusmYZb+ityzx2YviqT6BXSu+LyWWJwcA==
1065+
dependencies:
1066+
"@types/react" "*"
1067+
1068+
"@types/react@*", "@types/react@^16.9.44":
1069+
version "16.9.44"
1070+
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.44.tgz#da84b179c031aef67dc92c33bd3401f1da2fa3bc"
1071+
integrity sha512-BtLoJrXdW8DVZauKP+bY4Kmiq7ubcJq+H/aCpRfvPF7RAT3RwR73Sg8szdc2YasbAlWBDrQ6Q+AFM0KwtQY+WQ==
1072+
dependencies:
1073+
"@types/prop-types" "*"
1074+
csstype "^3.0.2"
1075+
10321076
"@webassemblyjs/ast@1.9.0":
10331077
version "1.9.0"
10341078
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.0.tgz#bd850604b4042459a5a41cd7d338cbed695ed964"
@@ -2474,6 +2518,11 @@ csso@^4.0.2:
24742518
dependencies:
24752519
css-tree "1.0.0-alpha.39"
24762520

2521+
csstype@^3.0.2:
2522+
version "3.0.2"
2523+
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.2.tgz#ee5ff8f208c8cd613b389f7b222c9801ca62b3f7"
2524+
integrity sha512-ofovWglpqoqbfLNOTBNZLSbMuGrblAf1efvvArGKOZMBrIoJeu5UsAipQolkijtyQx5MtAzT/J9IHj/CEY1mJw==
2525+
24772526
currently-unhandled@^0.4.1:
24782527
version "0.4.1"
24792528
resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea"
@@ -7265,6 +7314,11 @@ typedarray@^0.0.6:
72657314
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
72667315
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
72677316

7317+
typescript@^3.9.7:
7318+
version "3.9.7"
7319+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa"
7320+
integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==
7321+
72687322
unicode-canonical-property-names-ecmascript@^1.0.4:
72697323
version "1.0.4"
72707324
resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz#2619800c4c825800efdd8343af7dd9933cbe2818"

0 commit comments

Comments
 (0)