Unverified Commit 7774101a authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Skip paths that are routed to a .d.ts file (#11322)

parent ed064348
...@@ -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, {
......
export default () => {
return <>Not aliased to d.ts file</>
}
import React from 'react'
import NotAliasedToDTS from 'd-ts-alias'
export default function HelloPage(): JSX.Element {
return (
<div>
<NotAliasedToDTS />
</div>
)
}
...@@ -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/)
})
}) })
}) })
...@@ -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",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment