Skip to content

Commit

Permalink
πŸ”„ [chore]: Add playground file for easy core debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
brunotot committed Sep 9, 2023
1 parent 996e96e commit dc1d48d
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"build": "tsc --build",
"docs": "npm i --force --silent && typedoc",
"build-docs": "npm run clean && npm run build --silent && npm run docs",
"core/playground": "npm run playground --prefix=packages/core",
"core/test": "npm run test --prefix=packages/core",
"core/build": "npm run build --prefix=packages/core",
"core/deploy:minor": "npm run deploy:minor --prefix=packages/core",
Expand Down
25 changes: 25 additions & 0 deletions packages/core/dev/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { DecoratorContextMetadata } from "tdv-core";

declare global {
interface SymbolConstructor {
readonly metadata: unique symbol;
}

interface ClassFieldDecoratorContext<This = unknown, Value = unknown> {
readonly metadata: DecoratorContextMetadata;
}

interface ClassMethodDecoratorContext<
This = unknown,
Value extends (this: This, ...args: any) => any = (
this: This,
...args: any
) => any
> {
readonly metadata: DecoratorContextMetadata;
}

interface ClassGetterDecoratorContext<This = unknown, Value = unknown> {
readonly metadata: DecoratorContextMetadata;
}
}
10 changes: 10 additions & 0 deletions packages/core/dev/playground.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import EntityProcessor from "../src/model/processor/EntityProcessor";
import validators from "../validators/index";

class TestClass {
@validators.string.Required()
username!: string;
}

const processor = new EntityProcessor(TestClass);
console.log(processor.validate({}));
3 changes: 2 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"deploy:major": "bash ../../scripts/deploy.sh core major",
"deploy:patch": "bash ../../scripts/deploy.sh core patch",
"test": "bash ../../scripts/test.sh core",
"playground": "ts-node ../../dev/core/index.ts"
"playground": "ts-node ./dev/playground.ts"
},
"repository": {
"type": "git",
Expand All @@ -43,6 +43,7 @@
"@types/node": "^20.3.1",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.10",
"esm": "^3.2.25",
"jest": "^29.5.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
Expand Down
5 changes: 5 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@
"allowJs": true,
"strict": true,
"isolatedModules": false
},
"ts-node": {
"compilerOptions": {
"module": "commonjs"
}
}
}

0 comments on commit dc1d48d

Please sign in to comment.