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

[Contributor Doc] Type System CheatSheet #20168

Merged
merged 34 commits into from Apr 26, 2024
Merged

Conversation

Convly
Copy link
Member

@Convly Convly commented Apr 22, 2024

What does it do?

Init a cheatsheet for the type system in the contributor documentation

Note: This is honestly just a start. If you've any idea of what could/should/must be added, don't hesitate to comment

How to test it?

  • cd docs
  • yarn install && yarn start
  • head to guides > type system > cheatsheet

Convly and others added 30 commits April 9, 2024 16:25
…epts

# Conflicts:
#	docs/docs/guides/05-type-system/01-philosophy.md
#	packages/core/types/src/schema/attribute/definitions/uid.ts
#	packages/core/types/src/schema/index.ts
#	packages/core/types/src/struct/schema.ts
#	packages/core/types/src/uid/index.ts
Co-authored-by: Ben Irvin <ben.irvin@strapi.io>
Co-authored-by: Ben Irvin <ben.irvin@strapi.io>
Co-authored-by: Ben Irvin <ben.irvin@strapi.io>
Co-authored-by: Ben Irvin <ben.irvin@strapi.io>
Co-authored-by: Ben Irvin <ben.irvin@strapi.io>
Co-authored-by: Ben Irvin <ben.irvin@strapi.io>
…gistry.mdx

Co-authored-by: Ben Irvin <ben.irvin@strapi.io>
…gistry.mdx

Co-authored-by: Hannah Paine <151527179+hanpaine@users.noreply.github.com>
…gistry.mdx

Co-authored-by: Hannah Paine <151527179+hanpaine@users.noreply.github.com>
…gistry.mdx

Co-authored-by: Hannah Paine <151527179+hanpaine@users.noreply.github.com>
…gistry.mdx

Co-authored-by: Hannah Paine <151527179+hanpaine@users.noreply.github.com>
…gistry.mdx

Co-authored-by: Hannah Paine <151527179+hanpaine@users.noreply.github.com>
Co-authored-by: Hannah Paine <151527179+hanpaine@users.noreply.github.com>
Co-authored-by: Hannah Paine <151527179+hanpaine@users.noreply.github.com>
Co-authored-by: Hannah Paine <151527179+hanpaine@users.noreply.github.com>
@Convly Convly added pr: doc This PR contributes to the documentation in this repository (READMEs or Comments) source: typescript Source is related to TypeScript (typings, tooling, ...) labels Apr 22, 2024
Copy link

vercel bot commented Apr 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
contributor-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 26, 2024 0:45am

Copy link
Contributor

@innerdvations innerdvations left a comment

Choose a reason for hiding this comment

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

Good start, this will be helpful!

Can you make sure to run yarn prettier:write on this?

Or I'd be super happy if you could find out why your editor doesn't automatically do it on save, because this has been happening to a lot of people (myself included) seemingly randomly ever since I upgraded to prettier v3. There's definitely something odd going on but I haven't been able to figure it out.

docs/docs/guides/05-type-system/02-concepts/02-uid.mdx Outdated Show resolved Hide resolved
```typescript
import type { Data } from '@strapi/types';

function find(): Data.Entity {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you give a code example with a return to see when this might be used?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure I understand completely what you're referring too? Do you want an actual body definition for the function?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, like a use case showing what you would select in order to want to return a generic Data.Entity. Not important though, just a thought.

docs/docs/guides/05-type-system/03-cheatsheet.mdx Outdated Show resolved Hide resolved
Co-authored-by: Ben Irvin <ben.irvin@strapi.io>
Co-authored-by: Ben Irvin <ben.irvin@strapi.io>
@innerdvations
Copy link
Contributor

innerdvations commented Apr 24, 2024

Prettier is still failing, do we need the fix you did on v5/main?

And furthermore, is there something broken with yarn prettier:write in regards to ts docs that we can address (perhaps outside this PR)?

@Convly
Copy link
Member Author

Convly commented Apr 25, 2024

Prettier is still failing, do we need the fix you did on v5/main?

And furthermore, is there something broken with yarn prettier:write in regards to ts docs that we can address (perhaps outside this PR)?

We need to understand how to make prettier really understand mdx (because that's not the case currently)

For now everything works well with the exception of 1 prettier-ignore block comment. We can add a note/task to look at this later

Copy link
Contributor

@innerdvations innerdvations left a comment

Choose a reason for hiding this comment

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

LGTM!

```typescript
import type { Data } from '@strapi/types';

function find(): Data.Entity {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, like a use case showing what you would select in order to want to return a generic Data.Entity. Not important though, just a thought.

@hanpaine
Copy link

Prettier is still failing, do we need the fix you did on v5/main?
And furthermore, is there something broken with yarn prettier:write in regards to ts docs that we can address (perhaps outside this PR)?

We need to understand how to make prettier really understand mdx (because that's not the case currently)

For now everything works well with the exception of 1 prettier-ignore block comment. We can add a note/task to look at this later

I saw Piwi mention that prettier isn't great for documentation as it will often flag a deliberate formatting 'error' that we want there - same situ?

@innerdvations
Copy link
Contributor

I saw Piwi mention that prettier isn't great for documentation as it will often flag a deliberate formatting 'error' that we want there - same situ?

Here it's a bit more complicated, but the gist of it is that we've never spent time really configuring it for our docs. So sometimes it gets in the way a bit. We'll hopefully get a chance to improve that soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: doc This PR contributes to the documentation in this repository (READMEs or Comments) source: typescript Source is related to TypeScript (typings, tooling, ...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants