Skip to content

Commit

Permalink
Convert first files to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
captbaritone committed Sep 18, 2018
1 parent c98143a commit a276ffb
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
}
}
],
"@babel/preset-react"
"@babel/preset-react",
"@babel/preset-typescript"
],
"plugins": ["@babel/plugin-proposal-object-rest-spread", "@babel/plugin-proposal-class-properties"],
"env": {
Expand Down
4 changes: 2 additions & 2 deletions config/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const HtmlWebpackInlineSVGPlugin = require("html-webpack-inline-svg-plugin");

module.exports = {
resolve: {
extensions: [".js"]
extensions: [".js", ".ts"]
},
node: {
// Consider suggesting jsmediatags use: https://github.com/feross/is-buffer
Expand All @@ -19,7 +19,7 @@ module.exports = {
use: ["style-loader", "css-loader"]
},
{
test: /\.js$/,
test: /\.[tj]s$/,
exclude: /(node_modules)/,
use: {
loader: "babel-loader"
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion js/reducers/network.js → js/reducers/network.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {Action, NetworkState} from "../types";
import { NETWORK_CONNECTED, NETWORK_DISCONNECTED } from "../actionTypes";

const network = (state = { connected: true }, action) => {

const network = (state: NetworkState = { connected: true }, action: Action): NetworkState => {
switch (action.type) {
case NETWORK_CONNECTED:
return { ...state, connected: true };
Expand Down
7 changes: 6 additions & 1 deletion js/reducers/settings.js → js/reducers/settings.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { Action, SettingsState } from "../types";
import { SET_AVAILABLE_SKINS } from "../actionTypes";


const defaultSettingsState = {
availableSkins: []
};

const settings = (state = defaultSettingsState, action) => {
const settings = (
state: SettingsState = defaultSettingsState,
action: Action
): SettingsState => {
switch (action.type) {
case SET_AVAILABLE_SKINS:
return { ...state, availableSkins: action.skins };
Expand Down
22 changes: 22 additions & 0 deletions js/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
type Skin = {
url: string, name: string
}

export type Action = {
type: "NETWORK_CONNECTED"
} | {
type: "NETWORK_DISCONNECTED"
} | {
type: "SET_AVAILABLE_SKINS"
skins: Array<Skin>
}


export interface SettingsState {
availableSkins: Array<Skin>;
}


export interface NetworkState {
connected: boolean;
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.0.0",
"@babel/runtime": "^7.0.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^9.0.0-beta.3",
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"pretty": true
},
"include": [
"js/**/*.js"
"js/**/*.js",
"js/**/*.ts"
],
"exclude": [
"node_modules",
Expand Down
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,12 @@
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"

"@babel/plugin-syntax-typescript@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.0.0.tgz#90f4fe0a741ae9c0dcdc3017717c05a0cbbd5158"
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"

"@babel/plugin-transform-arrow-functions@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.0.0.tgz#a6c14875848c68a3b4b3163a486535ef25c7e749"
Expand Down Expand Up @@ -562,6 +568,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"

"@babel/plugin-transform-typescript@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.0.0.tgz#71bf13cae08117ae5dc1caec5b90938d8091a01e"
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-syntax-typescript" "^7.0.0"

"@babel/plugin-transform-unicode-regex@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.0.0.tgz#c6780e5b1863a76fe792d90eded9fcd5b51d68fc"
Expand Down Expand Up @@ -633,6 +646,13 @@
"@babel/plugin-transform-react-jsx-self" "^7.0.0"
"@babel/plugin-transform-react-jsx-source" "^7.0.0"

"@babel/preset-typescript@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.0.0.tgz#1e65c8b863ff5b290f070d999c810bb48a8e3904"
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-transform-typescript" "^7.0.0"

"@babel/runtime@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.0.0.tgz#adeb78fedfc855aa05bc041640f3f6f98e85424c"
Expand Down

0 comments on commit a276ffb

Please sign in to comment.