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
7774101a
Unverified
Commit
7774101a
authored
Mar 24, 2020
by
Tim Neutkens
Committed by
GitHub
Mar 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip paths that are routed to a .d.ts file (#11322)
parent
ed064348
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
1 deletion
+31
-1
jsconfig-paths-plugin.ts
packages/next/build/webpack/plugins/jsconfig-paths-plugin.ts
+6
-0
alias-to-d-ts.d.ts
...ntegration/typescript-paths/components/alias-to-d-ts.d.ts
+1
-0
alias-to-d-ts.tsx
...integration/typescript-paths/components/alias-to-d-ts.tsx
+3
-0
alias-to-d-ts.tsx
test/integration/typescript-paths/pages/alias-to-d-ts.tsx
+10
-0
index.test.js
test/integration/typescript-paths/test/index.test.js
+5
-0
tsconfig.json
test/integration/typescript-paths/tsconfig.json
+6
-1
No files found.
packages/next/build/webpack/plugins/jsconfig-paths-plugin.ts
View file @
7774101a
...
@@ -174,6 +174,12 @@ export class JsConfigPathsPlugin implements ResolvePlugin {
...
@@ -174,6 +174,12 @@ export class JsConfigPathsPlugin implements ResolvePlugin {
for
(
const
subst
of
paths
[
matchedPatternText
])
{
for
(
const
subst
of
paths
[
matchedPatternText
])
{
const
path
=
matchedStar
?
subst
.
replace
(
'*'
,
matchedStar
)
:
subst
const
path
=
matchedStar
?
subst
.
replace
(
'*'
,
matchedStar
)
:
subst
// Ensure .d.ts is not matched
if
(
path
.
endsWith
(
'.d.ts'
))
{
continue
}
const
candidate
=
join
(
baseDirectory
,
path
)
const
candidate
=
join
(
baseDirectory
,
path
)
const
[
err
,
result
]
=
await
new
Promise
((
resolve
,
reject
)
=>
{
const
[
err
,
result
]
=
await
new
Promise
((
resolve
,
reject
)
=>
{
const
obj
=
Object
.
assign
({},
request
,
{
const
obj
=
Object
.
assign
({},
request
,
{
...
...
test/integration/typescript-paths/components/alias-to-d-ts.d.ts
0 → 100644
View file @
7774101a
export
default
()
=>
any
test/integration/typescript-paths/components/alias-to-d-ts.tsx
0 → 100644
View file @
7774101a
export
default
()
=>
{
return
<>
Not aliased to d.ts file
</>
}
test/integration/typescript-paths/pages/alias-to-d-ts.tsx
0 → 100644
View file @
7774101a
import
React
from
'react'
import
NotAliasedToDTS
from
'd-ts-alias'
export
default
function
HelloPage
():
JSX
.
Element
{
return
(
<
div
>
<
NotAliasedToDTS
/>
</
div
>
)
}
test/integration/typescript-paths/test/index.test.js
View file @
7774101a
...
@@ -42,5 +42,10 @@ describe('TypeScript Features', () => {
...
@@ -42,5 +42,10 @@ describe('TypeScript Features', () => {
const
$
=
await
get
$
(
'/single-alias'
)
const
$
=
await
get
$
(
'/single-alias'
)
expect
(
$
(
'body'
).
text
()).
toMatch
(
/Hello/
)
expect
(
$
(
'body'
).
text
()).
toMatch
(
/Hello/
)
})
})
it
(
'should not resolve to .d.ts files'
,
async
()
=>
{
const
$
=
await
get
$
(
'/alias-to-d-ts'
)
expect
(
$
(
'body'
).
text
()).
toMatch
(
/Not aliased to d
\.
ts file/
)
})
})
})
})
})
test/integration/typescript-paths/tsconfig.json
View file @
7774101a
...
@@ -2,9 +2,14 @@
...
@@ -2,9 +2,14 @@
"compilerOptions"
:
{
"compilerOptions"
:
{
"baseUrl"
:
"."
,
"baseUrl"
:
"."
,
"paths"
:
{
"paths"
:
{
"isomorphic-unfetch"
:
[
"types/unfetch.d.ts"
],
"@c/*"
:
[
"components/*"
],
"@c/*"
:
[
"components/*"
],
"@lib/*"
:
[
"lib/a/*"
,
"lib/b/*"
],
"@lib/*"
:
[
"lib/a/*"
,
"lib/b/*"
],
"@mycomponent"
:
[
"components/hello.tsx"
]
"@mycomponent"
:
[
"components/hello.tsx"
],
"d-ts-alias"
:
[
"components/alias-to-d-ts.d.ts"
,
"components/alias-to-d-ts.tsx"
]
},
},
"esModuleInterop"
:
true
,
"esModuleInterop"
:
true
,
"module"
:
"esnext"
,
"module"
:
"esnext"
,
...
...
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