Skip to content

Commit

Permalink
add types
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbhmr committed Jul 12, 2023
1 parent 78f8e5a commit 3854ef8
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webfill/import-meta-resolve",
"version": "0.1.2",
"version": "0.2.0",
"description": "🎯 Standard synchronous import.meta.resolve() for anywhere",
"keywords": [
"import",
Expand All @@ -20,18 +20,21 @@
"type": "module",
"exports": {
".": {
"types": "./src/resolve-types.d.ts",
"deno": "./src/resolve-deno+default.js",
"bun": "./src/resolve-bun.js",
"node": "./src/resolve-node.js",
"default": "./src/resolve-deno+default.js"
},
"./resolve.js": {
"types": "./src/resolve-types.d.ts",
"deno": "./src/resolve-deno+default.js",
"bun": "./src/resolve-bun.js",
"node": "./src/resolve-node.js",
"default": "./src/resolve-deno+default.js"
},
"./polyfill.js": {
"types": "./src/polyfill-types.d.ts",
"deno": "./src/polyfill-deno.js",
"bun": "./src/polyfill-bun.js",
"node": "./src/polyfill-node.js",
Expand Down
30 changes: 30 additions & 0 deletions src/polyfill-types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
declare global {
interface ImportMeta {
/**
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve
* @see https://nodejs.org/api/esm.html#importmetaresolvespecifier-parent
* @see https://bun.sh/docs/api/import-meta
* @see https://deno.land/manual/runtime/import_meta_api
*/
resolve?(importMeta: ImportMeta, specifier: string): string;
/**
* @see https://nodejs.org/api/esm.html#importmetaresolvespecifier-parent
* @experimental
*/
resolve?(
importMeta: ImportMeta,
specifier: string,
parentURL?: string
): string;
}
}

/**
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve
* @see https://nodejs.org/api/esm.html#importmetaresolvespecifier-parent
* @see https://bun.sh/docs/api/import-meta
* @see https://deno.land/manual/runtime/import_meta_api
*/
function polyfill(importMeta: ImportMeta): void;

export default polyfill;
18 changes: 18 additions & 0 deletions src/resolve-types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve
* @see https://nodejs.org/api/esm.html#importmetaresolvespecifier-parent
* @see https://bun.sh/docs/api/import-meta
* @see https://deno.land/manual/runtime/import_meta_api
*/
function resolve(importMeta: ImportMeta, specifier: string): string;
/**
* @see https://nodejs.org/api/esm.html#importmetaresolvespecifier-parent
* @experimental
*/
function resolve(
importMeta: ImportMeta,
specifier: string,
parentURL?: string
): string;

export default resolve;

0 comments on commit 3854ef8

Please sign in to comment.