Skip to content

Commit 296e701

Browse files
authored
Merge pull request element-hq#12696 from vector-im/travis/typescript-2
Support TypeScript for React components
2 parents 87e32ba + 798d4da commit 296e701

4 files changed

Lines changed: 10 additions & 8 deletions

File tree

‎package.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@
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",
4747
"build:electron:macos": "yarn build && electron-builder -m --x64",
4848
"build:electron:windows": "yarn build && electron-builder -w --ia32 --x64",
49-
"build:types": "tsc --emitDeclarationOnly",
49+
"build:types": "tsc --emitDeclarationOnly --jsx react",
5050
"install:electron": "electron-builder install-app-deps",
5151
"dist": "scripts/package.sh",
5252
"start": "concurrently --kill-others-on-fail --prefix \"{time} [{name}]\" -n reskindex,reskindex-react,res,riot-js \"yarn reskindex:watch\" \"yarn reskindex:watch-react\" \"yarn start:res\" \"yarn start:js\"",
@@ -56,7 +56,7 @@
5656
"lint": "yarn lint:types && yarn lint:ts && yarn lint:js && yarn lint:style",
5757
"lint:js": "eslint src",
5858
"lint:ts": "echo 'We don't actually have a typescript linter at this layer because tslint is being removed from our stack. Presumably your TS is fine.'",
59-
"lint:types": "tsc --noEmit",
59+
"lint:types": "tsc --noEmit --jsx react",
6060
"lint:style": "stylelint 'res/css/**/*.scss'",
6161
"test": "jest"
6262
},
@@ -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)