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

[Bug report] Page.title is not type guarded #1306

Closed
Mister-Hope opened this issue Apr 19, 2023 · 2 comments · Fixed by #1308
Closed

[Bug report] Page.title is not type guarded #1306

Mister-Hope opened this issue Apr 19, 2023 · 2 comments · Fixed by #1308
Assignees
Labels
bug Something isn't working

Comments

@Mister-Hope
Copy link
Member

Description

---
title: 1
---
---
title: {}

There will be noob users who set titles like this, and page.title (with string type) will have other types, and this may break the application.

Unless we set page.title: unknown , we should guard the types of it.

Reproduction

Not needed

Used Package Manager

npm

System Info

.
@Mister-Hope Mister-Hope added the bug Something isn't working label Apr 19, 2023
@Mister-Hope Mister-Hope linked a pull request Apr 20, 2023 that will close this issue
@Mister-Hope Mister-Hope self-assigned this Apr 20, 2023
@meteorlxy
Copy link
Member

It's too verbose to use Record<string, unknown> for all frontmatter properties. We'd better assume that user use it correctly.

BTW, does title: 1 result in number or string?

@Mister-Hope
Copy link
Member Author

Mister-Hope commented Apr 20, 2023

number, so that's why I want this. No trim, replace or other functions are on numbers, so an errror will be thrown while it bypass typescript checks.

I agree it's fine for us not to check other properties, but title is an important one, and it's extracted just into page object (so you realize this is important)

I alrady met 10+ reports about setting title to a non-syring value by mistake and got error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants