Skip to content

Instantly share code, notes, and snippets.

@nabeix
nabeix / test.ts
Last active October 2, 2019 12:12
typescript-extends-builtin-array
// BAD
class A extends Array {
constructor(array: number[]) {
super();
console.log(array); // called twice with other array 1st => [1, 2, 3], 2nd(not an array type) => 3
array.forEach((a, i) => this[i] = a); // => Uncaught TypeError: array.forEach is not a function
}
}
const a = new A([1,2,3]);
@nabeix
nabeix / generics-ignore-extend-types.ts
Last active October 16, 2017 10:08
TypeScript Generics ignore extend types
abstract class A<T1, T2> {
}
class B extends A<string, number> {
}
interface AClassStatic<T1, T2, T3 extends A<T1, T2>> {
new (): T3
@nabeix
nabeix / WebViewJSInterfaceMainActivity.java
Last active September 24, 2022 10:38
Check available types of Android WebView JavascriptInterface
package net.nabeix.javascriptinterfacetest;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
public class MainActivity extends AppCompatActivity {