Skip to content

Commit

Permalink
adding strict null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mhoeger committed Jun 12, 2018
1 parent 3f3f30b commit 7b9a6f4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
17 changes: 8 additions & 9 deletions src/Context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import LogLevel = rpc.RpcLog.Level;
export interface IContext {
invocationId: string;
executionContext: IExecutionContext;
bindings: IDict;
bindingData: IDict;
bindings: IDict<any>;
bindingData: IDict<any>;
log: ILogger;
req?: Request;
res?: Response;
Expand All @@ -19,7 +19,7 @@ export interface IContext {
export function CreateContextAndInputs(info: FunctionInfo, request: rpc.IInvocationRequest, logCallback: ILogCallback, callback: IResultCallback) {
let context = new Context(info, request, logCallback, callback);

let bindings: IDict = {};
let bindings: IDict<any> = {};
let inputs: any[] = [];
let httpInput: HttpRequest | undefined;
for (let binding of <rpc.IParameterBinding[]>request.inputData) {
Expand Down Expand Up @@ -49,8 +49,8 @@ export function CreateContextAndInputs(info: FunctionInfo, request: rpc.IInvocat
class Context implements IContext {
invocationId: string;
executionContext: IExecutionContext;
bindings: IDict;
bindingData: IDict;
bindings: IDict<any>;
bindingData: IDict<any>;
log: ILogger;
req?: Request;
res?: Response;
Expand Down Expand Up @@ -109,7 +109,7 @@ function getLogger(invocationId: string, functionName: string, log: ILogCallback

export interface IInvocationResult {
return: any;
bindings: IDict;
bindings: IDict<any>;
}

export interface ILog {
Expand Down Expand Up @@ -141,7 +141,6 @@ export interface IExecutionContext {
functionDirectory: string;
}

export interface IDict {
[key: string]: any
export interface IDict<T> {
[key: string]: T
}

14 changes: 7 additions & 7 deletions src/Converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export function fromRpcHttp(rpcHttp: rpc.IRpcHttp) {
method: <string>rpcHttp.method,
url: <string>rpcHttp.url,
originalUrl: <string>rpcHttp.url,
headers: rpcHttp.headers,
query: rpcHttp.query,
params: rpcHttp.params,
body: fromTypedData(rpcHttp.body),
rawBody: fromTypedData(rpcHttp.rawBody, false),
headers: <IDict<string>>rpcHttp.headers,
query: <IDict<string>>rpcHttp.query,
params: <IDict<string>>rpcHttp.params,
body: fromTypedData(<rpc.ITypedData>rpcHttp.body),
rawBody: fromTypedData(<rpc.ITypedData>rpcHttp.rawBody, false),
};

return httpContext;
Expand Down Expand Up @@ -71,8 +71,8 @@ export function toTypedData(inputObject): rpc.ITypedData {
}
}

export function getNormalizedBindingData(request: rpc.IInvocationRequest): IDict {
let bindingData: IDict = {
export function getNormalizedBindingData(request: rpc.IInvocationRequest): IDict<any> {
let bindingData: IDict<any> = {
invocationId: request.invocationId
};
// node binding data is camel cased due to language convention
Expand Down
5 changes: 3 additions & 2 deletions src/FunctionLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ export class FunctionLoader implements IFunctionLoader {
}} = {};

load(functionId: string, metadata: rpc.IRpcFunctionMetadata): void {
let scriptFilePath = <string>metadata.scriptFile;
let scriptFilePath = <string>(metadata && metadata.scriptFile);
let script = require(scriptFilePath);
let userFunction = getEntryPoint(script, metadata.entryPoint);
let entryPoint = <string>(metadata && metadata.entryPoint);
let userFunction = getEntryPoint(script, entryPoint);
if(!isFunction(userFunction)) {
throw "The resolved entry point is not a function and cannot be invoked by the functions runtime. Make sure the function has been correctly exported.";
}
Expand Down
2 changes: 1 addition & 1 deletion src/http/Request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class HttpRequest {
method: string = "";
url: string = "";
originalUrl: string = "";
headers?: {[key:string]: any};
headers?: {[key:string]: string};
query?: {[key:string]: string};
params?: {[key:string]: string};
body?: any;
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"target": "es6",
"noImplicitAny": false,
"strict": true,
"strictNullChecks": false,
"outDir": "dist/src",
"sourceMap": true
},
Expand Down

0 comments on commit 7b9a6f4

Please sign in to comment.