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

feat: add orphan Type to IJSONApplication to save types #1210

Merged
merged 3 commits into from
Aug 22, 2024

Conversation

ryoppippi
Copy link
Contributor

@ryoppippi ryoppippi commented Aug 8, 2024

This is a small PR.
This PR modify IJsonApplication types.
Now IJsonApplication keeps the original Type which is passed to typia.json.application.
This is useful if we make third-party library using typia(ex. https://github.com/ryoppippi/typiautil/blob/ab71cf9cbb73c751474136c6698a3ea23eb8f4b1/openai/mod.ts#L17)

Before submitting a Pull Request, please test your code. 

If you created a new feature, then create the unit test function, too.

```bash
# COMPILE
npm run build

# RE-WRITE TEST PROGRAMS IF REQUIRED
npm run test:template

# BUILD TEST PROGRAM
npm run build:test

# DO TEST
npm run test
```

Learn more about the [CONTRIBUTING](CONTRIBUTING.md)

export namespace IJsonApplication {
export interface IV3_0 {
export interface IV3_0<T> {
[tag]: T;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This technique is called opaque types

@ryoppippi ryoppippi force-pushed the feature/add-orphan-to-typia-json branch from fab8bc0 to 4e27c9b Compare August 8, 2024 13:40
@ryoppippi ryoppippi marked this pull request as draft August 8, 2024 13:42
Copy link

pkg-pr-new bot commented Aug 8, 2024

commit: 7309a02

npm i https://pkg.pr.new/typia@1210

Open in Stackblitz

@ryoppippi ryoppippi marked this pull request as ready for review August 8, 2024 13:52
@ryoppippi ryoppippi force-pushed the feature/add-orphan-to-typia-json branch from 0e9cb25 to 920d85b Compare August 8, 2024 13:53
@ryoppippi ryoppippi force-pushed the feature/add-orphan-to-typia-json branch from 920d85b to 7309a02 Compare August 8, 2024 14:19
@ryoppippi
Copy link
Contributor Author

Hmm, I'll check why test fails

@ryoppippi ryoppippi marked this pull request as draft August 8, 2024 23:26
Copy link
Owner

@samchon samchon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tested would be passed just by running the npm run generate command in the ./test directory.

@ryoppippi
Copy link
Contributor Author

Thanks. I'll check later

@ryoppippi
Copy link
Contributor Author

ryoppippi commented Aug 21, 2024

@samchon
I faced a lot of issues when I run npm run generate!
Try to fix it

@samchon
Copy link
Owner

samchon commented Aug 22, 2024

Ah, I'm sorry. Run npm run template command instead.

@samchon samchon marked this pull request as ready for review August 22, 2024 18:18
Copy link
Owner

@samchon samchon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix test program template generation issue by myself.

Thanks for contribution.

@samchon samchon merged commit e858972 into samchon:master Aug 22, 2024
5 of 7 checks passed
@samchon samchon self-assigned this Aug 22, 2024
@samchon samchon added enhancement New feature or request good first issue Good for newcomers labels Aug 22, 2024
@samchon
Copy link
Owner

samchon commented Aug 22, 2024

Well, this affects to the validation code like below:

TypeGuardError: Error on typia.assert(): invalid type on $input[0]["__@tag@9875"], expect to be Array<unknown>
    at new TypeGuardError (D:\github\samchon\typia\test\node_modules\typia\src\TypeGuardError.ts:10:10)
    at D:\github\samchon\typia\test\node_modules\typia\src\functional\$guard.ts:14:37
    at D:\github\samchon\typia\test\node_modules\typia\src\functional\$guard.ts:14:64
    at $ao0 (D:\github\samchon\typia\test\bin\features\assert\test_assert_UltimateUnion.js:115:63)
    at D:\github\samchon\typia\test\bin\features\assert\test_assert_UltimateUnion.js:854:31
    at Array.every (<anonymous>)
    at D:\github\samchon\typia\test\bin\features\assert\test_assert_UltimateUnion.js:850:37
    at D:\github\samchon\typia\test\bin\features\assert\test_assert_UltimateUnion.js:862:27
    at D:\github\samchon\typia\test\bin\features\assert\test_assert_UltimateUnion.js:865:8
    at D:\github\samchon\typia\test\bin\internal\_test_assert.js:11:24 {
  method: 'typia.assert',
  path: '$input[0]["__@tag@9875"]',
  expected: 'Array<unknown>',
  value: undefined
}

@ryoppippi
Copy link
Contributor Author

@samchon
OK! thanks!

@ryoppippi ryoppippi deleted the feature/add-orphan-to-typia-json branch August 22, 2024 18:41
@ryoppippi
Copy link
Contributor Author

Hmm, you can remove it if you want

samchon added a commit that referenced this pull request Aug 22, 2024
…e bit emension on the `unique symbol` tag type.
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
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants