浏览代码

don't use boxed primitives

Alexander Rose 6 年之前
父节点
当前提交
a5a34f39e0

+ 1 - 1
src/mol-app/component/parameter/boolean.tsx

@@ -9,7 +9,7 @@ import { ParamDefinition as PD } from '../../../mol-util/param-definition';
 
 export interface BooleanParamComponentProps {
     label: string
-    param: PD.Boolean
+    param: PD.BooleanParam
     value: boolean
     onChange(v: boolean): void
 }

+ 1 - 1
src/mol-io/reader/mol2/parser.ts

@@ -84,7 +84,7 @@ function handleMolecule(state: State) {
     molecule.mol_comment = getTokenString(tokenizer)
 }
 
-function isStatus_bit(aString: String): Boolean {
+function isStatus_bit(aString: string): boolean {
     if (aString.includes('DSPMOD') || aString.includes('TYPECOL') || aString.includes('CAP')
         || aString.includes('BACKBONE') || aString.includes('DICT') || aString.includes('ESSENTIAL')
         || aString.includes('WATER') || aString.includes('DIRECT')) {

+ 1 - 1
src/mol-plugin/ui/controls/parameters.tsx

@@ -97,7 +97,7 @@ export abstract class SimpleParam<P extends PD.Any> extends React.PureComponent<
     }
 }
 
-export class BoolControl extends SimpleParam<PD.Boolean> {
+export class BoolControl extends SimpleParam<PD.BooleanParam> {
     onClick = (e: React.MouseEvent<HTMLButtonElement>) => { this.update(!this.props.value); e.currentTarget.blur(); }
     renderControl() {
         return <button onClick={this.onClick} disabled={this.props.isDisabled}>

+ 2 - 2
src/mol-util/console-logger.ts

@@ -25,7 +25,7 @@ export namespace ConsoleLogger {
         console.log(`[${tag}] ${msg}`);
     }
 
-    export function logId(guid: string | String, tag: string, msg: string) {
+    export function logId(guid: string, tag: string, msg: string) {
         console.log(`[${guid}][${tag}] ${msg}`);
     }
 
@@ -38,7 +38,7 @@ export namespace ConsoleLogger {
         console.error(`[Warn] (${ctx}) ${e}`);
     }
 
-    export function errorId(guid: string | String, e: any) {
+    export function errorId(guid: string, e: any) {
         console.error(`[${guid}][Error] ${e}`);
         if (e.stack) console.error(e.stack);
     }

+ 4 - 4
src/mol-util/param-definition.ts

@@ -76,11 +76,11 @@ export namespace ParamDefinition {
         return setInfo<MultiSelect<E, T>>({ type: 'multi-select', defaultValue, options }, info)
     }
 
-    export interface Boolean extends Base<boolean> {
+    export interface BooleanParam extends Base<boolean> {
         type: 'boolean'
     }
-    export function Boolean(defaultValue: boolean, info?: Info): Boolean {
-        return setInfo<Boolean>({ type: 'boolean', defaultValue }, info)
+    export function Boolean(defaultValue: boolean, info?: Info): BooleanParam {
+        return setInfo<BooleanParam>({ type: 'boolean', defaultValue }, info)
     }
 
     export interface Text<T extends string = string> extends Base<T> {
@@ -237,7 +237,7 @@ export namespace ParamDefinition {
     }
 
     export type Any =
-        | Value<any> | Select<any> | MultiSelect<any> | Boolean | Text | Color | Vec3 | Numeric | FileParam | Interval | LineGraph
+        | Value<any> | Select<any> | MultiSelect<any> | BooleanParam | Text | Color | Vec3 | Numeric | FileParam | Interval | LineGraph
         | ColorScale<any> | Group<any> | Mapped<any> | Converted<any, any> | Conditioned<any, any, any> | ScriptExpression | ObjectList
 
     export type Params = { [k: string]: Any }

+ 7 - 0
tslint.json

@@ -6,6 +6,7 @@
         ],
         "arrow-parens": false,
         "no-var-keyword": true,
+        "no-construct": true,
         "ordered-imports": [false],
         "trailing-comma": [false],
         "class-name": false,
@@ -17,6 +18,12 @@
             true,
             "spaces"
         ],
+        "ban-types": [
+            true,
+            ["String", "Use primitive 'string' instead."],
+            ["Boolean", "Use primitive 'boolean' instead."],
+            ["Number", "Use primitive 'number' instead."]
+        ],
         "no-eval": true,
         "no-internal-module": true,
         "no-trailing-whitespace": true,