Support TypeScript for React components

Same treatment as https://github.com/matrix-org/matrix-react-sdk/pull/4203
This commit is contained in:
Travis Ralston 2020-03-11 18:19:03 -06:00
parent 87e32baefa
commit f44694ad44
4 changed files with 8 additions and 6 deletions

View file

@ -40,7 +40,7 @@
"build:res": "node scripts/copy-res.js",
"build:genfiles": "yarn reskindex && yarn build:res",
"build:modernizr": "modernizr -c .modernizr.json -d src/vector/modernizr.js",
"build:compile": "babel -d lib --verbose --extensions \".ts,.js\" src",
"build:compile": "babel -d lib --verbose --extensions \".ts,.js,.tsx\" src",
"build:bundle": "cross-env NODE_ENV=production webpack -p --progress --bail --mode production",
"build:electron": "yarn build && yarn install:electron && electron-builder -wml --ia32 --x64",
"build:electron:linux": "yarn build && electron-builder -l --x64",
@ -94,7 +94,7 @@
"@babel/preset-typescript": "^7.7.4",
"@babel/register": "^7.7.4",
"@babel/runtime": "^7.7.6",
"@types/react": "^16.9.17",
"@types/react": "16.9",
"@types/react-dom": "^16.9.4",
"autoprefixer": "^9.7.3",
"babel-eslint": "^10.0.3",

View file

@ -10,10 +10,12 @@
"outDir": "./lib",
"declaration": true,
"types": [
"node"
"node",
"react"
]
},
"include": [
"./src/**/*.ts"
"./src/**/*.ts",
"./src/**/*.tsx"
]
}

View file

@ -82,7 +82,7 @@ module.exports = (env, argv) => {
aliasFields: ['matrix_src_browser', 'browser'],
// We need to specify that TS can be resolved without an extension
extensions: ['.js', '.json', '.ts'],
extensions: ['.js', '.json', '.ts', '.tsx'],
alias: {
// alias any requires to the react module to the one in our path,
// otherwise we tend to get the react source included twice when

View file

@ -1262,7 +1262,7 @@
dependencies:
"@types/react" "*"
"@types/react@*", "@types/react@^16.9.17":
"@types/react@*", "@types/react@16.9":
version "16.9.23"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.23.tgz#1a66c6d468ba11a8943ad958a8cb3e737568271c"
integrity sha512-SsGVT4E7L2wLN3tPYLiF20hmZTPGuzaayVunfgXzUn1x4uHVsKH6QDJQ/TdpHqwsTLd4CwrmQ2vOgxN7gE24gw==