212 let conn_waypoints;
213 let lowestdist = 1000000000000000000000;
214 let p0: number[], p1: number[], sol: number;
215 const paths = (connection as any).getPaths();216 const waypoints = [];
217 for (const j in paths) {
218 conn_waypoints = paths[j];
140 return rendered;
141 }
142
143 render2DTarget(key: string, params: { [k: string]: any }) {144 const render = this.render2D(params, key);
145 render.fillColor!.alpha = 0.5;
146 return render;
114 return ports;
115 }
116
117 render2D(params: { [k: string]: any }, key: string) {118 const position = params.position;
119 const px = position[0];
120 const py = position[1];
97 };
98 }
99
100 getPorts(params: { [k: string]: any }) {101 const l = params.length;
102 const w = params.width;
103
181 throw new Error("Unknown render key found in IDT: " + key);
182 }
183
184 render2DTarget(key: string, params: { [k: string]: any }) {185 const ret = new paper.CompoundPath("");
186 const flow = this.render2D(params, "FLOW");
187 ret.addChild(flow);
174 }
175
176
177 render2D(params: { [k: string]: any }, key = "FLOW") {178 if (key === "FLOW") {
179 return this.__renderFlow(params);
180 }
129 return ports;
130 }
131
132 __renderFlow(params: { [k: string]: any }) {133 const position = params.position;
134 const px = position[0];
135 const py = position[1];
102 };
103 }
104
105 getPorts(params: { [k: string]: any }) {106 const position = params.position;
107 const px = position[0];
108 const py = position[1];
181 throw new Error("Unknown render key found in IDT: " + key);
182 }
183
184 render2DTarget(key: string, params: { [k: string]: any }) {185 const ret = new paper.CompoundPath("");
186 const flow = this.render2D(params, "FLOW");
187 ret.addChild(flow);
174 }
175
176
177 render2D(params: { [k: string]: any }, key = "FLOW") {178 if (key === "FLOW") {
179 return this.__renderFlow(params);
180 }
129 return ports;
130 }
131
132 __renderFlow(params: { [k: string]: any }) {133 const position = params.position;
134 const px = position[0];
135 const py = position[1];
102 };
103 }
104
105 getPorts(params: { [k: string]: any }) {106 const position = params.position;
107 const px = position[0];
108 const py = position[1];
181 throw new Error("Unknown render key found in IDT: " + key);
182 }
183
184 render2DTarget(key: string, params: { [k: string]: any }) {185 const ret = new paper.CompoundPath("");
186 const flow = this.render2D(params, "FLOW");
187 ret.addChild(flow);
174 }
175
176
177 render2D(params: { [k: string]: any }, key = "FLOW") {178 if (key === "FLOW") {
179 return this.__renderFlow(params);
180 }
129 return ports;
130 }
131
132 __renderFlow(params: { [k: string]: any }) {133 const position = params.position;
134 const px = position[0];
135 const py = position[1];
102 };
103 }
104
105 getPorts(params: { [k: string]: any }) {106 const position = params.position;
107 const px = position[0];
108 const py = position[1];
181 throw new Error("Unknown render key found in IDT: " + key);
182 }
183
184 render2DTarget(key: string, params: { [k: string]: any }) {185 const ret = new paper.CompoundPath("");
186 const flow = this.render2D(params, "FLOW");
187 ret.addChild(flow);
174 }
175
176
177 render2D(params: { [k: string]: any }, key = "FLOW") {178 if (key === "FLOW") {
179 return this.__renderFlow(params);
180 }
129 return ports;
130 }
131
132 __renderFlow(params: { [k: string]: any }) {133 const position = params.position;
134 const px = position[0];
135 const py = position[1];
102 };
103 }
104
105 getPorts(params: { [k: string]: any }) {106 const position = params.position;
107 const px = position[0];
108 const py = position[1];
139 return rendered;
140 }
141
142 render2DTarget(key: string, params: { [k: string]: any }) {143 const render = this.render2D(params, key);
144 render.fillColor!.alpha = 0.5;
145 return render;
114 return ports;
115 }
116
117 render2D(params: { [k: string]: any }, key: string) {118 const position = params.position;
119 const px = position[0];
120 const py = position[1];
97 };
98 }
99
100 getPorts(params: { [k: string]: any }) {101 const l = params.length;
102 const w = params.width;
103
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> {}