Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3b9221f

Browse files
authored
fix(types): allow nonpromise return types for static functions (vercel#24685)
## Bug- [x]fixesvercel#24684- [x] Integration tests addedIntentionally omitted changing the types for `GetServerSideProps` etc. as its imo less reasonable to leverage SSR with a sync `getServerSideProps`. Can of course change the type too if you consider that also a valid case.
1 parentf29dfe2 commit3b9221f

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

‎packages/next/types/index.d.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,15 @@ export type GetStaticPropsResult<P> =
109109
exporttypeGetStaticProps<
110110
Pextends{[key:string]:any}={[key:string]:any},
111111
QextendsParsedUrlQuery=ParsedUrlQuery
112-
>=(context:GetStaticPropsContext<Q>)=>Promise<GetStaticPropsResult<P>>
112+
>=(
113+
context:GetStaticPropsContext<Q>
114+
)=>Promise<GetStaticPropsResult<P>>|GetStaticPropsResult<P>
113115

114116
exporttypeInferGetStaticPropsType<T>=TextendsGetStaticProps<inferP,any>
115117
?P
116118
:Textends(
117119
context?:GetStaticPropsContext<any>
118-
)=>Promise<GetStaticPropsResult<inferP>>
120+
)=>Promise<GetStaticPropsResult<inferP>>|GetStaticPropsResult<inferP>
119121
?P
120122
:never
121123

@@ -131,7 +133,7 @@ export type GetStaticPathsResult<P extends ParsedUrlQuery = ParsedUrlQuery> = {
131133

132134
exporttypeGetStaticPaths<PextendsParsedUrlQuery=ParsedUrlQuery>=(
133135
context:GetStaticPathsContext
134-
)=>Promise<GetStaticPathsResult<P>>
136+
)=>Promise<GetStaticPathsResult<P>>|GetStaticPathsResult<P>
135137

136138
exporttypeGetServerSidePropsContext<
137139
QextendsParsedUrlQuery=ParsedUrlQuery

‎test/integration/typescript/test/index.test.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,16 @@ export default function EvilPage(): JSX.Element {
111111
errorPage.restore()
112112
}
113113
})
114+
115+
it('should compile sync getStaticPaths & getStaticProps',async()=>{
116+
constpage=newFile(join(appDir,'pages/ssg/[slug].tsx'))
117+
try{
118+
page.replace(/async\(/g,'(')
119+
constoutput=awaitnextBuild(appDir,[],{stdout:true})
120+
expect(output.stdout).toMatch(/Compiledsuccessfully/)
121+
}finally{
122+
page.restore()
123+
}
124+
})
114125
})
115126
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp