choco
choco
TTCTheo's Typesafe Cult
Created by choco on 4/29/2024 in #questions
Typescript "implements"?
Hello, guys, i have two interfaces that have same name fields but different implementation, but i want when i create new interface without all fields from A in new interface, it should throws an error any help please?
interface A{
a: boolean;
b: boolean;
}
interface B{
a: function;
b:function
}
interface A{
a: boolean;
b: boolean;
}
interface B{
a: function;
b:function
}
5 replies
TTCTheo's Typesafe Cult
Created by choco on 3/28/2024 in #questions
Maybe i am dumb, but how can i detect if dynamically component has loaded or loading.js have closed?
Can not figure it out. By loading.js i mean loading.tsx in app folder.
6 replies
TTCTheo's Typesafe Cult
Created by choco on 2/9/2024 in #questions
Dumb plain js question
I am stuck on this about month or so, i want to disable scroll when scrollY equals my needed y. The problem is, before scrolling is disabled, if user will scroll little too fast, it would be scrolled some space before scrolling will be finally disabled, i am using Next.js but disable scroll with plain js.
7 replies
TTCTheo's Typesafe Cult
Created by choco on 12/25/2023 in #questions
Scroll question
Hello guys, could you please help me. I have a long single page app (Next.js). And some components a horizontal scrollable, i really wanna do a thing when vertical scroll for a page blocks and you can scroll only horizontally in those components. I tried to make overflow : hidden, but you can scroll some space down before scroll disappears.
5 replies
TTCTheo's Typesafe Cult
Created by choco on 12/22/2023 in #questions
Genius ask the Java problem question in Typescript relate server
I currently learning JAVA, so i rewriting my old JS algorithm from leetcode to practice JAVA. the problem is this code right below make "Time Limit Exceeded" error.
class Solution {
public int mySqrt(int x) {
long left = 0;
long right = x;
while(left <= right){
long mid = left + (right - left) / 2;
long doub = mid * mid;
if(doub == x){
return (int) mid;
}
if(doub > x){
left = mid - 1;
}
if(doub < x){
right = mid + 1;
}
}
return (int) right;
}
}
class Solution {
public int mySqrt(int x) {
long left = 0;
long right = x;
while(left <= right){
long mid = left + (right - left) / 2;
long doub = mid * mid;
if(doub == x){
return (int) mid;
}
if(doub > x){
left = mid - 1;
}
if(doub < x){
right = mid + 1;
}
}
return (int) right;
}
}
but when you use same code but update else if else instead of just if guards it works fine.
class Solution {
public int mySqrt(int x) {
long left = 0;
long right = x;

while (left <= right) {
long mid = left + (right - left) / 2;
long doub = mid * mid;

if (doub == x) {
return (int) mid;
} else if (doub > x) {
right = mid - 1;
} else {
left = mid + 1;
}
}
return (int) right;
}
}
class Solution {
public int mySqrt(int x) {
long left = 0;
long right = x;

while (left <= right) {
long mid = left + (right - left) / 2;
long doub = mid * mid;

if (doub == x) {
return (int) mid;
} else if (doub > x) {
right = mid - 1;
} else {
left = mid + 1;
}
}
return (int) right;
}
}
i really can not understand why, because i tried to add "continue" at the end of every if statement and the same error occur when is should skip in that logic cicle. Thanks in advance
7 replies
TTCTheo's Typesafe Cult
Created by choco on 9/29/2023 in #questions
Does somebody know Rust and JAVA?
What code is more readable? Java or Rust?
9 replies