Add Typescript support

This commit is contained in:
Andreas Nedbal 2020-12-25 21:41:54 +01:00 committed by Andreas Nedbal
parent 1221a82557
commit 51678e5e34
7 changed files with 66 additions and 2 deletions

View File

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

View File

@ -12,6 +12,7 @@
%title= yield(:title)
= stylesheet_link_tag 'application', media: 'all', data: { 'turbolinks-track': true }
= javascript_pack_tag 'legacy/application', data: { 'turbolinks-track': true }
= javascript_pack_tag 'hello_typescript'
= stylesheet_pack_tag 'legacy/application', data: { 'turbolinks-track': true }
- if user_signed_in? && current_user.mod?
= javascript_pack_tag 'legacy/moderation/index', data: { 'turbolinks-track': true }

View File

@ -34,7 +34,8 @@ module.exports = function(api) {
modules: false,
exclude: ['transform-typeof-symbol']
}
]
],
['@babel/preset-typescript', { 'allExtensions': true, 'isTSX': true }]
].filter(Boolean),
plugins: [
'babel-plugin-macros',

View File

@ -33,6 +33,8 @@ default: &default
- .woff2
extensions:
- .tsx
- .ts
- .coffee
- .mjs
- .js

View File

@ -1,5 +1,6 @@
{
"dependencies": {
"@babel/preset-typescript": "^7.12.7",
"bootstrap": "^4.5.3",
"cheet.js": "^0.3.3",
"core-js": "^3.8.1",
@ -18,7 +19,8 @@
"sweetalert": "1.1.3",
"tempusdominus-bootstrap-4": "5.1.2",
"tinycolor2": "^1.4.2",
"turbolinks": "turbolinks/turbolinks-classic"
"turbolinks": "turbolinks/turbolinks-classic",
"typescript": "^4.1.3"
},
"devDependencies": {
"@babel/core": "^7.12.10",

24
tsconfig.json Normal file
View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"module": "es6",
"moduleResolution": "node",
"baseUrl": ".",
"paths": {
"*": ["node_modules/*", "app/javascript/*"]
},
"sourceMap": true,
"target": "es5",
"noEmit": true
},
"exclude": [
"**/*.spec.ts",
"node_modules",
"vendor",
"public"
],
"compileOnSave": false
}

View File

@ -442,6 +442,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.10.4"
"@babel/plugin-syntax-typescript@^7.12.1":
version "7.12.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.12.1.tgz#460ba9d77077653803c3dd2e673f76d66b4029e5"
integrity sha512-UZNEcCY+4Dp9yYRCAHrHDU+9ZXLYaY9MgBXSRLkB9WjYFRR6quJBumfVrEkUxrePPBwFcpWfNKXqVRQQtm7mMA==
dependencies:
"@babel/helper-plugin-utils" "^7.10.4"
"@babel/plugin-transform-arrow-functions@^7.12.1":
version "7.12.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.12.1.tgz#8083ffc86ac8e777fbe24b5967c4b2521f3cb2b3"
@ -685,6 +692,15 @@
dependencies:
"@babel/helper-plugin-utils" "^7.10.4"
"@babel/plugin-transform-typescript@^7.12.1":
version "7.12.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.12.1.tgz#d92cc0af504d510e26a754a7dbc2e5c8cd9c7ab4"
integrity sha512-VrsBByqAIntM+EYMqSm59SiMEf7qkmI9dqMt6RbD/wlwueWmYcI0FFK5Fj47pP6DRZm+3teXjosKlwcZJ5lIMw==
dependencies:
"@babel/helper-create-class-features-plugin" "^7.12.1"
"@babel/helper-plugin-utils" "^7.10.4"
"@babel/plugin-syntax-typescript" "^7.12.1"
"@babel/plugin-transform-unicode-escapes@^7.12.1":
version "7.12.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.12.1.tgz#5232b9f81ccb07070b7c3c36c67a1b78f1845709"
@ -783,6 +799,15 @@
"@babel/types" "^7.4.4"
esutils "^2.0.2"
"@babel/preset-typescript@^7.12.7":
version "7.12.7"
resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.12.7.tgz#fc7df8199d6aae747896f1e6c61fc872056632a3"
integrity sha512-nOoIqIqBmHBSEgBXWR4Dv/XBehtIFcw9PqZw6rFYuKrzsZmOQm3PR5siLBnKZFEsDb03IegG8nSjU/iXXXYRmw==
dependencies:
"@babel/helper-plugin-utils" "^7.10.4"
"@babel/helper-validator-option" "^7.12.1"
"@babel/plugin-transform-typescript" "^7.12.1"
"@babel/runtime@^7.11.2", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4":
version "7.12.5"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.5.tgz#410e7e487441e1b360c29be715d870d9b985882e"
@ -7249,6 +7274,11 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
typescript@^4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.3.tgz#519d582bd94cba0cf8934c7d8e8467e473f53bb7"
integrity sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==
unicode-canonical-property-names-ecmascript@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz#2619800c4c825800efdd8343af7dd9933cbe2818"