-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib: add typings for fileURLToPath #38182
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -857,6 +857,9 @@ class URL { | |
FunctionPrototypeBind(onParsePortComplete, this)); | ||
} | ||
|
||
/** | ||
* @returns {string} | ||
*/ | ||
get pathname() { | ||
const ctx = this[context]; | ||
if (this[cannotBeBase]) | ||
|
@@ -1312,6 +1315,10 @@ function urlToHttpOptions(url) { | |
|
||
const forwardSlashRegEx = /\//g; | ||
|
||
/** | ||
* @param {URL} url | ||
* @returns {string} | ||
*/ | ||
function getPathFromURLWin32(url) { | ||
const hostname = url.hostname; | ||
let pathname = url.pathname; | ||
|
@@ -1365,6 +1372,10 @@ function getPathFromURLPosix(url) { | |
return decodeURIComponent(pathname); | ||
} | ||
|
||
/** | ||
* @param {string | URL} path | ||
* @returns {string} | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we document thrown errors using jsdoc's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from a practical perspective I don't think documenting the thrown errors is too useful since with current tooling it isn't actually able to guard them on a try/catch. In JS , stack depth, out of memory, etc. likely would cause such tags to be incorrect actually. |
||
function fileURLToPath(path) { | ||
if (typeof path === 'string') | ||
path = new URL(path); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these need to be wrapped in parentheses:
jsdoc→types→type union
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core is targeting JSDoc support in TypeScript not jsdoc the documentation tool. We could add them, but they are not actually needed. Just be sure to stick with TS support and not break the practical usage of the tags is my thoughts. So don't use jsdoc.org but instead defer to TS