From 457192d9a16ef7727d9978728ab4adbaecbcd123 Mon Sep 17 00:00:00 2001 From: Andrew Kemp Date: Tue, 31 Mar 2020 16:06:39 -0400 Subject: [PATCH] Add @Strong flag --- src/decorators/index.ts | 3 ++- src/decorators/strong.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/decorators/strong.ts diff --git a/src/decorators/index.ts b/src/decorators/index.ts index 4d53467..08f75d4 100644 --- a/src/decorators/index.ts +++ b/src/decorators/index.ts @@ -1,3 +1,4 @@ export * from './exclude'; export * from './memoize'; -export * from './pluck'; \ No newline at end of file +export * from './pluck'; +export * from './strong'; \ No newline at end of file diff --git a/src/decorators/strong.ts b/src/decorators/strong.ts new file mode 100644 index 0000000..cb62a75 --- /dev/null +++ b/src/decorators/strong.ts @@ -0,0 +1,9 @@ +export const STRONG_CLASS_KEY = 'serde:strong_class'; + +export function Strong(): Function { + return function(target: any) { + if (!Reflect.hasMetadata(STRONG_CLASS_KEY, target)) { + Reflect.defineMetadata(STRONG_CLASS_KEY, 'is_strong_typed', target); + } + } +} \ No newline at end of file