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

TypeError: Property internalSlots expected type of array but got boolean #27

Open
natramov opened this issue Jun 23, 2018 · 9 comments
Open

Comments

@natramov
Copy link

natramov commented Jun 23, 2018

Hi, in version 0.4.0 i get this type error:

TypeError: Property internalSlots expected type of array but got boolean at validate (/Users/admin/WebstormProjects/flow-swagger/node_modules/@babel/types/lib/definitions/utils.js:161:13) at Object.validate (/Users/admin/WebstormProjects/flow-swagger/node_modules/@babel/types/lib/definitions/utils.js:172:7) at validate (/Users/admin/WebstormProjects/flow-swagger/node_modules/@babel/types/lib/validators/validate.js:17:9) at builder (/Users/admin/WebstormProjects/flow-swagger/node_modules/@babel/types/lib/builders/builder.js:46:27) at ObjectTypeAnnotation (/Users/admin/WebstormProjects/flow-swagger/node_modules/@babel/types/lib/builders/generated/index.js:649:31) at processObjectSchema (/Users/admin/WebstormProjects/flow-swagger/node_modules/json-schema-to-flow-type/lib/FlowTypeGenerator.js:43:12) at exports.toFlowType.flowSchema (/Users/admin/WebstormProjects/flow-swagger/node_modules/json-schema-to-flow-type/lib/FlowTypeGenerator.js:60:12) at exports.toFlow.flowSchema (/Users/admin/WebstormProjects/flow-swagger/node_modules/json-schema-to-flow-type/lib/index.js:33:194) at exports.schemaToFlow.flowSchema (/Users/admin/WebstormProjects/flow-swagger/node_modules/json-schema-to-flow-type/lib/index.js:35:139) at /Users/admin/WebstormProjects/flow-swagger/node_modules/lodash/lodash.js:5138:35

@wmonk
Copy link
Contributor

wmonk commented Jun 25, 2018

Please can you provide some more detail as how to reproduce this error.

@benjamine
Copy link

benjamine commented Jul 5, 2018

+1, I avoided it downgrading to 0.2.6 (the previous version I was using)

@wmonk
Copy link
Contributor

wmonk commented Jul 5, 2018

@benjamine @natramov can you provide more information. Would be helpful to have the schema that is causing this issue. Closing until that point.

@wmonk wmonk closed this as completed Jul 5, 2018
@benjamine
Copy link

benjamine commented Jul 5, 2018

@wmonk

const jsonSchemaToFlowType = require("json-schema-to-flow-type");

const schema = {
    "type": "object",
    "properties": {
      "id": {
        "type": "string"
      },
      "reportType": {
        "type": "string",
        "example": "issues",
        "description": "a report type"
      },
      "params": {
        "type": "object",
        "description": "parameters for the report.\n        these can be specific to the report type",
        "properties": {}
      },
      "createdAt": {
        "$ref": "#/definitions/Date"
      }
    },
    "additionalProperties": false,
    "required": [
      "id",
      "reportType",
      "params",
      "createdAt"
    ],
    "id": "Report"
  };
  
 const imports = {
    "Report": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "reportType": {
          "type": "string",
          "example": "issues",
          "description": "a report type"
        },
        "params": {
          "type": "object",
          "description": "parameters for the report.\n        these can be specific to the report type"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}:\\d{2}\\.{0,1}[0-9]*Z$",
          "description": "creation datetime"
        }
      },
      "additionalProperties": false,
      "required": [
        "id",
        "reportType",
        "params",
        "createdAt"
      ],
      "id": "Report"
    },
    "ReportList": {
      "type": "object",
      "properties": {
        "entries": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Report"
          }
        }
      },
      "additionalProperties": false,
      "required": [
        "entries"
      ],
      "id": "ReportList"
    }
  };

jsonSchemaToFlowType.parseSchema(schema, imports);

on 0.4.0 throws:

TypeError: Property internalSlots expected type of array but got boolean
   at validate in @babel/types/lib/definitions/utils.js — line 161
   at Object.validate in @babel/types/lib/definitions/utils.js — line 172
   ....

(works fine with 0.2.6)

@wmonk
Copy link
Contributor

wmonk commented Jul 5, 2018

@benjamine thanks for this, will investigate

@wmonk wmonk reopened this Jul 5, 2018
This was referenced Jul 25, 2018
@zhulduz
Copy link

zhulduz commented Aug 2, 2018

@wmonk Any updates?

@esturcke
Copy link

Looks like the problem is the @babel/types signature for objectTypeAnnotation has a new 4th argument. There's an open pull request #28 to address it. I've tested this fix locally and it's working for me.

@esturcke
Copy link

As a stopgap, @marudor has published @marudor/json-schema-to-flow-type with the fix.

@sakai-akinobu
Copy link
Contributor

This problem was solved in #28 and v1.0.0 was released.
So I recommend using v1.0.0.

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

No branches or pull requests

6 participants