What is correct way to declare custom class factory?
- Lingua principale
- Rust
- Stelle
- 22.3k
- Fork
- 1.9k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Hello!
I'm searched, but not found answer on the similar question. Sorry if issue like this already exists.
When we [declare React-class](https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoAbgQwE5gEoCmmAxgC5gC8Y2BAjgK4CWNAFAOQ0mlsCUA3KkJcAdMU6kCAYRiYAzrJYBvVGFVhicAHaaCZFjzDK1x9Vtnl62GAC4wm+gFsARgVxVSAC0azhAcwKkAKpW+gLGAL4ANCpq-kEhPLbm2IyavoYxJtQBlppgbGxhauGo4fyoQA):
```
/* @flow */
var React = require('react');
React.createClass({
connect() {
const url: number = this.getUrl();
},
getUrl(): string {
return '';
}
});
```
Flow throws expected errors:
```
5: const url: number = this.getUrl();
^ string. This type is incompatible with
5: const url: number = this.getUrl();
^ number
```
But when we [declare our custom class factory](https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoAJgUwMYwIYBOmYueAzmWALICeYA3qmGGQC56sCW2JRHmAYXwUAPAAUAfAAoADgTgyyALjBiAlCqHky4iQG5UAX1S0AdNj6tBwslMbNm2OADtnOVlLUMmD30+dsYACuBDAqzkEAtgBGmARgALxgrAAWnGSmAOaYrACqoZ4GvoYAND7M2XkFGiysBJzOmd6+vkSsIc5gAORdRQ7GhmoGQA):
```
/* @flow */
declare class My {
static createClass
(props: P): Class
;
}
My.createClass({
connect() {
const url: number = this.getUrl();
},
getUrl(): string {
return '';
}
});
```
Flow says that it's `No errors!`. Why? How we can describe declaration to achieve the same behaviour as `React.createClass`?
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.