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;
interface JQuery {
autocomplete(options: any): JQuery;
datepicker(options: any): JQuery;
modal(arg : any) : JQuery; //From bootstrap
ejChart(arg : any) : JQuery // From syncfusion
}
declare module ReactRouter {
interface RouteHandlerProp {
key : string | number;
hub : any;
state : Object;
}
interface RouteProp {
hub? : any;
}
interface LinkProp {
className : string;
}
}
{
"compilerOptions": {
"jsx": "react",
"outDir": "./ts_modules",
"target": "es5",
"module": "commonjs"
},
"files": [
"./typings/tsd.d.ts",
"./Project/ts/Externals_shallow.d.ts",
"./Project/ts/components/UI/UIModules.ts",
"./Project/ts/area1/App.tsx",
"./Project/ts/area2/App.tsx"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment