Skip to content

Commit

Permalink
fix(types): fix typings
Browse files Browse the repository at this point in the history
  • Loading branch information
crimx committed May 30, 2018
1 parent 41095f8 commit f242fd3
Show file tree
Hide file tree
Showing 19 changed files with 15 additions and 45 deletions.
2 changes: 0 additions & 2 deletions src/app-config/dicts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { DeepReadonly } from '@/typings/helpers'

export function getALlDicts () {
const allDicts = {
bing: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/WordPage/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { MsgType, MsgEditWord } from '@/typings/message'
import { Observable, Subject } from 'rxjs'
import { mergeMap, audit, mapTo, share, startWith, debounceTime } from 'rxjs/operators'

const { Header, Footer, Sider, Content } = Layout
const { Header, Content } = Layout

const ITEMS_PER_PAGE = 20

Expand Down
4 changes: 1 addition & 3 deletions src/components/WordPage/ExportModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { translate, TranslationFunction } from 'react-i18next'
import { Layout, Modal, Table } from 'antd'
import { TableRowSelection, ColumnProps } from 'antd/lib/table/interface'
import { ColumnProps } from 'antd/lib/table/interface'
import { Word } from '@/_helpers/record-manager'
import { storage } from '@/_helpers/browser-api'

Expand Down Expand Up @@ -130,8 +130,6 @@ export class ExportModalBody extends React.Component<ExportModalInnerProps, Expo
render () {
const {
t,
title,
onCancel,
} = this.props

const {
Expand Down
4 changes: 2 additions & 2 deletions src/components/__fake__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import setupEnv from './devDict'

setupEnv({
dict: 'zdic',
dict: 'cambridge',
style: true,
text: '沙拉',
text: 'house',
})

/*-----------------------------------------------*\
Expand Down
3 changes: 1 addition & 2 deletions src/components/dictionaries/cambridge/engine.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { fetchDirtyDOM } from '@/_helpers/fetch-dom'
import { reflect } from '@/_helpers/promise-more'
import {
HTMLString,
getInnerHTMLThunk,
handleNoResult,
getText,
removeChild,
} from '../helpers'
import { AppConfig, DictConfigs } from '@/app-config'
import { AppConfig } from '@/app-config'
import { DictSearchResult } from '@/typings/server'

const getInnerHTML = getInnerHTMLThunk('https://dictionary.cambridge.org/')
Expand Down
1 change: 0 additions & 1 deletion src/components/dictionaries/longman/engine.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { fetchDirtyDOM } from '@/_helpers/fetch-dom'
import { reflect } from '@/_helpers/promise-more'
import { HTMLString, getText, getInnerHTMLThunk, handleNoResult } from '../helpers'
import { AppConfig, DictConfigs } from '@/app-config'
import { DictSearchResult } from '@/typings/server'
Expand Down
2 changes: 1 addition & 1 deletion src/components/dictionaries/oald/engine.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fetchDirtyDOM } from '@/_helpers/fetch-dom'
import { reflect } from '@/_helpers/promise-more'
import { HTMLString, getInnerHTMLThunk, handleNoResult, getText } from '../helpers'
import { HTMLString, getInnerHTMLThunk, handleNoResult } from '../helpers'
import { AppConfig, DictConfigs } from '@/app-config'
import { DictSearchResult } from '@/typings/server'

Expand Down
1 change: 0 additions & 1 deletion src/components/dictionaries/vocabulary/View.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
import Speaker from '@/components/Speaker'
import { VocabularyResult } from './engine'

export default class DictVocabulary extends React.PureComponent<{ result: VocabularyResult }> {
Expand Down
1 change: 0 additions & 1 deletion src/components/dictionaries/websterlearner/engine.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { fetchDirtyDOM } from '@/_helpers/fetch-dom'
import { reflect } from '@/_helpers/promise-more'
import { HTMLString, getInnerHTMLThunk, handleNoResult } from '../helpers'
import { AppConfig, DictConfigs } from '@/app-config'
import { DictSearchResult } from '@/typings/server'
Expand Down
1 change: 0 additions & 1 deletion src/components/dictionaries/youdao/engine.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { fetchDirtyDOM } from '@/_helpers/fetch-dom'
import { reflect } from '@/_helpers/promise-more'
import { getText, getInnerHTMLThunk, handleNoResult, HTMLString } from '../helpers'
import { AppConfig, DictConfigs } from '@/app-config'
import { DictSearchResult } from '@/typings/server'
Expand Down
2 changes: 1 addition & 1 deletion src/content/components/DictPanelPortal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Spring } from 'react-spring'
import DictPanel, { DictPanelDispatchers, DictPanelProps } from '../DictPanel'
import { MsgSelection } from '@/typings/message'
import { Omit } from '@/typings/helpers'
import { AppConfig, DictID, DictConfigs } from '@/app-config'
import { AppConfig, DictConfigs } from '@/app-config'

const isSaladictPopupPage = !!window.__SALADICT_POPUP_PAGE__

Expand Down
2 changes: 1 addition & 1 deletion src/content/components/MenuBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import { translate } from 'react-i18next'
import { message } from '@/_helpers/browser-api'
import { TranslationFunction } from 'i18next'
import { MsgType, MsgOpenUrl, MsgSelection } from '@/typings/message'
import { MsgType, MsgOpenUrl } from '@/typings/message'
import { SelectionInfo, getDefaultSelectionInfo } from '@/_helpers/selection'

const isSaladictOptionsPage = !!window.__SALADICT_OPTIONS_PAGE__
Expand Down
1 change: 0 additions & 1 deletion src/content/containers/WordEditorContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { connect } from 'react-redux'
import WordEditorPortal from '../components/WordEditorPortal'
import { StoreState } from '../redux/modules'
import { closePanel, closeWordEditor } from '../redux/modules/widget'
import { saveWord, getWordsByText } from '@/_helpers/record-manager'

export const mapStateToProps = ({ config, dictionaries, widget }: StoreState) => {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/content/redux/create.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createStore, applyMiddleware, compose } from 'redux'
import thunk from 'redux-thunk'
import rootReducer, { StoreState } from './modules'
import rootReducer from './modules'

import { startUpAction as configStartUp } from './modules/config'
import { startUpAction as selectionStartUp } from './modules/selection'
Expand Down
2 changes: 1 addition & 1 deletion src/content/redux/modules/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { appConfigFactory, AppConfig } from '@/app-config'
import { createAppConfigStream } from '@/_helpers/config-manager'
import { StoreState, Dispatcher, DispatcherThunk } from './index'
import { StoreState, DispatcherThunk } from './index'

/*-----------------------------------------------*\
Action Type
Expand Down
7 changes: 3 additions & 4 deletions src/content/redux/modules/dictionaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,12 @@ function popupPageInit (
} = state.config

if (baPreload) {
const fetchInfo = (
baPreload === 'selection'
const fetchInfo = baPreload === 'selection'
? message.send({ type: MsgType.__PreloadSelection__ })
: message.send({ type: MsgType.GetClipboard })
.then(text => getDefaultSelectionInfo({ text, title: 'From Clipboard' }))
)
.then(info => {

fetchInfo.then(info => {
if (baAuto && info.text) {
dispatch(searchText({ info }))
} else {
Expand Down
1 change: 0 additions & 1 deletion src/content/redux/modules/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { combineReducers } from 'redux'
import mergeUniqueObjects from '../utils/merge-unique-objects'

import {
Expand Down
8 changes: 1 addition & 7 deletions src/content/redux/modules/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import { message } from '@/_helpers/browser-api'
import { createAppConfigStream } from '@/_helpers/config-manager'
import { MsgSelection, MsgType, MsgTempDisabledState, MsgEditWord } from '@/typings/message'
import { searchText, restoreDicts } from '@/content/redux/modules/dictionaries'
import { getDefaultSelectionInfo, SelectionInfo } from '@/_helpers/selection'
import { SelectionInfo } from '@/_helpers/selection'
import { Mutable } from '@/typings/helpers'

const isSaladictOptionsPage = !!window.__SALADICT_OPTIONS_PAGE__
const isSaladictInternalPage = !!window.__SALADICT_INTERNAL_PAGE__
const isSaladictPopupPage = !!window.__SALADICT_POPUP_PAGE__

/*-----------------------------------------------*\
Expand Down Expand Up @@ -134,9 +133,7 @@ export const reducer: WidgetReducer = {
const {
panelWidth,
tripleCtrl,
tripleCtrlAuto,
tripleCtrlLocation,
tripleCtrlPreload,
} = state.config

if (!tripleCtrl || state.widget.shouldPanelShow) {
Expand Down Expand Up @@ -520,8 +517,6 @@ function listenNewSelection (
const {
isPinned,
shouldPanelShow: lastShouldPanelShow,
isPanelAppear: lastIsPanelAppear,
shouldBowlShow: lastShouldBowlShow,
panelRect: lastPanelRect,
} = state.widget

Expand Down Expand Up @@ -676,7 +671,6 @@ function _getPanelRectFromEvent (
}

const winWidth = window.innerWidth
const winHeight = window.innerHeight

// icon position 10px panel position
// +-------+ +------------------------+
Expand Down
14 changes: 1 addition & 13 deletions src/typings/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,7 @@ interface Window {
__SALADICT_INTERNAL_PAGE__?: boolean
__SALADICT_OPTIONS_PAGE__?: boolean
__SALADICT_POPUP_PAGE__?: boolean

// Options page
__SALADICT_LAST_SEARCH__?: string
}

declare namespace NodeJS {
export interface Process {
// For intellisense
env: {
NODE_ENV: 'production' | 'development',
DEBUG_MODE: string
/** Fast production build without optimization and compression */
DEV_BUILD: string
}
}
}

0 comments on commit f242fd3

Please sign in to comment.