move buildInitial to ts
This commit is contained in:
parent
3486b71acc
commit
199ab2ba31
1
index.d.ts
vendored
Normal file
1
index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
17
index.test-d.ts
Normal file
17
index.test-d.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { expectType, expectError } from 'tsd';
|
||||||
|
|
||||||
|
import buildInitial from './src/buildInitial';
|
||||||
|
|
||||||
|
expectType<{}>(buildInitial());
|
||||||
|
|
||||||
|
type MyState = {
|
||||||
|
foo: {
|
||||||
|
bar: number
|
||||||
|
},
|
||||||
|
baz: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
expectType<MyState>(buildInitial<MyState>());
|
||||||
|
|
||||||
|
expectError( buildInitial<MyState>({ foo: { bar: "potato" } }) );
|
||||||
|
|
@ -1,8 +0,0 @@
|
|||||||
import fp from 'lodash/fp';
|
|
||||||
|
|
||||||
export default function buildInitial(
|
|
||||||
initial= {},
|
|
||||||
subduxes = {},
|
|
||||||
) {
|
|
||||||
return fp.isPlainObject(initial) ? fp.mergeAll([subduxes, initial]) : initial;
|
|
||||||
}
|
|
11
src/buildInitial/index.ts
Normal file
11
src/buildInitial/index.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import fp from 'lodash/fp';
|
||||||
|
|
||||||
|
function buildInitial<S extends object>( initial?: Partial<S>, subduxes?: Partial<S> ): S;
|
||||||
|
function buildInitial(
|
||||||
|
initial = {},
|
||||||
|
subduxes = {} ,
|
||||||
|
) {
|
||||||
|
return fp.isPlainObject(initial) ? fp.mergeAll([subduxes, initial]) : initial;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default buildInitial;
|
@ -1,16 +1,19 @@
|
|||||||
{
|
{
|
||||||
|
"include": [
|
||||||
|
"./src/**/*"
|
||||||
|
],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
/* Basic Options */
|
/* Basic Options */
|
||||||
"incremental": true, /* Enable incremental compilation */
|
"incremental": true, /* Enable incremental compilation */
|
||||||
"target": "ES2019", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
"target": "ES2019", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||||
"lib": [ "dom", "es2019" ], /* Specify library files to be included in the compilation. */
|
"lib": [ "dom", "es2019" ], /* Specify library files to be included in the compilation. */
|
||||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
"allowJs": true, /* Allow javascript files to be compiled. */
|
||||||
// "checkJs": true, /* Report errors in .js files. */
|
// "checkJs": true, /* Report errors in .js files. */
|
||||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||||
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
"declaration": false, /* Generates corresponding '.d.ts' file. */
|
||||||
"declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
"declarationMap": false, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||||
"sourceMap": true, /* Generates corresponding '.map' file. */
|
"sourceMap": false, /* Generates corresponding '.map' file. */
|
||||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||||
"outDir": "./dist", /* Redirect output structure to the directory. */
|
"outDir": "./dist", /* Redirect output structure to the directory. */
|
||||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||||
@ -24,7 +27,7 @@
|
|||||||
|
|
||||||
/* Strict Type-Checking Options */
|
/* Strict Type-Checking Options */
|
||||||
"strict": true, /* Enable all strict type-checking options. */
|
"strict": true, /* Enable all strict type-checking options. */
|
||||||
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
|
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||||
// "strictNullChecks": true, /* Enable strict null checks. */
|
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||||
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||||
|
Loading…
Reference in New Issue
Block a user