mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Only filter ignored paths from module specifier generation if there exists a better option (#43024)
* Only filter ignored paths from module specifier generation if there exists a better option * Nit
This commit is contained in:
parent
4b67b4a7bc
commit
56f95d2a3f
@ -282,10 +282,12 @@ namespace ts.moduleSpecifiers {
|
||||
const redirects = host.redirectTargetsMap.get(importedPath) || emptyArray;
|
||||
const importedFileNames = [...(referenceRedirect ? [referenceRedirect] : emptyArray), importedFileName, ...redirects];
|
||||
const targets = importedFileNames.map(f => getNormalizedAbsolutePath(f, cwd));
|
||||
let shouldFilterIgnoredPaths = !every(targets, containsIgnoredPath);
|
||||
|
||||
if (!preferSymlinks) {
|
||||
// Symlinks inside ignored paths are already filtered out of the symlink cache,
|
||||
// so we only need to remove them from the realpath filenames.
|
||||
const result = forEach(targets, p => !containsIgnoredPath(p) && cb(p, referenceRedirect === p));
|
||||
const result = forEach(targets, p => !(shouldFilterIgnoredPaths && containsIgnoredPath(p)) && cb(p, referenceRedirect === p));
|
||||
if (result) return result;
|
||||
}
|
||||
const links = host.getSymlinkCache
|
||||
@ -312,12 +314,13 @@ namespace ts.moduleSpecifiers {
|
||||
for (const symlinkDirectory of symlinkDirectories) {
|
||||
const option = resolvePath(symlinkDirectory, relative);
|
||||
const result = cb(option, target === referenceRedirect);
|
||||
shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
|
||||
if (result) return result;
|
||||
}
|
||||
});
|
||||
});
|
||||
return result || (preferSymlinks
|
||||
? forEach(targets, p => containsIgnoredPath(p) ? undefined : cb(p, p === referenceRedirect))
|
||||
? forEach(targets, p => shouldFilterIgnoredPaths && containsIgnoredPath(p) ? undefined : cb(p, p === referenceRedirect))
|
||||
: undefined);
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
//// [tests/cases/compiler/nodeModuleReexportFromDottedPath.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
export interface PrismaClientOptions {
|
||||
rejectOnNotFound?: any;
|
||||
}
|
||||
|
||||
export class PrismaClient<T extends PrismaClientOptions = PrismaClientOptions> {
|
||||
private fetcher;
|
||||
}
|
||||
|
||||
//// [index.d.ts]
|
||||
export * from ".prisma/client";
|
||||
|
||||
//// [index.ts]
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
declare const enhancePrisma: <TPrismaClientCtor>(client: TPrismaClientCtor) => TPrismaClientCtor & { enhanced: unknown };
|
||||
const EnhancedPrisma = enhancePrisma(PrismaClient);
|
||||
export default new EnhancedPrisma();
|
||||
|
||||
|
||||
//// [index.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
var client_1 = require("@prisma/client");
|
||||
var EnhancedPrisma = enhancePrisma(client_1.PrismaClient);
|
||||
exports["default"] = new EnhancedPrisma();
|
||||
|
||||
|
||||
//// [index.d.ts]
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
declare const _default: PrismaClient<import(".prisma/client").PrismaClientOptions>;
|
||||
export default _default;
|
||||
@ -0,0 +1,41 @@
|
||||
=== /node_modules/.prisma/client/index.d.ts ===
|
||||
export interface PrismaClientOptions {
|
||||
>PrismaClientOptions : Symbol(PrismaClientOptions, Decl(index.d.ts, 0, 0))
|
||||
|
||||
rejectOnNotFound?: any;
|
||||
>rejectOnNotFound : Symbol(PrismaClientOptions.rejectOnNotFound, Decl(index.d.ts, 0, 38))
|
||||
}
|
||||
|
||||
export class PrismaClient<T extends PrismaClientOptions = PrismaClientOptions> {
|
||||
>PrismaClient : Symbol(PrismaClient, Decl(index.d.ts, 2, 1))
|
||||
>T : Symbol(T, Decl(index.d.ts, 4, 26))
|
||||
>PrismaClientOptions : Symbol(PrismaClientOptions, Decl(index.d.ts, 0, 0))
|
||||
>PrismaClientOptions : Symbol(PrismaClientOptions, Decl(index.d.ts, 0, 0))
|
||||
|
||||
private fetcher;
|
||||
>fetcher : Symbol(PrismaClient.fetcher, Decl(index.d.ts, 4, 80))
|
||||
}
|
||||
|
||||
=== /node_modules/@prisma/client/index.d.ts ===
|
||||
export * from ".prisma/client";
|
||||
No type information for this code.
|
||||
No type information for this code.=== /index.ts ===
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
>PrismaClient : Symbol(PrismaClient, Decl(index.ts, 0, 8))
|
||||
|
||||
declare const enhancePrisma: <TPrismaClientCtor>(client: TPrismaClientCtor) => TPrismaClientCtor & { enhanced: unknown };
|
||||
>enhancePrisma : Symbol(enhancePrisma, Decl(index.ts, 1, 13))
|
||||
>TPrismaClientCtor : Symbol(TPrismaClientCtor, Decl(index.ts, 1, 30))
|
||||
>client : Symbol(client, Decl(index.ts, 1, 49))
|
||||
>TPrismaClientCtor : Symbol(TPrismaClientCtor, Decl(index.ts, 1, 30))
|
||||
>TPrismaClientCtor : Symbol(TPrismaClientCtor, Decl(index.ts, 1, 30))
|
||||
>enhanced : Symbol(enhanced, Decl(index.ts, 1, 100))
|
||||
|
||||
const EnhancedPrisma = enhancePrisma(PrismaClient);
|
||||
>EnhancedPrisma : Symbol(EnhancedPrisma, Decl(index.ts, 2, 5))
|
||||
>enhancePrisma : Symbol(enhancePrisma, Decl(index.ts, 1, 13))
|
||||
>PrismaClient : Symbol(PrismaClient, Decl(index.ts, 0, 8))
|
||||
|
||||
export default new EnhancedPrisma();
|
||||
>EnhancedPrisma : Symbol(EnhancedPrisma, Decl(index.ts, 2, 5))
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
=== /node_modules/.prisma/client/index.d.ts ===
|
||||
export interface PrismaClientOptions {
|
||||
rejectOnNotFound?: any;
|
||||
>rejectOnNotFound : any
|
||||
}
|
||||
|
||||
export class PrismaClient<T extends PrismaClientOptions = PrismaClientOptions> {
|
||||
>PrismaClient : PrismaClient<T>
|
||||
|
||||
private fetcher;
|
||||
>fetcher : any
|
||||
}
|
||||
|
||||
=== /node_modules/@prisma/client/index.d.ts ===
|
||||
export * from ".prisma/client";
|
||||
No type information for this code.
|
||||
No type information for this code.=== /index.ts ===
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
>PrismaClient : typeof PrismaClient
|
||||
|
||||
declare const enhancePrisma: <TPrismaClientCtor>(client: TPrismaClientCtor) => TPrismaClientCtor & { enhanced: unknown };
|
||||
>enhancePrisma : <TPrismaClientCtor>(client: TPrismaClientCtor) => TPrismaClientCtor & { enhanced: unknown; }
|
||||
>client : TPrismaClientCtor
|
||||
>enhanced : unknown
|
||||
|
||||
const EnhancedPrisma = enhancePrisma(PrismaClient);
|
||||
>EnhancedPrisma : typeof PrismaClient & { enhanced: unknown; }
|
||||
>enhancePrisma(PrismaClient) : typeof PrismaClient & { enhanced: unknown; }
|
||||
>enhancePrisma : <TPrismaClientCtor>(client: TPrismaClientCtor) => TPrismaClientCtor & { enhanced: unknown; }
|
||||
>PrismaClient : typeof PrismaClient
|
||||
|
||||
export default new EnhancedPrisma();
|
||||
>new EnhancedPrisma() : PrismaClient<import("/node_modules/.prisma/client/index").PrismaClientOptions>
|
||||
>EnhancedPrisma : typeof PrismaClient & { enhanced: unknown; }
|
||||
|
||||
19
tests/cases/compiler/nodeModuleReexportFromDottedPath.ts
Normal file
19
tests/cases/compiler/nodeModuleReexportFromDottedPath.ts
Normal file
@ -0,0 +1,19 @@
|
||||
// @declaration: true
|
||||
|
||||
// @Filename: /node_modules/.prisma/client/index.d.ts
|
||||
export interface PrismaClientOptions {
|
||||
rejectOnNotFound?: any;
|
||||
}
|
||||
|
||||
export class PrismaClient<T extends PrismaClientOptions = PrismaClientOptions> {
|
||||
private fetcher;
|
||||
}
|
||||
|
||||
// @Filename: /node_modules/@prisma/client/index.d.ts
|
||||
export * from ".prisma/client";
|
||||
|
||||
// @Filename: /index.ts
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
declare const enhancePrisma: <TPrismaClientCtor>(client: TPrismaClientCtor) => TPrismaClientCtor & { enhanced: unknown };
|
||||
const EnhancedPrisma = enhancePrisma(PrismaClient);
|
||||
export default new EnhancedPrisma();
|
||||
Loading…
x
Reference in New Issue
Block a user