saguiar
Re:Gödel's Incompleteness Theorems (2015)
on Tuesday April 04, 2017 @01:20PM (#14035081)
Agreed it has been abused. On the other hand, if you adhere to a computational theory of mind and see the mind as computation over a formal system, then it is saying something about the mind and the fact that some (true) sentences cannot be proven in that system, isn't it? It is a big if though.
(though maybe in a completely irrelevant sense of truth).
Re:If TypeScript is so great, how come all notable ReactJS projects us...
on Tuesday September 20, 2016 @02:18PM (#12541876)
> What I really miss is the ability to say that what is the return type of the method
Agreed! There's an open issue that addresses that scenario (and a ton of others):
Re:If TypeScript is so great, how come all notable ReactJS projects us...
on Tuesday September 20, 2016 @01:25PM (#12541231)
I've been using discriminated unions on TS 2 to do this, and works quite well.
Example:
const INCREMENT: "increment" = "increment";
const DECREMENT: "decrement" = "decrement";
interface Increment {
type: typeof INCREMENT;
payload: {
inc: number;
};
}
interface Decrement {
type: typeof DECREMENT;
payload: {
dec: number;
};
}
interface State {
count: number;
}
type Actions = Increment | Decrement;
function reducer(state: State, action: Actions) {
switch (action.type) {
case INCREMENT: {
const { inc } = action.payload;
return { count: state.count + inc };
}
case DECREMENT: {
const { dec } = action.payload;
return { count: state.count + dec };
}
default:
return state;
}
}
Once TS figures out the action type is INCREMENT, it can infer the type of the payload. You don't need the Actions type either, you can just receive action: Increment | Decrement.
Re:Plottable.js – Flexible, interactive charts for the web
on Monday September 05, 2016 @04:34PM (#12432101)
Thanks, it does make more sense now.
Re:Plottable.js – Flexible, interactive charts for the web
on Monday September 05, 2016 @03:52PM (#12431932)
The odd thing is that they are not using three:
public connectorsEnabled(enabled: boolean): this;
public connectorsEnabled(): boolean;
public connectorsEnabled(enabled?: boolean): any {
if (enabled == null) {
return this._connectorsEnabled;
}
this._connectorsEnabled = enabled;
return this;
}
In that way, typescript will use the most specific overload to do type checking, so you'll get an actual boolean when doing connectorsEnabled(); instead of any.