Typescript class: “Overload signature is not compatible with function implementation”

You get that compilation error because the signature of the implementation function does not satisfy the empty constructor you declared. As you want to have the default constructor, it should be: class MyItem { public name: string; public surname: string; public category: string; public address: string; constructor(); constructor(name:string, surname: string, category: string, address?: string); constructor(name?: … Read more

Get companion object of class by given generic type Scala

A gist by Miles Sabin may give you a hint: trait Companion[T] { type C def apply() : C } object Companion { implicit def companion[T](implicit comp : Companion[T]) = comp() } object TestCompanion { trait Foo object Foo { def bar = “wibble” // Per-companion boilerplate for access via implicit resolution implicit def companion … Read more

phpunit: How do I pass values between tests?

The setUp() method is always called before tests, so even if you set up a dependency between two tests, any variables set in setUp() will be overwritten. The way PHPUnit data passing works is from the return value of one test to the parameter of the other: class JsonRpcBitcoinTest extends PHPUnit_Framework_TestCase { public function setUp() … Read more

Create an instance of a React class from a string

This will not work: var Home = React.createClass({ … }); var Component = “Home”; React.render(<Component />, …); However, this will: var Home = React.createClass({ … }); var Component = Home; React.render(<Component />, …); So you simply need to find a way to map between the string “Home” and the component class Home. A simple object … Read more

OOP Terminology: class, attribute, property, field, data member

“Fields”, “class variables”, and “attributes” are more-or-less the same – a low-level storage slot attached to an object. Each language’s documentation might use a different term consistently, but most actual programmers use them interchangeably. (However, this also means some of the terms can be ambiguous, like “class variable” – which can be interpreted as “a … Read more

Declare dynamically added class properties in TypeScript

The problem is that you’re adding the new properties at runtime and the compiler has no way of knowing that. If you know the property names in advance then you can do this: type Json = { foo: string; bar: string; } … const myInstance = new MyClass(someJson) as MyClass & Json; console.log(myInstance.foo) // no … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)