Skip to content

named Macros build with function do not infer previous macro resolve #1574

@neronim1141

Description

@neronim1141

What version of Elysia is running?

1.4.16

What platform is your computer?

Microsoft Windows NT 10.0.26100.0 x64

What environment are you using

1.3.2

Are you using dynamic mode?

no

What steps can reproduce the bug?

Correct me if im wrong
according to this documentation:
https://elysiajs.com/patterns/macro.html#macro

it is possible to make macros as:

  .macro({
    	hi: (word: string) => ({
			resolve() {
				return {
					name: word,
				};
			},
		}),
    })

and combined it with this: https://elysiajs.com/patterns/macro.html#macro-extension-with-resolve

it should be in my opinion to do something like:

.macro("auth", {
		resolve: () => {
			return {
				user: "user",
			};
		},
	})
	.macro("permission", (permission: string) => ({
		auth: true,
		resolve: ({ user }) => {
			//check if user has permission
		},
	}));

But in this case typescript is complaining that the user does not exist,
where if we do use plain object instead of function as second parameter it works.

What is the expected behavior?

The user is infered properly from previous macro, when second macro parameter is an function

What do you see instead?

Typescript is complaining that user does not exist.

Additional information

No response

Have you try removing the node_modules and bun.lockb and try again yet?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions