Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
c9aa2ea2
Unverified
Commit
c9aa2ea2
authored
Aug 10, 2022
by
JJ Kasper
Committed by
GitHub
Aug 10, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweak styled-jsx type declarations (#39474)
* Tweak styled-jsx type declarations * fix lint
parent
f5cab2f5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
taskfile.js
packages/next/taskfile.js
+15
-2
index.tsx
test/production/typescript-basic/app/pages/index.tsx
+2
-0
No files found.
packages/next/taskfile.js
View file @
c9aa2ea2
...
...
@@ -57,18 +57,31 @@ export async function copy_styled_jsx_assets(task, opts) {
// dev dep `styled-jsx` and `next/dist/styled-jsx` for duplicated declare modules
const
typesDir
=
join
(
outputDir
,
'types'
)
let
typeReferences
=
''
let
globalTypesContent
=
''
await
fs
.
ensureDir
(
outputDir
)
await
fs
.
ensureDir
(
typesDir
)
for
(
const
file
of
typeFiles
)
{
const
fileNoExt
=
file
.
replace
(
/
\.
d
\.
ts/
,
''
)
const
content
=
await
fs
.
readFile
(
join
(
styledJsxPath
,
file
),
'utf8'
)
let
content
=
await
fs
.
readFile
(
join
(
styledJsxPath
,
file
),
'utf8'
)
if
(
file
===
'index.d.ts'
)
{
const
styledJsxIdx
=
content
.
indexOf
(
`declare module 'styled-jsx' {`
)
globalTypesContent
=
content
.
substring
(
0
,
styledJsxIdx
)
content
=
content
.
substring
(
styledJsxIdx
)
.
replace
(
'React.'
,
`import('react').`
)
}
await
fs
.
writeFile
(
join
(
typesDir
,
file
),
content
)
typeReferences
+=
`/// <reference types="./
${
fileNoExt
}
" />\n`
}
await
fs
.
writeFile
(
join
(
typesDir
,
'global.d.ts'
),
typeReferences
)
await
fs
.
writeFile
(
join
(
typesDir
,
'global.d.ts'
),
`
${
typeReferences
}
\n
${
globalTypesContent
}
`
)
for
(
const
file
of
jsFiles
)
{
const
content
=
await
fs
.
readFile
(
join
(
styledJsxPath
,
file
),
'utf8'
)
...
...
test/production/typescript-basic/app/pages/index.tsx
View file @
c9aa2ea2
import
{
useRouter
}
from
'next/router'
import
Link
from
'next/link'
import
{
type
PageConfig
}
from
'next'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import
{
StyleRegistry
,
createStyleRegistry
}
from
'styled-jsx'
export
const
config
:
PageConfig
=
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment