557 * @param {*} entity
558 * @memberof ComponentAPI
559 */
560 static getBlackBoxDefinition(xspan: number, yspan: number, ports: Array<any>): LibraryEntryDefinition {561 // TODO: Deal with the ports later
562 // Create a fake definition for the blackbox
563
150 return hex;
151 }
152
153 render2DTarget(key: string | null, params: { [k: string]: any }) {154 if (key === null) {
155 key = this.__renderKeys[0];
156 }
120 return ports;
121 }
122
123 render2D(params: { [k: string]: any }, key: string) {124 const position = params.position;
125 const px = position[0];
126 const py = position[1];
106 };
107 }
108
109 getPorts(params: { [k: string]: any }) {110 const channelWidth = params.channelWidth;
111 const l = params.length;
112 const w = params.width;
486 * @returns
487 * @memberof Template
488 */
489 transformRender(params: { [key: string]: any }, render: paper.CompoundPath) {490 const mirrorX = params.mirrorByX;
491 const mirrorY = params.mirrorByY;
492 const px = params.position[0];
465 * @returns
466 * @memberof Template
467 */
468 getCenter(params: { [key: string]: any }): { x: any; y: any } {469 let newParams = params;
470
471 newParams.rotation = 0;
465 * @returns
466 * @memberof Template
467 */
468 getCenter(params: { [key: string]: any }): { x: any; y: any } {469 let newParams = params;
470
471 newParams.rotation = 0;
465 * @returns
466 * @memberof Template
467 */
468 getCenter(params: { [key: string]: any }): { x: any; y: any } {469 let newParams = params;
470
471 newParams.rotation = 0;
157 return rendered;
158 }
159
160 render2DTarget(key: string | null, params: { [k: string]: any }) {161 if (key === null) {
162 key = this.__renderKeys[0];
163 }
126 return ports;
127 }
128
129 render2D(params: { [k: string]: any }, key: string) {130 const position = params.position;
131 const px = position[0];
132 const py = position[1];
109 };
110 }
111
112 getPorts(params: { [k: string]: any }) {113 const l = params.length;
114 const w = params.width;
115
The any
type can sometimes leak into your codebase. TypeScript compiler skips the type checking of the any
typed variables, so it creates a potential safety hole, and source of bugs in your codebase. We recommend using unknown
or never
type variable.
In TypeScript, every type is assignable to any
. This makes any
a top type (also known as a universal supertype) of the type system.
The any
type is essentially an escape hatch from the type system. As developers, this gives us a ton of freedom: TypeScript lets us perform any operation we want on values of type any
without having to perform any checking beforehand.
The developers should not assign any
typed value to variables and properties, which can be hard to pick up on, especially from the external library; instead, developers can use the never
or unknown
type variable.
Bad Practice
const age: any = 'seventeen';
const ages: any[] = ['seventeen'];
const ages: Array<any> = ['seventeen'];
function greet(): any {}
function greet(): any[] {}
function greet(): Array<any> {}
function greet(): Array<Array<any>> {}
function greet(param: Array<any>): string {}
function greet(param: Array<any>): Array<any> {}
Recommended
const age: number = 17;
const ages: number[] = [17];
const ages: Array<number> = [17];
function greet(): string {}
function greet(): string[] {}
function greet(): Array<string> {}
function greet(): Array<Array<string>> {}
function greet(param: Array<string>): string {}
function greet(param: Array<string>): Array<string> {}