Flow: Cannot build a typed interface for this module - flowtype

I'm getting these errors when I run flow but not sure at all why:
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ packages/gestalt/src/Typeahead.js:272:9
Cannot build a typed interface for this module. You should annotate the exports of this module with types. Cannot
determine the type of this call expression. Please provide an annotation, e.g., by adding a type cast around this
expression. [signature-verification-failure]
269│ Typeahead.propTypes = {
270│ id: PropTypes.string,
271│ onChange: PropTypes.func,
272│ data: PropTypes.arrayOf(
273│ PropTypes.exact({
274│ label: PropTypes.string.isRequired,
275│ value: PropTypes.string.isRequired,
276│ })
277│ ),
278│ placeholder: PropTypes.string,
279│ size: PropTypes.oneOf(['md', 'lg']),
280│ searchField: PropTypes.string,
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ packages/gestalt/src/Typeahead.js:279:9
Cannot build a typed interface for this module. You should annotate the exports of this module with types. Cannot
determine the type of this call expression. Please provide an annotation, e.g., by adding a type cast around this
expression. [signature-verification-failure]
276│ })
277│ ),
278│ placeholder: PropTypes.string,
279│ size: PropTypes.oneOf(['md', 'lg']),
280│ searchField: PropTypes.string,
281│ onBlur: PropTypes.func,
282│ onFocus: PropTypes.func,
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ packages/gestalt/src/Typeahead.js:284:16
Cannot build a typed interface for this module. You should annotate the exports of this module with types. Cannot
determine the type of this call expression. Please provide an annotation, e.g., by adding a type cast around this
expression. [signature-verification-failure]
281│ onBlur: PropTypes.func,
282│ onFocus: PropTypes.func,
283│ onSelect: PropTypes.func,
284│ defaultItem: PropTypes.exact({
285│ label: PropTypes.string.isRequired,
286│ value: PropTypes.string.isRequired,
287│ }),
288│ noResultText: PropTypes.string,
289│ };
290│
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ packages/gestalt/src/TypeaheadInputField.js:193:16
Cannot build a typed interface for this module. You should annotate the exports of this module with types. Cannot
determine the type of this call expression. Please provide an annotation, e.g., by adding a type cast around this
expression. [signature-verification-failure]
190│ };
191│ forwardRefInputField.displayName = 'InputField';
192│
193│ export default React.forwardRef<Props, HTMLInputElement>(forwardRefInputField);
194│
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ packages/gestalt/src/TypeaheadOption.js:79:11
Cannot build a typed interface for this module. You should annotate the exports of this module with types. Cannot
determine the type of this call expression. Please provide an annotation, e.g., by adding a type cast around this
expression. [signature-verification-failure]
76│ Option.displayName = 'Option';
77│
78│ Option.propTypes = {
79│ option: PropTypes.exact({
80│ label: PropTypes.string.isRequired,
81│ value: PropTypes.string.isRequired,
82│ }),
83│ selected: PropTypes.exact({
84│ label: PropTypes.string.isRequired,
85│ value: PropTypes.string.isRequired,
Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ packages/gestalt/src/TypeaheadOption.js:83:13
Cannot build a typed interface for this module. You should annotate the exports of this module with types. Cannot
determine the type of this call expression. Please provide an annotation, e.g., by adding a type cast around this
expression. [signature-verification-failure]
80│ label: PropTypes.string.isRequired,
81│ value: PropTypes.string.isRequired,
82│ }),
83│ selected: PropTypes.exact({
84│ label: PropTypes.string.isRequired,
85│ value: PropTypes.string.isRequired,
86│ }),
87│ searchField: PropTypes.string,
88│ handleSelect: PropTypes.func,
89│ };
Found 6 errors

This is because you have the types first architecture enabled which means that at module boundaries must be explicitly typed before you can export it.
You can learn more about it here
What is the "types first" Flow architecture?

Related

How do I convert part of a Terraform schema provider from interface {}([]interface {}) to an array of strings

I am creating a new resource in the aws-terraform-provider. In my schema, I have the following vpc options which is a complex type.
...
"vpc_options": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"subnets": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"security_groups": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
},
...
In hashicorp configuration language i am using this resource like this
vpc_options {
5 subnets = ["subnet-0be8cde92b74efcc8", "subnet-03a31237a28404445"]
6 security_groups = ["sg-0d3c85573d69473fb"]
7 }
I want to be able to use this resource. In order for me to use these fields effectively, I think I need the resource to be in the form of strings that I can use with the aws api calls for creation, deletion, update, and read. Even though I need these values to be strings, when I read the vpc_config in the debugger, I see that they are of type
interface {}([]interface {}) [map[string]interface {} ["subnets": *(*interface {})(0xc0063a8088), "security_groups": *(*interface {})(0xc0063a8098), ]]
Here is a picture of me inspecting the vpc_config in my debugger.
How should i go about converting this to an array of subnet strings and an array of security_groups strings. Then update the schema with d.Set("subnets",.... and d.Set("security_groups",....

Use a reference to the same object inside an object

I'm trying to do something like this:
User:
type: "object"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
manager:
$ref: "/definitions/User"
Editor does not throw an exception, but the code generated according to this schema does not work at all.
I generated python-flask server, and on launch, it throws:
ImportError: cannot import name 'User'
Looking through the code I found that 'User' class uses 'User' keyword in __init__ and inside the class.
Also there was the import: from swagger_server.models.user import User
Does python-flask generator know how to implement references like this?

swagger editor reference definition inside another definition

Inside my definitions I'm using inheritance. In the example below, the PERSON-PATCH properties are coming in without issue. Now I want to take the PERSON-BIO properties and show that's a sub-object inside the PersonGet. I can't figure out the syntax to do that.
PersonBio:
type: object
properties: &PERSON-BIO
nickname:
type: string
description: The nickname for the Person
... other properties chopped out ...
minProperties: 1
PersonGet:
type: object
properties:
<<: *PERSON-PATCH
ident:
type: integer
format: int32
description: The SQL ident of the Person
bio:
<<: *PERSON-BIO
OK, just figured this out;
PersonGet:
type: object
properties:
<<: *PERSON-PATCH
bio:
$ref: '#/definitions/PersonBio'

Trouble Accessing Set Context in Collection2 to Display Invalid Keys on CLIENT

I am using Collection2 for form insert and validation. It works great.
My only issue using the context to access the keys for presenting errors back to the user on the client.
I have the following code:
Common.coffee
Schemas = {}
Schemas.Journal = new SimpleSchema
goal:
type: String
label: "Related Goal"
max: 200
description:
type: String
label: "Comment"
max: 200
likes:
type: Number
label: "Likes"
min: 0
createdBy:
type: String
max: 50
createdAt:
type: Date
label: "Created At"
Journal.attachSchema(Schemas.Journal)
journalContext = Schemas.Journal.namedContext("insertForm")
On Client:
Template.journalForm.events
'submit #newEntryForm': (event) ->
text = event.target.text.value
Meteor.call("newJournalEntry", Session.get("activeGoal"), text)
On Server as a Method:
'newJournalEntry': (goalId, text) ->
Journal.insert
goal: goalId
description: text
createdAt: new Date()
createdBy: Meteor.userId()
likes: 0
{validationContext: "insertForm"}, (error, result) ->
if error
console.log error.invalidKeys
else
console.log "#{result} added to Journal collection."
The validation works correctly on the server and when insert is denied I see the correct messages via terminal, but calling the validation context ON THE CLIENT always gives back an empty array. []
Either of the following work on the server, but if I try these on the client they are empty:
Schemas.Journal.namedContext("insertForm").invalidKeys()
or
error.invalidKeys
UPDATE:
I tried a few more tries at the syntax ON THE CLIENT. Same empty array result. Here are the attempts:
Schemas.Journal.namedContext().invalidKeys()
journalContext.invalidKeys()
Schemas.Journal.namedContext("insertForm").invalidKeys()

meteorJS autoforms: Change a value before insert OR use multiple types of value

I use autoforms for my forms. Now I have a special problem and I am asking myself if its possible to solve this easy with autoforms.
With my autoforms I want to build a easy Category-Tree in my MongoDB. Just with a name and a parent (select).
This looks like this:
Categories.attachSchema(new SimpleSchema({
name : {
type: String,
label: "Name",
max: 200
},
parent : {
type : String,
allowedValues: [false, 'id_of_cat_1', 'id_of_cat_2', 'id_of_cat_3'],
optional : true,
autoform: {
options: [
{label: '- none -', value: false},
{label: 'cat 1', value: 'id_of_cat_1'},
{label: 'cat 2', value: 'id_of_cat_2'},
{label: 'cat 3', value: 'id_of_cat_3'}
]
}
}
}));
Very short and very simple. The autoforms now creates me the form and I am able to do stuff with it.
But whats the problem here ? The problem is the parent-value. Its type is String and because of this selecting "- none -" is not possible. But I want that the field parent in the database has a boolean value (false) when no parent is given.
The question is now how to solve this.
Is it better - and possible - to give a value 2 or more types ? If not it must be necessery to overwrite the value after or before isnerting to the collection - but this also does not work because the simpleSchema do deny this process. FOr overwriting I use matb33:collection-hooks.
You can use empty string instead:
parent : {
type : String,
allowedValues: ['', 'id_of_cat_1', 'id_of_cat_2', 'id_of_cat_3'],
optional : true,
autoform: {
options: [
{label: '- none -', value: ''},
{label: 'cat 1', value: 'id_of_cat_1'},
{label: 'cat 2', value: 'id_of_cat_2'},
{label: 'cat 3', value: 'id_of_cat_3'}
]
}
}
It makes sense since the empty string works as false in the if statement

Resources