Question: I have a user table, the important columns are these.

```
id | logintime
---+-----------
1  | 2004-01-10
2  | 2006-02-10
3  | 2005-03-12
4  | 2006-10-23

```

I want to create a column that approximates time the user registered. To do this I want to take the lowest logintime on id and every id larger than itself. the logintime is the last time the id has logged into the site.

While it is not perfect, it gives a "latest possible date" for the registertime. Since id is autoincrement we know that the person with id 2 has registered before the person with id 3, so we approximate the registertime for id 2 with the logintime for id 3.

The result would be 

```
id | logintime  | Registertime
---+------------+-------------
1  | 2004-01-10 | 2004-01-10
2  | 2006-02-10 | 2005-03-12
3  | 2005-03-12 | 2005-03-12
4  | 2006-10-23 | 2006-10-23

```

Can I do this with one query? I think I can achieve it with a t-cursor, but that seems a bit too fancy for this, simple, task.

**Edit**: Clarified the question.

Answer: 
Still not one-liner, but something that can save you from explicitly maintaining parent method type:

```
declare let parentController: ParentComponentController;

class ChildComponentController {
    constructor(private parentMethod: typeof parentController.parentMethod) {}
}

```
The 'messy' snippet in the original post is the proper way to do this. This is what TypeScript best practices suggest. The fact is that `parentMethod` is a type, and wrapping it with some namespace like `ParentComponentController.parentMethod` doesn't do anything good.

It falls into the same case that the manual addresses in [*Needless Namespacing* section](https://www.typescriptlang.org/docs/handbook/namespaces-and-modules.html#needless-namespacing):

> 
> To reiterate why you shouldn’t try to namespace your module contents, the general idea of namespacing is to provide logical grouping of constructs and to prevent name collisions. Because the module file itself is already a logical grouping, and its top-level name is defined by the code that imports it, it’s unnecessary to use an additional module layer for exported objects.
> 
> 
> 

Despite being a namespace in in the broad sense of the word, expected namespaced type like `ParentComponentController.parentMethod` type falls within the same principle, Occam's razor. Namespaced type provides unnecessary complexity while having no advantages for the design.

The code can use `T`-prefixed Hungarian notation for custom types in addition to `I`-prefixed interfaces. This is conventional for other OO languages, C# in particular (where TypeScript heavily borrows from). It should be also noticed that [well-known *Coding guidelines* document](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines) refers to the usage of prefixes in TypeScript code itself and doesn't prohibit Hungarian notation anywhere else.

So basically the preferable way stays unchanged, with possible use of `TParentMethod` instead of obscure `parentMethod` type for readability:

```
declare type TParentMethod = (param1: number, param2: string) => boolean;

interface ICommonApi {
  parentMethod: TParentMethod;
}

class ParentComponentController implements ICommonApi {
  public parentMethod(param1: number, param2: string): boolean { ... }
}

class ChildComponentController {
  constructor(private parentMethod: TParentMethod) { }
  ...
}

```

If callback function type occurs only once or twice and doesn't require a separate type to be defined, it is appropriate to specify function signature explicitly:

```
class ChildComponentController {
  constructor(private parentMethod: (n: number, s: string) => boolean) { }
  ...
}

```

This provides the necessary level of redundancy to keep code type safe.