Skip to content
This repository has been archived by the owner on Dec 12, 2020. It is now read-only.

Commit

Permalink
fix: Change super name into DynamicType (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktutnik committed Jun 6, 2020
1 parent 728c491 commit 0102fd6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export namespace generic {
* @param params List of generic type parameters
*/
export function create<T extends Class>(parent: T | { parent: T, name: string }, ...params: TypeOverride[]) {
const opt = (typeof parent === "object") ? parent : { parent: parent, name: parent.name }
const opt = (typeof parent === "object") ? parent : { parent: parent, name: "DynamicType" }
const Type = metadata.createClass(opt.parent, opt.name)
Reflect.decorate([generic.type(...params)], Type)
return Type
Expand Down
6 changes: 2 additions & 4 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@ function getNamesFromAst(nodes: any[]) {

function getCode(fn:Class|Function){
const code = fn.toString()
if(code === "class extends parent {}") {
const token = code.split(" ")
token.splice(1, 0, "DynamicClass")
return token.join(" ")
if(code.search(/^class(\s*)extends\s*parent\s*{\s*}/gm) > -1) {
return "class DynamicClass extends parent {}"
}
else
return code.replace("[native code]", "")
Expand Down
30 changes: 15 additions & 15 deletions test/__snapshots__/generic.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ Object {
"decorators": Array [
Object {
"kind": "GenericType",
"target": SuperClass,
"target": DynamicType,
"types": Array [
Number,
String,
Expand Down Expand Up @@ -411,10 +411,10 @@ Object {
"typeClassification": "Primitive",
},
],
"name": "SuperClass",
"name": "DynamicType",
"properties": Array [],
"super": SuperClass,
"type": SuperClass,
"type": DynamicType,
"typeClassification": "Class",
}
`;
Expand Down Expand Up @@ -964,7 +964,7 @@ Object {
"decorators": Array [
Object {
"kind": "GenericType",
"target": CustomGeneric,
"target": DynamicType,
"types": Array [
String,
],
Expand All @@ -977,7 +977,7 @@ Object {
],
"kind": "Class",
"methods": Array [],
"name": "CustomGeneric",
"name": "DynamicType",
"properties": Array [
Object {
"decorators": Array [],
Expand All @@ -990,7 +990,7 @@ Object {
},
],
"super": CustomGeneric,
"type": CustomGeneric,
"type": DynamicType,
"typeClassification": "Class",
}
`;
Expand All @@ -1005,7 +1005,7 @@ Object {
"decorators": Array [
Object {
"kind": "GenericType",
"target": CustomGeneric,
"target": DynamicType,
"types": Array [
String,
],
Expand All @@ -1018,7 +1018,7 @@ Object {
],
"kind": "Class",
"methods": Array [],
"name": "CustomGeneric",
"name": "DynamicType",
"properties": Array [
Object {
"decorators": Array [],
Expand All @@ -1031,7 +1031,7 @@ Object {
},
],
"super": CustomGeneric,
"type": CustomGeneric,
"type": DynamicType,
"typeClassification": "Class",
}
`;
Expand All @@ -1046,7 +1046,7 @@ Object {
"decorators": Array [
Object {
"kind": "GenericType",
"target": CustomGeneric,
"target": DynamicType,
"types": Array [
String,
],
Expand All @@ -1059,7 +1059,7 @@ Object {
],
"kind": "Class",
"methods": Array [],
"name": "CustomGeneric",
"name": "DynamicType",
"properties": Array [
Object {
"decorators": Array [],
Expand All @@ -1072,7 +1072,7 @@ Object {
},
],
"super": CustomGeneric,
"type": CustomGeneric,
"type": DynamicType,
"typeClassification": "Class",
}
`;
Expand All @@ -1087,7 +1087,7 @@ Object {
"decorators": Array [
Object {
"kind": "GenericType",
"target": CustomGeneric,
"target": DynamicType,
"types": Array [
String,
],
Expand All @@ -1100,7 +1100,7 @@ Object {
],
"kind": "Class",
"methods": Array [],
"name": "CustomGeneric",
"name": "DynamicType",
"properties": Array [
Object {
"decorators": Array [],
Expand All @@ -1113,7 +1113,7 @@ Object {
},
],
"super": CustomGeneric,
"type": CustomGeneric,
"type": DynamicType,
"typeClassification": "Class",
}
`;

0 comments on commit 0102fd6

Please sign in to comment.