Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support: Type export by implicit inference #805

Open
ltnscp9028 opened this issue Feb 20, 2024 · 1 comment
Open

Support: Type export by implicit inference #805

ltnscp9028 opened this issue Feb 20, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ltnscp9028
Copy link

ltnscp9028 commented Feb 20, 2024

The feature proposal you're describing suggests supporting to export implicit types inferred.

for Example,

@Controller('foo')
export class FooController {
    @Post()
    foo(@Body() body: {fooRequest: string}) {
        return {foo: 'bar'}
    }
}

In the code below, I expect the type inference to be as follows:

interface FooControllerFooRequest {
  fooRequest: string
}

interface FooControllerFooResponse {
  foo: string
}

The interface content doesn't necessarily need to this pattern (Controller class name + Controller class method + Request/Response).

Only, It can be any value that is easy for users to distinguish.

This enables Nestia users to convert implicit type inference into explicit type inference through Nestia.

Also support migration through nestia.

e.g. npx nestia migrate implict command,

AS-IS

@Controller('foo')
export class FooController {
    @Post()
    foo(@Body() body: {fooRequest: string}) {
        return {foo: 'bar'}
    }
}

TO-BE

@Controller('foo')
export class FooController {
    @Post()
    foo(@Body() body: FooRequest): FooResponse {
        return {foo: 'bar'}
    }
}

To achieve this, export type support is necessary.
Alternatively, users can create a type in a path specified by them.

If Support this feature, Nestia-driven development becomes feasible.

@samchon samchon self-assigned this Feb 24, 2024
@samchon samchon added enhancement New feature or request good first issue Good for newcomers labels Feb 24, 2024
@samchon
Copy link
Owner

samchon commented Feb 24, 2024

The new cli command would be npx nestia explicit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants