This commit is contained in:
Richie Wee 2026-10-13 00:55:36 +08:00 • committed by GitHub
commit 3ab094b062
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 24 additions and 3 deletions

View file

@ -545,9 +545,11 @@ export const routesPhase: PipelinePhase<RoutesOutput> = {
// Unicode property classes make the boundary cover non-ASCII identifier
// characters too — ASCII `\w` would let `caféget('/x')` match `get`
// (#1852 review F10).
// An optional TypeScript type argument list may sit between the name and
// the call (`client.get<User[]>('/x')`).
const alternation = [...wrapperNames].map(escapeRegex).join('|');
const wrapperCallRegex = new RegExp(
`(?<![.\\p{L}\\p{N}_$])(?:${alternation})\\s*\\(\\s*['"\`](/[^'"\`\\s)]+)['"\`]`,
`(?<![.\\p{L}\\p{N}_$])(?:${alternation})\\s*(?:<[^()'"\`]*>\\s*)?\\(\\s*['"\`](/[^'"\`\\s)]+)['"\`]`,
'gu',
);
const scanContent = (filePath: string, content: string): void => {

View file

@ -6,6 +6,6 @@ const API_BASE = process.env.API_BASE || '';
// `fetch()`, so the parse-phase auto-detector cannot flag it. Listing
// "doRequest" in `.gitnexusrc` `fetchWrappers` is what lets the routes phase
// trace its consumers (#1589/#1852 residual).
export async function doRequest(path: string, opts?: Record<string, unknown>) {
return axios.get(`${API_BASE}${path}`, opts);
export async function doRequest<T = unknown>(path: string, opts?: Record<string, unknown>) {
return axios.get<T>(`${API_BASE}${path}`, opts);
}

View file

@ -0,0 +1,11 @@
import { doRequest } from '../lib/http';
type Thing = { id: number; name: string };
export default function TypedThings() {
const loadThings = async () => {
const res = await doRequest<Thing[]>('/api/things');
return res.data;
};
return null;
}

View file

@ -42,6 +42,14 @@ describe('Configurable fetch wrapper consumer extraction', () => {
expect(thingsEdge).toBeDefined();
});
it('traces a configured wrapper called with type arguments', () => {
const edges = getRelationships(withConfig, 'FETCHES');
const thingsEdge = edges.find(
(e) => e.sourceFilePath.includes('TypedThings') && e.target === '/api/things',
);
expect(thingsEdge).toBeDefined();
});
it('does NOT match a configured bare name inside a longer non-ASCII identifier (#1852 review F10)', () => {
// Accented.tsx calls `cafédoRequest('/api/things')` — `doRequest` preceded by
// the non-ASCII letter `é`. The Unicode-aware lookbehind must reject it.