Skip to content

Commit f44694a

Browse files
committed
Support TypeScript for React components
Same treatment as matrix-org/matrix-react-sdk#4203
1 parent 87e32ba commit f44694a

4 files changed

Lines changed: 8 additions & 6 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"build:res": "node scripts/copy-res.js",
4141
"build:genfiles": "yarn reskindex && yarn build:res",
4242
"build:modernizr": "modernizr -c .modernizr.json -d src/vector/modernizr.js",
43-
"build:compile": "babel -d lib --verbose --extensions \".ts,.js\" src",
43+
"build:compile": "babel -d lib --verbose --extensions \".ts,.js,.tsx\" src",
4444
"build:bundle": "cross-env NODE_ENV=production webpack -p --progress --bail --mode production",
4545
"build:electron": "yarn build && yarn install:electron && electron-builder -wml --ia32 --x64",
4646
"build:electron:linux": "yarn build && electron-builder -l --x64",
@@ -94,7 +94,7 @@
9494
"@babel/preset-typescript": "^7.7.4",
9595
"@babel/register": "^7.7.4",
9696
"@babel/runtime": "^7.7.6",
97-
"@types/react": "^16.9.17",
97+
"@types/react": "16.9",
9898
"@types/react-dom": "^16.9.4",
9999
"autoprefixer": "^9.7.3",
100100
"babel-eslint": "^10.0.3",

tsconfig.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
"outDir": "./lib",
1111
"declaration": true,
1212
"types": [
13-
"node"
13+
"node",
14+
"react"
1415
]
1516
},
1617
"include": [
17-
"./src/**/*.ts"
18+
"./src/**/*.ts",
19+
"./src/**/*.tsx"
1820
]
1921
}

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ module.exports = (env, argv) => {
8282
aliasFields: ['matrix_src_browser', 'browser'],
8383

8484
// We need to specify that TS can be resolved without an extension
85-
extensions: ['.js', '.json', '.ts'],
85+
extensions: ['.js', '.json', '.ts', '.tsx'],
8686
alias: {
8787
// alias any requires to the react module to the one in our path,
8888
// otherwise we tend to get the react source included twice when

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,7 @@
12621262
dependencies:
12631263
"@types/react" "*"
12641264

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

0 commit comments

Comments
 (0)