Skip to content

Incorrect definition of createIndex function of IDBObjectStore #5832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aksharpatel47 opened this issue Nov 30, 2015 · 8 comments
Closed

Incorrect definition of createIndex function of IDBObjectStore #5832

aksharpatel47 opened this issue Nov 30, 2015 · 8 comments
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this

Comments

@aksharpatel47
Copy link

I'm trying to create a composite index in Indexeddb such as

store.createIndex('user_id,todo_id', ['user_id', 'todo_id'], {unique: true});

but I'm getting an error in the keyPath field due to the createIndex function having the following signature

createIndex(name: string, keyPath: string, optionalParameters?: any): IDBIndex;

I checked the IndexedDB specification on w3.org and it states that keyPath can be a string or an array of strings. Hence, the function should have the following signature:

createIndex(name: string, keyPath: string | string[], optionalParameters?: any): IDBIndex;
@aksharpatel47 aksharpatel47 changed the title Creating Composite Index in an IndexedDB Objectstore Incorrect definition of createIndex function of IDBObjectStore Dec 1, 2015
@mhegazy mhegazy added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this Good First Issue Well scoped, documented and has the green light labels Dec 1, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Dec 1, 2015

PRs are welcomed. here is some documentation on how to submit lib.d.ts fixes: https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes

@aksharpatel47
Copy link
Author

Great. I'll do it tonight.

@aksharpatel47
Copy link
Author

The definition of createIndex is in webworker.generated.d.ts. I checked out https://github.com/Microsoft/TSJS-lib-generator. It seems I'll have to change the specification written in browser.webidl.xml in the inputfiles directory of TSJS-lib-generator. Please correct me if I'm wrong.

@mhegazy
Copy link
Contributor

mhegazy commented Dec 2, 2015

We should not be changing the specification, we have inputfiles/overridingTypes.json that allows you to override existing declarations when the script runs. @zhengbli can help you more.

@zhengbli
Copy link
Contributor

zhengbli commented Dec 2, 2015

Hi @aksharpatel47, you don't have to change the xml file, if you only want your changes to affect webworker.generated.d.ts, you can put a "flavor":"worker" in the added json file. Similar to
https://github.com/Microsoft/TSJS-lib-generator/blob/master/inputfiles/sample.json#L29

@aksharpatel47
Copy link
Author

Thanks @zhengbli. I'll keep that in mind. However, the changes I propose should be reflected in both the dom.generated.d.ts and webworker.generated.d.ts. I added a createIndex method in the overridingTypes.json. I'm on mac, so ran build.sh. Got an error saying

TSJS-lib-generator/Shared.fsx(419,17): error FS0039: The value, constructor, namespace or type 'distinct' is not defined

I have mono 4.2.1 installed. Can you help me out here.

@zhengbli
Copy link
Contributor

zhengbli commented Dec 3, 2015

@aksharpatel47 That's because you are not on F# 4.0, which normally because you are not using mono 4.2+. I tried again on a mac mini using the installer at http://www.mono-project.com/download/alpha/, which builds for me. Do you see 4.2.1 if you run mono --version from terminal?

@aksharpatel47
Copy link
Author

@zhengbli Yes. 4.2.1 is what's showing up. I installed it through homebrew. I'll remove it and try to install using the universal installer on the link you just shared.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Breaking Change Would introduce errors in existing code Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

3 participants