mirror of
https://github.com/captbaritone/webamp.git
synced 2026-01-23 02:15:01 +00:00
Convert first files to TypeScript
This commit is contained in:
parent
c98143aedc
commit
a276ffb518
9 changed files with 58 additions and 6 deletions
3
.babelrc
3
.babelrc
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -19,7 +19,7 @@ module.exports = {
|
|||
use: ["style-loader", "css-loader"]
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
test: /\.[tj]s$/,
|
||||
exclude: /(node_modules)/,
|
||||
use: {
|
||||
loader: "babel-loader"
|
||||
|
|
|
|||
|
|
@ -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 };
|
||||
|
|
@ -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 };
|
||||
22
js/types.ts
Normal file
22
js/types.ts
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@
|
|||
"pretty": true
|
||||
},
|
||||
"include": [
|
||||
"js/**/*.js"
|
||||
"js/**/*.js",
|
||||
"js/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
|
|
|
|||
20
yarn.lock
20
yarn.lock
|
|
@ -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"
|
||||
|
|
@ -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"
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue