From 6b618bac9128167f7c13392957db2d67438a2f6f Mon Sep 17 00:00:00 2001 From: Keyan Zhang Date: Wed, 20 Jul 2016 13:29:31 -0700 Subject: [PATCH] annotate unannotated non-liftable state with ExistsType instead of object type (#68) --- .../__testfixtures__/class-initial-state.output.js | 12 ++++++------ transforms/class.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/transforms/__testfixtures__/class-initial-state.output.js b/transforms/__testfixtures__/class-initial-state.output.js index e71740c0..146688ec 100644 --- a/transforms/__testfixtures__/class-initial-state.output.js +++ b/transforms/__testfixtures__/class-initial-state.output.js @@ -61,7 +61,7 @@ class App extends React.Component { } class App2 extends React.Component { - state: Object; + state: *; constructor(props, context) { super(props, context); @@ -81,7 +81,7 @@ App.contextTypes = { }; class MyComponent2 extends React.Component { - state: Object; + state: *; constructor(props) { super(props); @@ -100,7 +100,7 @@ class MyComponent2 extends React.Component { const getContextFromInstance = (x) => x.context; // meh class MyComponent3 extends React.Component { - state: Object; + state: *; constructor(props, context) { super(props, context); @@ -141,7 +141,7 @@ class MyComponent5 extends React.Component { // intense control flow testing class Loader extends React.Component { - state: Object; + state: *; constructor(props, context) { super(props, context); @@ -183,7 +183,7 @@ class Loader extends React.Component { } class FunctionDeclarationInGetInitialState extends React.Component { - state: Object; + state: *; constructor(props) { super(props); @@ -274,7 +274,7 @@ var ShadowingIssue = React.createClass({ // bail out here // will remove unnecessary bindings class ShadowingButFine extends React.Component { - state: Object; + state: *; constructor(props, context) { super(props, context); diff --git a/transforms/class.js b/transforms/class.js index deb227dd..dd5e8752 100644 --- a/transforms/class.js +++ b/transforms/class.js @@ -910,7 +910,7 @@ module.exports = (file, api, options) => { maybeConstructor = createConstructor(getInitialState); if (shouldTransformFlow) { let stateType = j.typeAnnotation( - j.genericTypeAnnotation(j.identifier('Object'), null) + j.existsTypeAnnotation() ); if (getInitialState.value.returnType) {