-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat(index): move isInitialized to aurelia-pal #16
Conversation
/** | ||
* The runtime's history API. | ||
*/ | ||
history: Object; | ||
history: typeof window.history; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct for history and location? I get that Element
isn't an instance of Element
but is the type itself but history and location are the instances of history and location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@EisenbergEffect Yeah, this is correct. typeof
in TypeScript doesn't mean "the class of X", but simply "same type as X". So "typeof window.history" is the type of an instance of history.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MeirionHughes I've checked this. The reason last one came out wrong is you have an error in your example. Last example should be:
let foo = new Foo();
let foo2: typeof foo = foo;
Since you used typeof Foo
instead of typeof foo
you got the ctor of Foo
, not referenced type of the variable foo
.
Going back to the actual problem, history
is a property of the window
object. So typeof window.history
is the type of the variable on the Window object, i.e. type of the instance of History.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... never mind; its fine because the typeof target is an instance, so it grabs the type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just need some clarification on my question. Otherwise, I can merge this. Let me know.
It makes sense to have
isInitialized
in aurelia-pal, not in each individual-pal
repository, otherwise you can initialize it multiple times with different PALs by mistake, which is probably not the desired behavior. I've added areset()
function just in case somebody wants to purposefully reinitialize PAL with a different version.Related PRs for all PALs: