I'm currently pretty annoyed at TypeScript and TC39 for default exports
being a mess.
The goal here is to be able to type
import Dex from './dex';
instead of any of
import Dex = require('./dex');
import {Dex} from './dex';
import * as Dex from './dex';
This part involves a significant amount of struggle.
First, you can't automatically package up all your exports as your
default export. This leads to extremely un-DRY code, like in sim/index:
export {
Pokemon,
Side,
Battle,
PRNG,
Dex,
TeamValidator,
BattleStream,
};
export const Sim = {
Pokemon,
Side,
Battle,
PRNG,
Dex,
TeamValidator,
BattleStream,
};
(Both of these exports would be entirely unnecessary if you could just
automatically declare the file's exports as a default namespace.)
Second, a default export can't easily be a namespace. And TypeScript
doesn't allow types to exist in objects. Take the example from earlier:
export const Sim = {
Pokemon,
};
If we were to try to use it:
import Sim from './sim';
let pokemon: Sim.Pokemon;
you'll get this error:
Cannot find namespace 'Sim'. ts(2503)
You can, of course, fix this by making Sim a namespace:
const PokemonT = Pokemon;
type PokemonT = Pokemon;
export namespace Sim {
export const Pokemon = PokemonT;
type Pokemon = PokemonT;
}
But this quickly gets ridiculous the more classes you try to export.
You'd think there'd be a better way to do this. But I, at least,
haven't found one.
This is mostly a TypeScript refactor, but it does come with several
renames:
Dnsbl -> IPTools
Dnsbl.query -> IPTools.queryDnsbl
Dnsbl.reverse -> IPTools.getHost
Also move mods/ to data/mods/
This makes PS more monorepo-like. The intent is to further separate
the sim and the server code, but without fully committing to splitting
the repository itself.
We now support `./pokemon-showdown start` in addition to
`./pokemon-showdown`. I'm not clear which I want to be the default
yet.