Closed Mister-Hope closed 4 years ago
Well, I think you should use Module Augmentation to extend the Page
type itself
Well, good idea
Nope, we are using PageComputed
type in other files, and this function use Page
. Extending it has no meaning because it's only used in compiling. see here
That is, I think we should better change it, and write:
declare 'vuepress-types/types/page' {
interface PageComputed {
xxx: yyy;
}
}
instead of remaining it and write:
declare 'vuepress-types/types/page' {
interface Page {
xxx: yyy;
}
interface PageComputed {
xxx: yyy;
}
}
Extending it has no meaning because it's only used in compiling
Sorry didn't catch your point. Typescript is only used in compiling, too.
Extending it has no meaning because it's only used in compiling
Sorry didn't catch your point. Typescript is only used in compiling, too.
The page is only used in plugin config and themeConfig for extendPage, and the extend result is PageComputed when we access them, so there is no need to extend Page interface, we shoukd just change the type as I suggested and extend Page Comput in some where alse, is this description clear?😅
Not all extended properties will be treated as computed. If you want to add a property in both Page
and PageComputed
, try to extend BasePage
Not all extended properties will be treated as computed. If you want to add a property in both
Page
andPageComputed
, try to extendBasePage
Emmm, an example please? Even in generated I am seeing PageComputed
declare 'vuepress-types/types/page' {
interface BasePage {
foo: bar;
}
}
declare 'vuepress-types/types/page' { interface BasePage { foo: bar; } }
😅I was saying an example of user accessing Page interface somewhere in theme config, plugin config or components.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
should be
Otherwise we can not extend it. 🙄