-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fix of decorators from different modules (issue #27)
- new! literal arguments of decorators captured -> Decorator.getArguments(): Array<any> - decorator can be CallExpression`@decorator()` or (new) just Identifier `@decorator` - TypeBuilders - getType(val: any) on runtime value - preparation - fix of some circular dependencies in runtime package - Null metadata Store
- Loading branch information
Showing
25 changed files
with
629 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export enum SomeEnum | ||
{ | ||
One, | ||
Two | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
export const SomeString = "SomeTypeString"; | ||
|
||
export class SomeType { | ||
|
||
foo() { | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,32 @@ | ||
import { getType } from "tst-reflect"; | ||
import { getType } from "tst-reflect"; | ||
import { property } from "./property"; | ||
import { SomeEnum } from "./SomeEnum"; | ||
import { SomeString } from "./SomeType"; | ||
|
||
enum SomeEnum | ||
{ | ||
One, | ||
Two | ||
} | ||
const MyString = "SomeType"; | ||
|
||
interface Foo | ||
/** | ||
* @reflectDecorator | ||
*/ | ||
function klass<TType>(str: string, num: number, enu: SomeEnum) | ||
{ | ||
enum: SomeEnum; | ||
console.log("klass", str, num, enu); | ||
const t = getType<TType>(); | ||
|
||
console.log(t.getDecorators().map(d => "\tdecorator: " + d.name + " args:" + d.getArguments().join(", "))); | ||
return function <T>(Constructor: { new(...args: any[]): T }) { | ||
}; | ||
} | ||
|
||
const type = getType<Foo>(); | ||
|
||
console.log(type); | ||
|
||
const enumProperty = type.getProperties().find(prop => prop.type.isEnum()); | ||
|
||
if (enumProperty) | ||
@klass(MyString, 5, SomeEnum.One) | ||
class A | ||
{ | ||
console.log(enumProperty.type.name, enumProperty.type.getEnum().getEnumerators()); | ||
@property("Foo property", 5, SomeEnum.One, { foo: "f", bar: 5, baz: SomeEnum.Two }) | ||
foo: string; | ||
|
||
@property(SomeString, 5, SomeEnum.Two, true) | ||
get bar(): number | ||
{ | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { SomeEnum } from "./SomeEnum"; | ||
|
||
export function property(str: string, num: number, enu: SomeEnum, any: any) | ||
{ | ||
console.log("property", str, num, enu, any); | ||
return function (_, __) {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.