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

Add (multidimensional) enum array typing #535

Merged
merged 6 commits into from
Jul 20, 2024
Merged

Add (multidimensional) enum array typing #535

merged 6 commits into from
Jul 20, 2024

Conversation

thoom76
Copy link
Contributor

@thoom76 thoom76 commented Jul 15, 2024

Context

Assume we have the following schema:

export const TheSchema {
	...,
	models: {
	    SomeModel: {
	        brands: {
	            type: Array,
                    required: true,
	            items: {
                        type: String,
	                enum: Object.values(Brand)
	            }
	        }
	    }
	}
}

the following Entity type:

export type SomeModelEntity = Entity<typeof TheSchema.models.SomeModel>;

and the following code:

const {brands}: SomeModelEntity = {
	...
}

Previously

when we check the type of brands we're seeing that it has the type string[] instead of the type Brand[]

New

When we check the type of brands we'll see that it has type Brand[]

thoom76 and others added 3 commits July 15, 2024 16:44
Make EntityField recursive when 'items' is defined to obtain the right type.
@mobsense
Copy link
Contributor

thank you. We'll test this out.

Michael

@thoom76
Copy link
Contributor Author

thoom76 commented Jul 16, 2024

@mobsense Fixed the typing issue, do you want me to create tests for the typing itself?

@mobsense
Copy link
Contributor

Is that possible?

@thoom76
Copy link
Contributor Author

thoom76 commented Jul 17, 2024

Added the tests 👍

@thoom76
Copy link
Contributor Author

thoom76 commented Jul 17, 2024

@mobsense Idk if you guys are aware of it. When simply cloning the repo, making some changes and running npm run test locally results in succeeding tests while the CI/CD pipeline fails on the same changes. Running nvm use 20 && npm ci && npm run build --if-present && npm run lint --if-present && npm run test:v2 && npm run test:v3 like the pipeline job did the work for me to get the same results.

@mobsense mobsense merged commit c7645a1 into sensedeep:main Jul 20, 2024
1 check passed
@mobsense
Copy link
Contributor

Thank you for the patch.

@mobsense
Copy link
Contributor

@mobsense Idk if you guys are aware of it. When simply cloning the repo, making some changes and running npm run test locally results in succeeding tests while the CI/CD pipeline fails on the same changes. Running nvm use 20 && npm ci && npm run build --if-present && npm run lint --if-present && npm run test:v2 && npm run test:v3 like the pipeline job did the work for me to get the same results.

Not really sure what you mean. The CI/CD seems to be working fine. When does it not work?

@thoom76 thoom76 deleted the patch-2 branch July 20, 2024 09:17
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.

2 participants