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: adds @deepkit/type #895

Closed
wants to merge 6 commits into from
Closed

feat: adds @deepkit/type #895

wants to merge 6 commits into from

Conversation

BasixKOR
Copy link

@BasixKOR BasixKOR commented Jun 17, 2022

Making a draft since I had a hard time running this on my local machine. Aims to resolve #894.

@moltar moltar changed the title Add @deepkit/type feat: adds @deepkit/type Jun 17, 2022
package.json Outdated Show resolved Hide resolved
cases/deepkit.ts Outdated Show resolved Hide resolved
tsconfig.json Outdated Show resolved Hide resolved
@hoeck
Copy link
Collaborator

hoeck commented Jun 18, 2022

Also, deepkit seems to require at least node v14 (tried that locally and it worked):

    /home/runner/work/typescript-runtime-type-benchmarks/typescript-runtime-type-benchmarks/node_modules/@deepkit/type/dist/cjs/src/reflection/reflection.js:923
                type.visibility = prop.visibility ?? type_1.ReflectionVisibility.public;
                                                   ^
    SyntaxError: Unexpected token '?'
      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1728:14)
      at Object.<anonymous> (node_modules/@deepkit/type/dist/cjs/src/decorator.js:4:28)

To resolve this, we could:

  1. add a node version filter to the benchmarks
  2. use some tool (babel?) to transpile node-modules
  3. drop node 12 benchmarks

In absence of other options, I'd vote for dropping node 12 benchmarks 😁

@hoeck
Copy link
Collaborator

hoeck commented Jun 18, 2022

@BasixKOR I you like, you can also run the tests locally with npm run test, you'll then see that the parseStrict case test is failing for deepkit:

    deepkit
      ✓ should validate the data (2 ms)
      ✓ should throw on invalid attribute type (1 ms)
      ✕ should throw on extra attributes
      ✕ should throw on extra nested attributes
      ✕ should throw on missing attributes

If there is no strict validation option for deepkit (I did not found any, tried validatedDeserialize() but that did ignore extra attributes), you can omit the case and only include those that deepkit supports.

@BasixKOR
Copy link
Author

BasixKOR commented Jun 18, 2022

use some tool (babel?) to transpile node-modules

@hoeck Yeah, It seems like Jest allows to do this with transformIgnorePatterns so I think I'll try this option.

you can omit the case and only include those that deepkit supports.

Thanks, I'll remove loose and safe test cases for now until I figure out how to ignore unknown keys.

I understood in a completely opposite way 😂 I'll remove the strict ones, thanks for the suggestion!

@hoeck
Copy link
Collaborator

hoeck commented Jun 18, 2022

I understood in a completely opposite way joy I'll remove the strict ones, thanks for the suggestion!

Indeed that was worded quite ambiguously, I meant removing the benchmark case 😅 not the test case.

Yeah, It seems like Jest allows to do this with transformIgnorePatterns so I think I'll try this option.

That will help with running the Jest tests but you'd still need a separate setup for running the benchmark?

As the oldest LTS release is node 14 now, I am all in favor of dropping node 12 support instead of introducing more build complexity. @moltar any opinions?

@moltar
Copy link
Owner

moltar commented Jun 18, 2022

I am in favour of dropping Node v12!

cases/deepkit.ts Outdated Show resolved Hide resolved
cases/deepkit.ts Outdated Show resolved Hide resolved
@hoeck
Copy link
Collaborator

hoeck commented Jun 24, 2022

I am in favour of dropping Node v12!

👍 okay I'll create a PR that drops node 12, after merging, this PR can then be rebased and deepkit tests and benchmarks should work 😀

@hoeck
Copy link
Collaborator

hoeck commented Jul 14, 2022

@BasixKOR could you please rebase on the latest master - I have removed node 12, the benchmarks now run on 14, 16 and node 18 only so your PR should pass after the rebase. If you don't have time any more, please let me know and I will take care of this PR. Thanks!

@BasixKOR
Copy link
Author

I rebased the deepkit branch and it should be okay, please lmk if anything is a bit off

package.json Outdated Show resolved Hide resolved
BasixKOR added a commit to BasixKOR/typescript-runtime-type-benchmarks that referenced this pull request Jul 16, 2022
@BasixKOR
Copy link
Author

Fixed some remaining rebase issues and uses guard and deserializeFunction now! Unfortunately 'should throw on missing attributes' test is breaking though.

@hoeck
Copy link
Collaborator

hoeck commented Jul 20, 2022

'should throw on missing attributes' test is breaking though

Could you skip that benchmark then? It is okay if you only implement the benchmarks that deepkit supports.

I created separate benchmarks as checking for missing attributes adds some overhead and I wanted to be able to compare libs that perform that extra step.

@M-jerez M-jerez mentioned this pull request Jan 30, 2024
@moltar moltar closed this in #1199 Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add deepkit
4 participants