Skip to content
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 tsconfig internal contributions #38042

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
nits / make some mutations picked up
  • Loading branch information
bmeck committed Apr 7, 2021
commit 927aa17b32b58b6617c632c19cf1e3d7943f7920
3 changes: 3 additions & 0 deletions lib/internal/per_context/primordials.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ const copyProps = (src, dest) => {
});
};

/**
* @type {typeof primordials.makeSafe}
*/
const makeSafe = (unsafe, safe) => {
if (SymbolIterator in unsafe.prototype) {
const dummy = new unsafe();
Expand Down
13 changes: 13 additions & 0 deletions typings/primordials.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
type UncurryThis<T extends (this: unknown, ...args: unknown[]) => unknown> =
(self: ThisParameterType<T>, ...args: Parameters<T>) => ReturnType<T>;
type UncurryThisStaticApply<T extends (this: unknown, ...args: unknown[]) => unknown> =
(self: ThisParameterType<T>, args: Parameters<T>) => ReturnType<T>;
type StaticApply<T extends (this: unknown, ...args: unknown[]) => unknown> =
(args: Parameters<T>) => ReturnType<T>;

/**
* Primordials are a way to safely use globals without fear of global mutation
Expand All @@ -19,6 +23,12 @@ type UncurryThis<T extends (this: unknown, ...args: unknown[]) => unknown> =
* ```
*/
declare namespace primordials {
export function uncurryThis<
T extends (...args: unknown[]) => unknown
> (fn: T):
(self: ThisType<T>, ...args: Parameters<T>) => ReturnType<T>;
export function makeSafe<T extends NewableFunction>(unsafe: NewableFunction, safe: T): T;

export const decodeURI: typeof globalThis.decodeURI;
export const decodeURIComponent: typeof globalThis.decodeURIComponent;
export const encodeURI: typeof globalThis.encodeURI;
Expand Down Expand Up @@ -49,6 +59,7 @@ declare namespace primordials {
export const MathLog2: typeof Math.log2
export const MathLog10: typeof Math.log10
export const MathMax: typeof Math.max
export const MathMaxApply: StaticApply<typeof Math.max>
export const MathMin: typeof Math.min
export const MathPow: typeof Math.pow
export const MathRandom: typeof Math.random
Expand Down Expand Up @@ -100,9 +111,11 @@ declare namespace primordials {
export const ArrayPrototypeLastIndexOf: UncurryThis<typeof Array.prototype.lastIndexOf>
export const ArrayPrototypePop: UncurryThis<typeof Array.prototype.pop>
export const ArrayPrototypePush: UncurryThis<typeof Array.prototype.push>
export const ArrayPrototypePushApply: UncurryThisStaticApply<typeof Array.prototype.push>
export const ArrayPrototypeReverse: UncurryThis<typeof Array.prototype.reverse>
export const ArrayPrototypeShift: UncurryThis<typeof Array.prototype.shift>
export const ArrayPrototypeUnshift: UncurryThis<typeof Array.prototype.unshift>
export const ArrayPrototypeUnshiftApply: UncurryThisStaticApply<typeof Array.prototype.unshift>
export const ArrayPrototypeSlice: UncurryThis<typeof Array.prototype.slice>
export const ArrayPrototypeSort: UncurryThis<typeof Array.prototype.sort>
export const ArrayPrototypeSplice: UncurryThis<typeof Array.prototype.splice>
Expand Down