Skip to content

Instantly share code, notes, and snippets.

@flq
Last active October 10, 2015 23:45
Show Gist options
  • Save flq/7e3dc1a86a1e2fb0baeb to your computer and use it in GitHub Desktop.
Save flq/7e3dc1a86a1e2fb0baeb to your computer and use it in GitHub Desktop.
Gists for the blog post porting react app to tyescript
import {Url,parse} from "url";
interface MvcUrl extends Url {
controller : string;
}
function extractFirstPart(url : Url) : string {
var url2 = url.path.substring(1);
if (url2.indexOf('/') == -1)
return url2;
return url2.substring(0, url2.indexOf('/'))
}
var theUrl = <MvcUrl>parse(window.location.href);
theUrl.controller = extractFirstPart(theUrl);
export = theUrl;
{
"compilerOptions": {
"jsx": "react",
"outDir": "./ts_modules",
"target": "es5",
"module": "commonjs"
},
"files": [
"./typings/tsd.d.ts",
"./Trekspace/ts/Externals_shallow.d.ts",
"./Trekspace/ts/components/UI/UIModules.ts",
"./Trekspace/ts/people/App.tsx",
"./Trekspace/ts/areas/App.tsx"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment