Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit return undefined #200

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion spec/helpers/matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ beforeEach(() => {
const secondAsInt8Array: Int8Array | undefined = tryAsInt8Array(second);

if (firstAsInt8Array === undefined || secondAsInt8Array === undefined) {
return;
return undefined;
}

if (firstAsInt8Array.length !== secondAsInt8Array.length) {
Expand All @@ -112,6 +112,7 @@ function tryAsInt8Array(obj: any): Int8Array | undefined {
} else if (ArrayBuffer.isView(obj)) {
return new Int8Array(obj.buffer);
}
return undefined;
}

// eslint-disable-next-line @typescript-eslint/no-namespace
Expand Down
1 change: 1 addition & 0 deletions src/deserializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function defaultTypeResolver(
if (sourceObject.__type != null) {
return knownTypes.get(sourceObject.__type);
}
return undefined;
}

export type DeserializerFn<T, TD extends TypeDescriptor, Raw> = (
Expand Down
4 changes: 3 additions & 1 deletion src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class JsonObjectMetadata {
static getFromConstructor<T>(ctor: Serializable<T>): JsonObjectMetadata | undefined {
const prototype = ctor.prototype;
if (prototype == null) {
return;
return undefined;
}

let metadata: JsonObjectMetadata | undefined;
Expand All @@ -133,6 +133,8 @@ export class JsonObjectMetadata {
// we do not store the metadata here to not modify builtin prototype
return primitiveMeta;
}

return undefined;
}

static ensurePresentInPrototype(prototype: IndexedObject): JsonObjectMetadata {
Expand Down
4 changes: 4 additions & 0 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ export class TypedJSON<T> {
} catch (e) {
this.errorHandler(e);
}
return undefined;
}

toPlainArray(object: Array<T>, dimensions?: 1): Array<Object>;
Expand All @@ -489,6 +490,7 @@ export class TypedJSON<T> {
} catch (e) {
this.errorHandler(e);
}
return undefined;
}

toPlainSet(object: Set<T>): Array<Object> | undefined {
Expand All @@ -497,6 +499,7 @@ export class TypedJSON<T> {
} catch (e) {
this.errorHandler(e);
}
return undefined;
}

toPlainMap<K>(
Expand All @@ -511,6 +514,7 @@ export class TypedJSON<T> {
} catch (e) {
this.errorHandler(e);
}
return undefined;
}

/**
Expand Down
9 changes: 8 additions & 1 deletion tsconfig/tsconfig.app-strict.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"extends": "./tsconfig.app.json",
"compilerOptions": {
"noUnusedLocals": true
"noUnusedLocals": true,
"strict": true,
"allowJs": false,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"noImplicitReturns": true,
"preserveConstEnums": true
}
}