Skip to content
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

Type ReactComponentTreeHook #7504

Merged
merged 1 commit into from
Aug 25, 2016
Merged

Conversation

vjeux
Copy link
Contributor

@vjeux vjeux commented Aug 15, 2016

For this one, I wanted to type a non-trivial piece of the codebase and ran into the fact that we do not have types for ReactElement nor ReactInstance, so I had to create them.

I'll add comments inline

};

export type ReactElement = {
$$typeof: any,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I typed everything any that I did not need to type ReactComponentTreeHook

@gaearon
Copy link
Collaborator

gaearon commented Aug 19, 2016

Sorry, I was still changing stuff and this got outdated.
Can you rebase and I’ll review?

@vjeux vjeux force-pushed the type_ReactComponentTreeHook branch from 1290d53 to ea4aecd Compare August 25, 2016 17:52
@vjeux
Copy link
Contributor Author

vjeux commented Aug 25, 2016

Just rebased

For this one, I wanted to type a non-trivial piece of the codebase and ran into the fact that we do not have types for ReactElement nor ReactInstance, so I had to create them.

I'll add comments inline
@vjeux vjeux force-pushed the type_ReactComponentTreeHook branch from ea4aecd to 6842e2e Compare August 25, 2016 18:06
@vjeux vjeux changed the title [RFC] Type ReactComponentTreeHook Type ReactComponentTreeHook Aug 25, 2016
@vjeux vjeux merged commit ea494a2 into facebook:master Aug 25, 2016
@vjeux vjeux added this to the 15-next milestone Aug 25, 2016
}
function getIDFromKey(key: string): DebugID {
return parseInt(key.substr(1), 10);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

lint is complaining about these functions being inside the else

  116:3  error  Move function declaration to program root  no-inner-declarations
  119:3  error  Move function declaration to program root  no-inner-declarations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

arg, I ran npm test but didn't run the lint. Travis is soo backed up, I'll send a quick fix

vjeux added a commit to vjeux/react that referenced this pull request Aug 25, 2016
In Type ReactComponentTreeHook facebook#7504, I merged even though travis didn't report green (travis for all the fb repos has been backlogged like crazy since this morning) by manually doing `npm test` and `npm run flow` but I didn't ensure that lint was all green.

@millermedeiros pinged me about it so here's a quick fix
@vjeux vjeux mentioned this pull request Aug 25, 2016
updateCount: number,
};

declare function getItem(id: DebugID): ?Item;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this going to result in a global definition of getItem or is it local to this module? I thought these weren't supposed to be used in local code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm doing two implementations in the two branches below, I want both to match the same API. What is the flow way of doing things?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like I don't even need this block anymore, if I remove it, it works with flow!

Copy link
Collaborator

@sebmarkbage sebmarkbage Aug 26, 2016

Choose a reason for hiding this comment

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

If we want to start using let/const consistently instead of var. We would have to hoist the let statements upwards.

Can you do something like this?

let foo : (x : number) => string;

if (window.bar) {
  foo = (x : number) => x + 'bar';
} else {
  foo = (x : number) => x + '';
}

let bar : string = foo(10);

Flow is smart enough to know that it is not possible for foo to be undefined here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

vjeux added a commit that referenced this pull request Aug 26, 2016
In Type ReactComponentTreeHook #7504, I merged even though travis didn't report green (travis for all the fb repos has been backlogged like crazy since this morning) by manually doing `npm test` and `npm run flow` but I didn't ensure that lint was all green.

@millermedeiros pinged me about it so here's a quick fix
@zpao zpao modified the milestones: 15-next, 15.4.0 Oct 4, 2016
zpao pushed a commit that referenced this pull request Oct 4, 2016
For this one, I wanted to type a non-trivial piece of the codebase and ran into the fact that we do not have types for ReactElement nor ReactInstance, so I had to create them.

I'll add comments inline
(cherry picked from commit ea494a2)
zpao pushed a commit that referenced this pull request Oct 4, 2016
In Type ReactComponentTreeHook #7504, I merged even though travis didn't report green (travis for all the fb repos has been backlogged like crazy since this morning) by manually doing `npm test` and `npm run flow` but I didn't ensure that lint was all green.

@millermedeiros pinged me about it so here's a quick fix
(cherry picked from commit 66e77f6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants