e3181c2d77
This commit allows the users to import URLPattern from `next/server`, by defining a key that uses `global.URLPattern`. Why is this any good? or: why don't we add URLPattern to the global namespace? URLPattern is exposed as global on Edge Runtime _only_. This means that if we define a constructor in global namespace in our TypeScript definitions, people might have runtime errors in their Node.js functions. Importing from `next/server` enables users to get the constructor without risking in runtime errors and wrong type definitions. Keep in mind, that with the current implementation, we do not check if the constructor actually exists, but `next/server` shouldn't be imported in Node.js functions, AFAIK. ## Related - Fixes #38131 ## Bug - [x] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
17 lines
528 B
TypeScript
17 lines
528 B
TypeScript
declare class Headers extends globalThis.Headers {
|
|
getAll(key: 'set-cookie'): string[]
|
|
}
|
|
|
|
declare class Request extends globalThis.Request {
|
|
readonly headers: Headers
|
|
}
|
|
|
|
declare class Response extends globalThis.Response {
|
|
readonly headers: Headers
|
|
}
|
|
|
|
declare const fetchImplementation: typeof fetch
|
|
declare const FileConstructor: typeof File
|
|
declare const FormDataConstructor: typeof FormData
|
|
|
|
export { FileConstructor as File, FormDataConstructor as FormData, Headers, Request, Response, fetchImplementation as fetch };
|