mirror of https://github.com/zulip/zulip.git
typescript: Fix violations of new typescript rules.
This commit is contained in:
parent
02cb85a8a9
commit
90478fc4b2
|
@ -4,9 +4,9 @@ import * as _ from 'underscore';
|
|||
* Implementation detail of the Dict class. `key` is `k` converted to a string,
|
||||
* in lowercase if the `fold_case` option is enabled.
|
||||
*/
|
||||
type KeyValue<K, V> = { k: K, v: V }
|
||||
type KeyValue<K, V> = { k: K; v: V }
|
||||
type Items<K, V> = {
|
||||
[key: string]: KeyValue<K, V>
|
||||
[key: string]: KeyValue<K, V>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,16 +64,6 @@ export class Dict<K, V> {
|
|||
return dict;
|
||||
}
|
||||
|
||||
// Handle case-folding of keys and the empty string.
|
||||
private _munge(key: K): string | undefined {
|
||||
if (key === undefined) {
|
||||
blueslip.error("Tried to call a Dict method with an undefined key.");
|
||||
return;
|
||||
}
|
||||
const str_key = ':' + key.toString();
|
||||
return this._fold_case ? str_key.toLowerCase() : str_key;
|
||||
}
|
||||
|
||||
clone(): Dict<K, V> {
|
||||
const dict = new Dict<K, V>({fold_case: this._fold_case});
|
||||
dict._items = { ...this._items };
|
||||
|
@ -83,7 +73,7 @@ export class Dict<K, V> {
|
|||
get(key: K): V | undefined {
|
||||
const mapping = this._items[this._munge(key)];
|
||||
if (mapping === undefined) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
return mapping.v;
|
||||
}
|
||||
|
@ -123,7 +113,7 @@ export class Dict<K, V> {
|
|||
|
||||
items(): [K, V][] {
|
||||
return _.map(_.values(this._items),
|
||||
(mapping: KeyValue<K, V>): [K, V] => [mapping.k, mapping.v]);
|
||||
(mapping: KeyValue<K, V>): [K, V] => [mapping.k, mapping.v]);
|
||||
}
|
||||
|
||||
num_items(): number {
|
||||
|
@ -134,11 +124,21 @@ export class Dict<K, V> {
|
|||
return _.isEmpty(this._items);
|
||||
}
|
||||
|
||||
each(f: (v: V, k?: K) => void) {
|
||||
each(f: (v: V, k?: K) => void): void {
|
||||
_.each(this._items, (mapping: KeyValue<K, V>) => f(mapping.v, mapping.k));
|
||||
}
|
||||
|
||||
clear() {
|
||||
clear(): void {
|
||||
this._items = {};
|
||||
}
|
||||
|
||||
// Handle case-folding of keys and the empty string.
|
||||
private _munge(key: K): string | undefined {
|
||||
if (key === undefined) {
|
||||
blueslip.error("Tried to call a Dict method with an undefined key.");
|
||||
return undefined;
|
||||
}
|
||||
const str_key = ':' + key.toString();
|
||||
return this._fold_case ? str_key.toLowerCase() : str_key;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
import { basename } from 'path';
|
||||
|
||||
interface Loader {
|
||||
test: string;
|
||||
use: string;
|
||||
}
|
||||
|
||||
/* Return imports-loader format to the config
|
||||
For example:
|
||||
[
|
||||
|
@ -7,11 +12,11 @@ import { basename } from 'path';
|
|||
{path: './foler/my_module.js', args: '?this=>window'},
|
||||
]
|
||||
*/
|
||||
interface importLoaderOptions {
|
||||
path: string;
|
||||
args: string;
|
||||
interface ImportLoaderOptions {
|
||||
path: string;
|
||||
args: string;
|
||||
}
|
||||
function getImportLoaders(optionsArr:Array<importLoaderOptions>) {
|
||||
function getImportLoaders(optionsArr: ImportLoaderOptions[]): Loader[] {
|
||||
const importsLoaders = [];
|
||||
for (var loaderEntry of optionsArr) {
|
||||
importsLoaders.push({
|
||||
|
@ -34,11 +39,11 @@ function getImportLoaders(optionsArr:Array<importLoaderOptions>) {
|
|||
{path: './folder/my_module.js', name: ['name1', 'name2']}
|
||||
]
|
||||
*/
|
||||
interface exportLoaderOptions {
|
||||
path: string;
|
||||
name?: string | Array<string>;
|
||||
interface ExportLoaderOptions {
|
||||
path: string;
|
||||
name?: string | string[];
|
||||
}
|
||||
function getExposeLoaders(optionsArr:Array<exportLoaderOptions>) {
|
||||
function getExposeLoaders(optionsArr: ExportLoaderOptions[]): Loader[] {
|
||||
const exposeLoaders = [];
|
||||
for (var loaderEntry of optionsArr) {
|
||||
const path = loaderEntry.path;
|
||||
|
|
|
@ -2,12 +2,12 @@ import { resolve } from 'path';
|
|||
import * as BundleTracker from 'webpack-bundle-tracker';
|
||||
import * as webpack from 'webpack';
|
||||
import { getExposeLoaders, getImportLoaders } from './webpack-helpers';
|
||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
||||
import * as MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
||||
|
||||
const assets = require('./webpack.assets.json');
|
||||
|
||||
// Adds on css-hot-loader in dev mode
|
||||
function getHotCSS(bundle:any[], isProd:boolean) {
|
||||
function getHotCSS(bundle: any[], isProd: boolean): any[] {
|
||||
if (isProd) {
|
||||
return bundle;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ function getHotCSS(bundle:any[], isProd:boolean) {
|
|||
].concat(bundle);
|
||||
}
|
||||
|
||||
export default (env?: string) : webpack.Configuration => {
|
||||
export default (env?: string): webpack.Configuration => {
|
||||
const production: boolean = env === "production";
|
||||
const config: webpack.Configuration = {
|
||||
mode: production ? "production" : "development",
|
||||
|
|
Loading…
Reference in New Issue