Skip to content

Commit

Permalink
Merge pull request #10 from ef4/inter-version-compat
Browse files Browse the repository at this point in the history
Fix inter-version compatibility
  • Loading branch information
ef4 committed Jan 4, 2024
2 parents f47940e + 6857db4 commit 1e24344
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default function legacyDecoratorCompat(
path.insertBefore(
t.staticBlock([
t.expressionStatement(
t.callExpression(state.runtime(path, "f"), args)
t.callExpression(state.runtime(path, "g"), args)
),
])
);
Expand Down Expand Up @@ -206,7 +206,7 @@ export default function legacyDecoratorCompat(
path.insertAfter(
t.staticBlock([
t.expressionStatement(
t.callExpression(state.runtime(path, "m"), [
t.callExpression(state.runtime(path, "n"), [
prototype,
valueForFieldKey(t, path.node.key),
t.arrayExpression(
Expand Down
23 changes: 21 additions & 2 deletions src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,18 @@ function findDeferredDecorator(
}
}

// decorateField
// decorateField v1
export function f(
target: { prototype: object },
prop: string | number | symbol,
decorators: LegacyDecorator[],
initializer?: () => any
): void {
return g(target.prototype, prop, decorators, initializer);
}

// decorateField v2
export function g(
prototype: object,
prop: string | number | symbol,
decorators: LegacyDecorator[],
Expand All @@ -76,8 +86,17 @@ export function f(
}
}

// decorateMethod
// decorateMethod v1
export function m(
{ prototype }: { prototype: object },
prop: string | number | symbol,
decorators: LegacyDecorator[]
): void {
return n(prototype, prop, decorators);
}

// decorateMethod v2
export function n(
prototype: object,
prop: string | number | symbol,
decorators: LegacyDecorator[]
Expand Down

0 comments on commit 1e24344

Please sign in to comment.