mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
addint definitions for @tinajs/tina-redux (#27231)
This commit is contained in:
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@@ -4293,6 +4293,7 @@
|
||||
/types/timer-machine/ @dolanmiu
|
||||
/types/timezone-js/ @bonnici
|
||||
/types/tinajs__tina/ @Jimexist
|
||||
/types/tinajs__tina-redux/ @Jimexist
|
||||
/types/tinder/ @pingec
|
||||
/types/tiny-slider-react/ @screendriver
|
||||
/types/tinycolor2/ @M-Zuber @geertjansen @nvh
|
||||
|
||||
23
types/tinajs__tina-redux/index.d.ts
vendored
Normal file
23
types/tinajs__tina-redux/index.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
// Type definitions for @tinajs/tina-redux 1.4
|
||||
// Project: https://github.com/tinajs/tina-redux
|
||||
// Definitions by: Jiayu Liu <https://github.com/Jimexist>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/tinajs__tina-redux
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Store, Dispatch } from "redux";
|
||||
|
||||
type MapStateToProps = (state: any) => any;
|
||||
type mapDispatchToProps = (dispatch: Dispatch) => any;
|
||||
|
||||
interface HOC {
|
||||
onLoad: () => void;
|
||||
onUnload: () => void;
|
||||
methods: object;
|
||||
}
|
||||
|
||||
declare class TinaRedux {
|
||||
constructor(reduxStore: Store);
|
||||
connect(mapState?: MapStateToProps, mapDispatch?: mapDispatchToProps): HOC;
|
||||
}
|
||||
|
||||
export = TinaRedux;
|
||||
6
types/tinajs__tina-redux/package.json
Normal file
6
types/tinajs__tina-redux/package.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"redux": "^4.0.0"
|
||||
}
|
||||
}
|
||||
51
types/tinajs__tina-redux/tinajs__tina-redux-tests.ts
Normal file
51
types/tinajs__tina-redux/tinajs__tina-redux-tests.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { createStore, combineReducers, Action } from "redux";
|
||||
import TinaRedux from "@tinajs/tina-redux";
|
||||
|
||||
interface Todo {
|
||||
id: number;
|
||||
text: string;
|
||||
completed: boolean;
|
||||
}
|
||||
|
||||
interface TodoAction extends Action, Todo {}
|
||||
|
||||
const intialState: Todo[] = [
|
||||
{ id: 1, text: "Star Tina.js", completed: false },
|
||||
{ id: 2, text: "Star Tina-Redux", completed: true },
|
||||
{ id: 3, text: "Build a mini-program with Tina.js", completed: false },
|
||||
{ id: 4, text: "Add to Showcase of Tina.js", completed: false }
|
||||
];
|
||||
|
||||
const todos = (state = intialState, action: TodoAction) => {
|
||||
switch (action.type) {
|
||||
case "ADD_TODO":
|
||||
return [
|
||||
...state,
|
||||
{
|
||||
id: action.id,
|
||||
text: action.text,
|
||||
completed: false
|
||||
}
|
||||
];
|
||||
case "TOGGLE_TODO":
|
||||
return state.map(
|
||||
todo =>
|
||||
todo.id === action.id
|
||||
? { ...todo, completed: !todo.completed }
|
||||
: todo
|
||||
);
|
||||
case "CLEAR_COMPLETED_TODOS":
|
||||
return state.filter(todo => !todo.completed);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const todoApp = combineReducers({
|
||||
todos
|
||||
});
|
||||
|
||||
const reduxStore = createStore(todoApp);
|
||||
const store = new TinaRedux(reduxStore);
|
||||
|
||||
export default store;
|
||||
21
types/tinajs__tina-redux/tsconfig.json
Normal file
21
types/tinajs__tina-redux/tsconfig.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"paths": {
|
||||
"@tinajs/tina": ["tinajs__tina"],
|
||||
"@tinajs/tina-redux": ["tinajs__tina-redux"]
|
||||
}
|
||||
},
|
||||
"files": ["index.d.ts", "tinajs__tina-redux-tests.ts"]
|
||||
}
|
||||
3
types/tinajs__tina-redux/tslint.json
Normal file
3
types/tinajs__tina-redux/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user