Skip to content

Type ReactComponentTreeHook #7504

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 1 commit into from
Aug 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/isomorphic/classic/element/ReactElementType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright 2016-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
* @providesModule ReactElementType
*/

'use strict';

import type { ReactInstance } from 'ReactInstanceType';

export type Source = {
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 not sure if I should put them in this file (which is a bit random) or in a different file

Copy link
Contributor

Choose a reason for hiding this comment

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

Relay has a RelayTypes and RelayInternalTypes file, would there be any benefit here to implementing something similar to that approach, if the end goal is a fully typed codebase?

fileName: string,
lineNumber: number,
};

export type ReactElement = {
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 not sure how to name this one since it's going to conflict with the ReactElement name. I've thought about appending Type but it kind of sucks to have all the types have Type at the end... In a normal codebase, the same name works because flow assumes instanceof. But in the React codebase, a lot of things return random objects with weird constructions :p

$$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

type: any,
key: any,
ref: any,
props: any,
_owner: ReactInstance,

// __DEV__
_store: {
validated: bool,
},
_self: ReactElement,
_shadowChildren: any,
_source: Source,
};
Loading