String or Number values in Typescript
<p>An example of what I am trying to achieve:</p>

<pre><code>class Test {
    private _folderId: number;
    private _pageId: number;
    private _folderName: string;
    private _pageName: string;

    constructor(pageId: string | number, folderId: string | number){
        this._folderId = (!isNaN(+folderId)) ? folderId : undefined;
        this._pageId = (!isNaN(+pageId)) ? pageId : undefined;
        this._folderName = (isNaN(+folderId)) ? folderId : undefined;
        this._pageName = (isNaN(+pageId)) ? pageId : undefined;
    }
}
</code></pre>

<p>Unfortunately this throws compiler error: </p>

<pre><code>TS2322:Type 'string | number' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'.
</code></pre>

<p>and so on (similar error for each var).</p>

<p>Is there any way around it? At the moment only thing I can do is to set page and folder id to type any...</p>