Skip to content

Commit

Permalink
FIX #448 and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
pubkey committed Dec 30, 2017
1 parent 66e4b92 commit 245413c
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 43 deletions.
81 changes: 39 additions & 42 deletions src/typings/index.d.ts
Expand Up @@ -21,7 +21,7 @@ import {
RxCollectionCreator,
RxReplicationState,
SyncOptions,
RxCollection
RxCollection as RxCollectionClass
} from './rx-collection';
export * from './rx-collection';

Expand Down Expand Up @@ -54,59 +54,56 @@ import {
export * from './rx-plugin';


export function create(creator: RxDatabaseCreator): Promise<RxDatabase>;
export function removeDatabase(databaseName: string, adapter: any): Promise<void>;
type createType = (creator: RxDatabaseCreator) => Promise<RxDatabase>;
export const create: createType;

type removeDatabaseType = (databaseName: string, adapter: any) => Promise<void>;
export const removeDatabase: removeDatabaseType;

type QueryChangeDetector = {
enableDebugging: () => void,
enable: (to: boolean) => void
};


export function checkAdapter(adapter: any | string): Promise<boolean>;

export const QueryChangeDetector: {
enable(): void;
enableDebugging(set?: boolean): void;
};

export function plugin(mod: RxPlugin | any): void;
type pluginType = (mod: RxPlugin | any) => void;
export const plugin: pluginType;

export function isRxDatabase(obj: any): boolean;
export function isRxCollection(obj: any): boolean;
export function isRxDocument(obj: any): boolean;
export function isRxQuery(obj: any): boolean;
export function isRxSchema(obj: any): boolean;
type isInstanceOfType = (obj: any) => boolean;

declare const _default: {
create,
removeDatabase,
plugin,
RxPlugin,

// database
isRxDatabase,
RxDatabaseCreator,
RxDatabase,
export const isRxDatabase: isInstanceOfType;
export const isRxCollection: isInstanceOfType;
export const isRxDocument: isInstanceOfType;
export const isRxQuery: isInstanceOfType;
export const isRxSchema: isInstanceOfType;

// collection
isRxCollection,
RxCollectionCreator,
RxCollection,

// document
isRxDocument,
RxDocument,

// query
isRxQuery,
RxQuery,
type Test<RxDocumentType> = {
readonly doc: RxDocument<RxDocumentType>;
}

// attachment
RxAttachment,

// schema
isRxSchema,
RxSchema,
RxJsonSchema,

// other
PouchDB,
QueryChangeDetector,
RxError
declare const _default: {
create: createType,
checkAdapter: (adapter: any) => Promise<boolean>,
removeDatabase: removeDatabaseType,
plugin: pluginType,
dbCount: () => number,
isRxDatabase: isInstanceOfType,
isRxCollection: isInstanceOfType,
isRxDocument: isInstanceOfType,
isRxQuery: isInstanceOfType,
isRxSchema: isInstanceOfType,
RxSchema: RxSchema,
PouchDB: PouchDB,
QueryChangeDetector: QueryChangeDetector,
RxDatabase: RxDatabase
};

export default _default;
2 changes: 1 addition & 1 deletion src/typings/rx-document.d.ts
Expand Up @@ -33,7 +33,7 @@ export declare class RxDocumentBase<RxDocumentType> {
update(updateObj: any): Promise<any>;
atomicUpdate(fun: Function): Promise<RxDocument<RxDocumentType>>;

putAttachment(RxAttachmentCreator): Promise<RxAttachment<RxDocumentType>>;
putAttachment(creator: RxAttachmentCreator): Promise<RxAttachment<RxDocumentType>>;
getAttachment(id: string): Promise<RxAttachment<RxDocumentType>>;
allAttachments(): Promise<RxAttachment<RxDocumentType>[]>;
readonly allAttachments$: Observable<RxAttachment<RxDocumentType>[]>;
Expand Down
1 change: 1 addition & 0 deletions test/helper/issue-448/index.ts
@@ -0,0 +1 @@
import rxdb from '../../../';
9 changes: 9 additions & 0 deletions test/helper/issue-448/tsconfig.json
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"strict": true,
"skipLibCheck": true,
"outDir": "../../../test_tmp/issue-448"
}
}
22 changes: 22 additions & 0 deletions test/unit/typings.test.js
Expand Up @@ -314,4 +314,26 @@ describe('typings.test.js', () => {
await transpileCode(code);
});
});
describe('issues', () => {
it('#448 strict:true not working', async () => {
/*
* TODO we currently have to set "skipLibCheck": true
* because of a rxjs-typings problem
* @link https://github.com/ReactiveX/rxjs/issues/3031
*/
const exec = require('child_process').exec;
await new Promise((res, rej) => {
exec('tsc --p "../test/helper/issue-448/tsconfig.json"', (err, stdout, stderr) => {
if (err || stderr !== '') {
// console.log('sterr:'); console.dir(stderr);
// console.log('err:'); console.dir(err);
rej(err);
} else {
// console.log('out:'); console.log(stdout);
res(stdout);
}
});
});
});
});
});

0 comments on commit 245413c

Please sign in to comment.