Skip to content

Add overrides for interface types and add CustomEvent types for testing. #319

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

Merged
merged 4 commits into from
Nov 7, 2017

Conversation

jthoms1
Copy link
Contributor

@jthoms1 jthoms1 commented Nov 4, 2017

This PR will fix microsoft/TypeScript#14785 and replace #304.

In order to override interfaces and add types this PR updates the TS.fsx and adds a new override type called typedinterface. The naming convention was provided here #304 (comment)

This is my first time writing F# so please let me know if I need to make changes to the convention or if I missed an interfaces beyond Dictionaries or Interface Declarations.

@@ -1,5 +1,40 @@
[
{
"kind": "typedinterface",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do not think you need a new kind here.. just add a property typeParameters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So would kind be interface and then parameters would become typeParameters?

@jthoms1
Copy link
Contributor Author

jthoms1 commented Nov 6, 2017

Much better approach. I have updated the code to reflect the requested changes.

"interface": "CustomEvent",
"name": "initCustomEvent",
"signatures": [
"(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: T): void"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to include the name here. i.e. initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: T)

@@ -2374,9 +2374,9 @@ declare var CSSSupportsRule: {
new(): CSSSupportsRule;
};

interface CustomEvent extends Event {
readonly detail: any;
initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: any): void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name of the method is missing.

initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: any): void;
interface CustomEvent<T = any> extends Event {
readonly detail: T;
(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: T): void;
}

declare var CustomEvent: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to change this one too, this is your entry point to an event.. it should be:

declare var CustomEvent: {
prototype: CustomEvent;
     new<T>(typeArg: string, eventInitDict?: CustomEventInit<T>): CustomEvent<T>;
 };

@jthoms1
Copy link
Contributor Author

jthoms1 commented Nov 6, 2017

initCustomEvent is back in and I also added the type information to the constructor.

interface CustomEventInit extends EventInit {
detail?: any;
interface CustomEventInit<T = any> extends EventInit {
detail: T;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

detail should still be optional? or is this intentional?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good otherwise. thanks!

@jthoms1
Copy link
Contributor Author

jthoms1 commented Nov 7, 2017

It is now optional. Thanks! Good learning experience I will likely have more PRs in the future.

@mhegazy mhegazy merged commit 9e73579 into microsoft:master Nov 7, 2017
@arjunyel
Copy link
Contributor

arjunyel commented Nov 7, 2017

@jthoms1 thank you for stepping up and seeing this through! I got stuck at the F# stuff and never made it through

@jthoms1
Copy link
Contributor Author

jthoms1 commented Nov 8, 2017

@arjunyel No worries, I really wanted this. Your work started it! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CustomEvent should be parameterized by detail type.
3 participants