convert frontend to ts

This commit is contained in:
Raccoon 2021-07-31 11:47:20 +08:00
parent ed80cb2221
commit 2135fb0d93
No known key found for this signature in database
GPG Key ID: 06770355DC9ECD38
6 changed files with 46 additions and 6 deletions

View File

@ -7,7 +7,8 @@
"node": "6",
"uglify": true
}
}]
}],
"@babel/preset-typescript"
],
"plugins": [
"@babel/plugin-transform-runtime"

31
package-lock.json generated
View File

@ -2465,6 +2465,15 @@
"@babel/helper-plugin-utils": "^7.14.5"
}
},
"@babel/plugin-syntax-typescript": {
"version": "7.14.5",
"resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.14.5.tgz",
"integrity": "sha512-u6OXzDaIXjEstBRRoBCQ/uKQKlbuaeE5in0RvWdA4pN6AhqxTIwUsnHPU1CFZA/amYObMsuWhYfRl3Ch90HD0Q==",
"dev": true,
"requires": {
"@babel/helper-plugin-utils": "^7.14.5"
}
},
"@babel/plugin-transform-arrow-functions": {
"version": "7.14.5",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.14.5.tgz",
@ -2962,6 +2971,17 @@
"@babel/helper-plugin-utils": "^7.14.5"
}
},
"@babel/plugin-transform-typescript": {
"version": "7.14.6",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.14.6.tgz",
"integrity": "sha512-XlTdBq7Awr4FYIzqhmYY80WN0V0azF74DMPyFqVHBvf81ZUgc4X7ZOpx6O8eLDK6iM5cCQzeyJw0ynTaefixRA==",
"dev": true,
"requires": {
"@babel/helper-create-class-features-plugin": "^7.14.6",
"@babel/helper-plugin-utils": "^7.14.5",
"@babel/plugin-syntax-typescript": "^7.14.5"
}
},
"@babel/plugin-transform-unicode-escapes": {
"version": "7.14.5",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.14.5.tgz",
@ -3105,6 +3125,17 @@
"esutils": "^2.0.2"
}
},
"@babel/preset-typescript": {
"version": "7.14.5",
"resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.14.5.tgz",
"integrity": "sha512-u4zO6CdbRKbS9TypMqrlGH7sd2TAJppZwn3c/ZRLeO/wGsbddxgbPDUZVNrie3JWYLQ9vpineKlsrWFvO6Pwkw==",
"dev": true,
"requires": {
"@babel/helper-plugin-utils": "^7.14.5",
"@babel/helper-validator-option": "^7.14.5",
"@babel/plugin-transform-typescript": "^7.14.5"
}
},
"@babel/runtime": {
"version": "7.14.8",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.14.8.tgz",

View File

@ -108,6 +108,7 @@
"@babel/core": "~7.14.8",
"@babel/plugin-transform-runtime": "~7.14.5",
"@babel/preset-env": "~7.14.8",
"@babel/preset-typescript": "^7.14.5",
"@babel/runtime": "~7.14.8",
"@hackmd/codemirror": "~5.57.7",
"@hackmd/emojify.js": "^2.1.0",

View File

@ -7,7 +7,7 @@ let checkAuth = false
let profile = null
let lastLoginState = getLoginState()
let lastUserId = getUserId()
var loginStateChangeEvent = null
let loginStateChangeEvent = null
export function setloginStateChangeEvent (func) {
loginStateChangeEvent = func

View File

@ -1,3 +1,12 @@
interface Window {
DROPBOX_APP_KEY: string,
domain: string,
urlpath: string,
debug: boolean,
serverurl: string,
version: string
}
export const DROPBOX_APP_KEY = window.DROPBOX_APP_KEY || ''
export const domain = window.domain || '' // domain name

View File

@ -406,6 +406,7 @@ module.exports = {
},
resolve: {
extensions: ['.js', '.ts'],
alias: {
codemirror: path.join(__dirname, 'node_modules/@hackmd/codemirror/codemirror.min.js'),
inlineAttachment: path.join(__dirname, 'public/vendor/inlineAttachment/inline-attachment.js'),
@ -452,10 +453,7 @@ module.exports = {
module: {
rules: [{
test: /\.mjs$/,
type: 'javascript/auto'
}, {
test: /\.js$/,
test: /\.(m?js|ts)$/,
use: [{ loader: 'babel-loader' }],
exclude: [
path.resolve(__dirname, 'node_modules'),