-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
IDBKeyRange definition is degraded #1075
Comments
Except for the newable contructor the current one is right. |
How do I access to IDBKeyRange.only doing? new IDBKeyRange().only // Runtime error
IDBKeyRange.only // Compile error We can no longer access the IDBKeyRange method in the regular procedure. |
|
When you have installed the VisualStudio, TypeScript that has been installed by npm is ignored. |
@falsandtru, I installed the CTP for 1.1 for VS link In short: npm 1.1 works
For clarification what are you using? Visual Studio version (if you use that) and TypeScript version? |
I am fails to compile in tsc command from cmd. Windows7 64bit |
@DickvdBrink something sounds strange, 1.1 CTP did not update the language service. so the language service is the same as you had in 1.0. so there should not be a change in behavior here. what are the errors are you seeing, and what is the definition of IDBKeyRange you have? @falsandtru can you share the code that is failing to compile, along with the error you are getting? This is building for me on 1.1, and latest from master. IDBKeyRange.only("1"); |
@mhegazy, when using VS 14 CTP with 1.1 it works like a charm, IDBKeyrange has the Different machine Windows 8.1 with VS 2012 and 2013 and installed multiple versions on it coming from TypeScript 0.8.3 if I recall correctly is giving me the error
When I look in the microsoft sdks\typescript folder I have the 1.0 and the 1.1 folder both with a lib.d.ts. Note: I did install the CTP for VS 2013 (it is showing me the warning 'Your project file uses a newer version of the TypeScript compiler...blabla') I never edited lib.d.ts manually or something and also tried to run a repair from the 1.1 CTP installer. Also: it is pretty funny because with the 1.0 release I added a extensions.d.ts file with the edited this post It didn't contain the error I was having .. xD |
I will cancel the update. Please wait a little. |
OK. now i see the problem.. you are redefining the var IDBKeyRange. The language does not allow changing the type of a var after it has been declared, this is diffrent from other constructs like an interface that can be augmented in later declarations. so something like: var x: number;
var x: string; /// error TS2403: Subsequent variable declarations must have the same type.
/// Variable 'x' must be of type 'number', but here has type 'sting'. what you want is for the definition of the var IDBKeyRange to define a new type that you can reopen later on, this is covered by #182. the soultion here would be: // lib.d.ts would define:
interface IDBKeyRange {
upper: any;
upperOpen: boolean;
lower: any;
lowerOpen: boolean;
}
interface IDBKeyRangeStatic {
prototype: IDBKeyRange;
new(): IDBKeyRange;
bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange;
only(value: any): IDBKeyRange;
lowerBound(bound: any, open?: boolean): IDBKeyRange;
upperBound(bound: any, open?: boolean): IDBKeyRange;
}
declare var IDBKeyRange: IDBKeyRangeStatic;
// your file would update the static side
interface IDBKeyRangeStatic {
myNewStaticHelperFunction();
} Now for the next issue, defining the function on the interface is not probably what you mean. so if you look at the definition, there are two things:
var instance = new IDBKeyRange();
instance.upper; // upper bounds of the value "instance", whose this object is "instance"
IDBKeyRange.upperBound // a static helper function that has no state associated with it. adding upperBound on the interface, makes all instances of IDBKeyRange, have that, which is not what you want. what you want is a helper function on the static value side of IDBKeyRange. hope that helps. |
@mhegazy, should I creatie a new issue for the probleem i'm seeing with vs2013 because I think this one is a bit noisy (which is my fault, sorry bout that) |
@DickvdBrink yes please. thanks for reporting this issue! |
Wait, Duplication seems to be due to previous declaration that I do not show. It is not a Duplication of the definition file. Please anymore let a while verification. |
The essential cause is I was found. There are the following unnatural constraints. Is this would specification? When IDBKeyRange I referring to the directly, I can use the method. Can not be defined only by inference the type of a variable.
Impossible to resolve the vendor prefix.
Impossible to define the class interface.
|
The issue here is a name can exist as a type and as a value. IDBKeyRange is both a var, and an interface. in type position (that is after the : in To create a new IDBKeyRange Object you must use one of the static helpers:
here is how you can get your samples to work.
|
marking it as a bug, as we need to remove the construct signature off IDBKeyRange |
Thanks! We can not resolve the vendor prefix. // Need
class Database {
keyrange = window.IDBKeyRange || window.msIDBKeyRange
}
var db = new Database();
var keyrange = db.keyrange.only(1); // success! // Now
class Database {
// keyrange type is not IDBKeyRange.
keyrange = window.IDBKeyRange || window.msIDBKeyRange
}
var db = new Database();
// Impossible to access the IDBKeyRange static method.
var keyrange = db.keyrange.only(1); // error... // Ideal
class IDatabase {
keyrange: IDBKeyRange
}
class Database implements IDBDatabase {
keyrange = window.IDBKeyRange || window.webkitIDBKeyRange || window.mozIDBKeyRange || window.msIDBKeyRange
}
var db: IDatabase = new Database();
var keyrange = db.keyrange.only(1); :'-( |
You can define |
I am now, I have to resolve this problem in their own definition. // User customization
declare var webkitIndexedDB: IDBFactory;
declare var mozIndexedDB: IDBFactory;
declare var msIndexedDB: IDBFactory;
declare var webkitIDBKeyRange: IDBKeyRange;
declare var mozIDBKeyRange: IDBKeyRange;
declare var msIDBKeyRange: IDBKeyRange;
interface Window {
IDBKeyRange: IDBKeyRange
webkitIDBKeyRange?: IDBKeyRange
mozIDBKeyRange?: IDBKeyRange
msIDBKeyRange?: IDBKeyRange
} // Should vendor
interface IDBKeyRange {
bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange;
only(value: any): IDBKeyRange;
lowerBound(bound: any, open?: boolean): IDBKeyRange;
upperBound(bound: any, open?: boolean): IDBKeyRange;
} |
http://www.w3.org/TR/IndexedDB/#range-concept
// lib.d.ts at master branch head
interface IDBKeyRange {
upper: any;
upperOpen: boolean;
lower: any;
lowerOpen: boolean;
// Missing method
// bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange;
// only(value: any): IDBKeyRange;
// lowerBound(bound: any, open?: boolean): IDBKeyRange;
// upperBound(bound: any, open?: boolean): IDBKeyRange;
} 'upper' in IDBKeyRange; // false
'upperOpen' in IDBKeyRange; // false
'upperBound' in IDBKeyRange; // true |
IDBKeyRange
is defined as follows.https://github.com/Microsoft/TypeScript/blob/master/bin/lib.d.ts#L11630
But it does not work.
Please recovery.
The text was updated successfully, but these errors were encountered: