mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-04-27 19:26:54 -05:00
Switch to using import type
We were previously using `type Foo = import('bar').Foo` which works
actually equally well, because sucrase didn't support `import type`,
but now it does!
This commit is contained in:
parent
188111c316
commit
a315c93836
2
build
2
build
|
|
@ -61,7 +61,7 @@ try {
|
||||||
var sucraseVersion = require('sucrase').getVersion().split('.');
|
var sucraseVersion = require('sucrase').getVersion().split('.');
|
||||||
if (
|
if (
|
||||||
parseInt(sucraseVersion[0]) < 3 ||
|
parseInt(sucraseVersion[0]) < 3 ||
|
||||||
(parseInt(sucraseVersion[0]) === 3 && parseInt(sucraseVersion[1]) < 12)
|
(parseInt(sucraseVersion[0]) === 3 && parseInt(sucraseVersion[1]) < 15)
|
||||||
) {
|
) {
|
||||||
throw new Error("Sucrase version too old");
|
throw new Error("Sucrase version too old");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"probe-image-size": "^5.0.0",
|
"probe-image-size": "^5.0.0",
|
||||||
"sockjs": "0.3.20",
|
"sockjs": "0.3.20",
|
||||||
"sucrase": "^3.13.0"
|
"sucrase": "^3.15.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"cloud-env": "^0.2.3",
|
"cloud-env": "^0.2.3",
|
||||||
|
|
@ -74,6 +74,6 @@
|
||||||
"husky": "^4.2.3",
|
"husky": "^4.2.3",
|
||||||
"mocha": "^7.1.1",
|
"mocha": "^7.1.1",
|
||||||
"smogon": "^1.1.1",
|
"smogon": "^1.1.1",
|
||||||
"typescript": "^3.8.3"
|
"typescript": "^3.9.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
/* eslint no-else-return: "error" */
|
/* eslint no-else-return: "error" */
|
||||||
import {Utils} from '../../lib/utils';
|
import {Utils} from '../../lib/utils';
|
||||||
type UserSettings = import('../users').User['settings'];
|
import type {UserSettings} from '../users';
|
||||||
|
|
||||||
const avatarTable = new Set([
|
const avatarTable = new Set([
|
||||||
'aaron',
|
'aaron',
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,7 @@ To reload chat commands:
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
type RoomPermission = import('./user-groups').RoomPermission;
|
import type {RoomPermission, GlobalPermission} from './user-groups';
|
||||||
type GlobalPermission = import('./user-groups').GlobalPermission;
|
|
||||||
|
|
||||||
export type PageHandler = (this: PageContext, query: string[], user: User, connection: Connection)
|
export type PageHandler = (this: PageContext, query: string[], user: User, connection: Connection)
|
||||||
=> Promise<string | null | void> | string | null | void;
|
=> Promise<string | null | void> | string | null | void;
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as defaults from '../config/config-example';
|
import * as defaults from '../config/config-example';
|
||||||
type GroupInfo = import('./user-groups').GroupInfo;
|
import type {GroupInfo, EffectiveGroupSymbol} from './user-groups';
|
||||||
type EffectiveGroupSymbol = import('./user-groups').EffectiveGroupSymbol;
|
|
||||||
|
|
||||||
export type ConfigType = typeof defaults & {
|
export type ConfigType = typeof defaults & {
|
||||||
groups: {[symbol: string]: GroupInfo},
|
groups: {[symbol: string]: GroupInfo},
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ const LadderStore: typeof LadderStoreT = (typeof Config === 'object' && Config.r
|
||||||
const SECONDS = 1000;
|
const SECONDS = 1000;
|
||||||
const PERIODIC_MATCH_INTERVAL = 60 * SECONDS;
|
const PERIODIC_MATCH_INTERVAL = 60 * SECONDS;
|
||||||
|
|
||||||
type ChallengeType = import('./room-battle').ChallengeType;
|
import type {ChallengeType} from './room-battle';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This represents a user's search for a battle under a format.
|
* This represents a user's search for a battle under a format.
|
||||||
|
|
|
||||||
|
|
@ -118,12 +118,10 @@ export interface RoomSettings {
|
||||||
isMultichannel?: boolean;
|
isMultichannel?: boolean;
|
||||||
}
|
}
|
||||||
export type Room = GameRoom | ChatRoom;
|
export type Room = GameRoom | ChatRoom;
|
||||||
type Poll = import('./chat-plugins/poll').Poll;
|
import type {Poll} from './chat-plugins/poll';
|
||||||
type Announcement = import('./chat-plugins/announcements').Announcement;
|
import type {Announcement} from './chat-plugins/announcements';
|
||||||
type RoomEvent = import('./chat-plugins/room-events').RoomEvent;
|
import type {RoomEvent, RoomEventAlias, RoomEventCategory} from './chat-plugins/room-events';
|
||||||
type RoomEventAlias = import('./chat-plugins/room-events').RoomEventAlias;
|
import type {Tournament} from './tournaments/index';
|
||||||
type RoomEventCategory = import('./chat-plugins/room-events').RoomEventCategory;
|
|
||||||
type Tournament = import('./tournaments/index').Tournament;
|
|
||||||
|
|
||||||
export abstract class BasicRoom {
|
export abstract class BasicRoom {
|
||||||
roomid: RoomID;
|
roomid: RoomID;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ interface ElimTree {
|
||||||
nextLayerLeafNodes: ElimNode[];
|
nextLayerLeafNodes: ElimNode[];
|
||||||
}
|
}
|
||||||
|
|
||||||
type TournamentPlayer = import('./index').TournamentPlayer;
|
import type {TournamentPlayer} from './index';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* There are two types of elim nodes, player nodes
|
* There are two types of elim nodes, player nodes
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ interface Match {
|
||||||
result?: string;
|
result?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type TournamentPlayer = import('./index').TournamentPlayer;
|
import type {TournamentPlayer} from './index';
|
||||||
|
|
||||||
export class RoundRobin {
|
export class RoundRobin {
|
||||||
readonly name: string;
|
readonly name: string;
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ const MINUTES = 60 * 1000;
|
||||||
const IDLE_TIMER = 60 * MINUTES;
|
const IDLE_TIMER = 60 * MINUTES;
|
||||||
const STAFF_IDLE_TIMER = 30 * MINUTES;
|
const STAFF_IDLE_TIMER = 30 * MINUTES;
|
||||||
|
|
||||||
type StreamWorker = import('../lib/process-manager').StreamWorker;
|
import type {StreamWorker} from '../lib/process-manager';
|
||||||
|
|
||||||
/*********************************************************
|
/*********************************************************
|
||||||
* Utility functions
|
* Utility functions
|
||||||
|
|
@ -305,6 +305,13 @@ export class Connection {
|
||||||
|
|
||||||
type ChatQueueEntry = [string, RoomID, Connection];
|
type ChatQueueEntry = [string, RoomID, Connection];
|
||||||
|
|
||||||
|
export interface UserSettings {
|
||||||
|
blockChallenges: boolean;
|
||||||
|
blockPMs: boolean | AuthLevel;
|
||||||
|
ignoreTickets: boolean;
|
||||||
|
hideBattlesFromTrainerCard: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
// User
|
// User
|
||||||
export class User extends Chat.MessageContext {
|
export class User extends Chat.MessageContext {
|
||||||
readonly user: User;
|
readonly user: User;
|
||||||
|
|
@ -341,12 +348,7 @@ export class User extends Chat.MessageContext {
|
||||||
lastMatch: string;
|
lastMatch: string;
|
||||||
forcedPublic: string | null;
|
forcedPublic: string | null;
|
||||||
|
|
||||||
settings: {
|
settings: UserSettings;
|
||||||
blockChallenges: boolean,
|
|
||||||
blockPMs: boolean | AuthLevel,
|
|
||||||
ignoreTickets: boolean,
|
|
||||||
hideBattlesFromTrainerCard: boolean,
|
|
||||||
};
|
|
||||||
|
|
||||||
battleSettings: {
|
battleSettings: {
|
||||||
team: string,
|
team: string,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user