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

🔧 Toggle on isolatedDeclarations flag on the project #5136

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
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
17 changes: 9 additions & 8 deletions packages/fast-check/src/check/model/commands/CommandWrapper.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import type {
WithAsyncToStringMethod,
WithToStringMethod} from '../../../utils/stringify';
import {
asyncToStringMethod,
hasAsyncToStringMethod,
hasToStringMethod,
toStringMethod,
toStringMethod
} from '../../../utils/stringify';
import { cloneMethod, hasCloneMethod } from '../../symbols';
import type { ICommand } from '../command/ICommand';
Expand All @@ -14,22 +17,20 @@ import type { ICommand } from '../command/ICommand';
export class CommandWrapper<Model extends object, Real, RunResult, CheckAsync extends boolean>
dubzzz marked this conversation as resolved.
Show resolved Hide resolved
implements ICommand<Model, Real, RunResult, CheckAsync>
{
[toStringMethod]?: () => string;
[asyncToStringMethod]?: () => Promise<string>;

hasRan = false;
constructor(readonly cmd: ICommand<Model, Real, RunResult, CheckAsync>) {
if (hasToStringMethod(cmd)) {
const method = cmd[toStringMethod];
this[toStringMethod] = function toStringMethod(): string {
(this as unknown as WithToStringMethod)[toStringMethod] = function toStringMethod(): string {
return method.call(cmd);
};
}
if (hasAsyncToStringMethod(cmd)) {
const method = cmd[asyncToStringMethod];
this[asyncToStringMethod] = function asyncToStringMethod(): Promise<string> {
return method.call(cmd);
};
(this as unknown as WithAsyncToStringMethod)[asyncToStringMethod] =
function asyncToStringMethod(): Promise<string> {
return method.call(cmd);
};
}
}
check(m: Readonly<Model>): CheckAsync extends false ? boolean : Promise<boolean> {
Expand Down
2 changes: 1 addition & 1 deletion packages/fast-check/src/check/symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @remarks Since 1.8.0
* @public
*/
export const cloneMethod = Symbol.for('fast-check/cloneMethod');
export const cloneMethod: unique symbol = Symbol.for('fast-check/cloneMethod');
dubzzz marked this conversation as resolved.
Show resolved Hide resolved

/**
* Object instance that should be cloned from one generation/shrink to another
Expand Down
2 changes: 1 addition & 1 deletion packages/fast-check/src/stream/Stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class Stream<T> implements IterableIterator<T> {
next(): IteratorResult<T> {
return this.g.next();
}
[safeSymbolIterator](): IterableIterator<T> {
[Symbol.iterator](): IterableIterator<T> {
// /*DEBUG*/ this.closeCurrentStream();
return this.g;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/fast-check/src/utils/stringify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const safePositiveInfinity = Number.POSITIVE_INFINITY;
* @remarks Since 2.17.0
* @public
*/
export const toStringMethod = Symbol.for('fast-check/toStringMethod');
export const toStringMethod: unique symbol = Symbol.for('fast-check/toStringMethod');
dubzzz marked this conversation as resolved.
Show resolved Hide resolved
/**
* Interface to implement for {@link toStringMethod}
*
Expand Down Expand Up @@ -62,7 +62,7 @@ export function hasToStringMethod<T>(instance: T): instance is T & WithToStringM
* @remarks Since 2.17.0
* @public
*/
export const asyncToStringMethod = Symbol.for('fast-check/asyncToStringMethod');
export const asyncToStringMethod: unique symbol = Symbol.for('fast-check/asyncToStringMethod');
dubzzz marked this conversation as resolved.
Show resolved Hide resolved
/**
* Interface to implement for {@link asyncToStringMethod}
*
Expand Down
8 changes: 4 additions & 4 deletions packages/poisoning/src/internals/PoisoningFreeArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const safeArraySort = Array.prototype.sort;
const safeObjectDefineProperty = Object.defineProperty;

/** Alias for Array.prototype.map */
export const MapSymbol = Symbol('safe.map');
export const MapSymbol: unique symbol = Symbol('safe.map');
/** Alias for Array.prototype.push */
export const PushSymbol = Symbol('safe.push');
export const PushSymbol: unique symbol = Symbol('safe.push');
/** Alias for Array.prototype.shift */
export const ShiftSymbol = Symbol('safe.shift');
export const ShiftSymbol: unique symbol = Symbol('safe.shift');
/** Alias for Array.prototype.sort */
export const SortSymbol = Symbol('safe.sort');
export const SortSymbol: unique symbol = Symbol('safe.sort');
dubzzz marked this conversation as resolved.
Show resolved Hide resolved

/** Array instance enriched with aliased methods that cannot be poisoned */
export type PoisoningFreeArray<T> = Array<T> & {
Expand Down
8 changes: 4 additions & 4 deletions packages/poisoning/src/internals/PoisoningFreeMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const safeMapSet = Map.prototype.set;
const safeObjectDefineProperty = Object.defineProperty;

/** Alias for Map.prototype.get */
export const GetSymbol = Symbol('safe.get');
export const GetSymbol: unique symbol = Symbol('safe.get');
/** Alias for Map.prototype.has */
export const HasSymbol = Symbol('safe.has');
export const HasSymbol: unique symbol = Symbol('safe.has');
/** Alias for Map.prototype.entries */
export const EntriesSymbol = Symbol('safe.entries');
export const EntriesSymbol: unique symbol = Symbol('safe.entries');
/** Alias for Map.prototype.set */
export const SetSymbol = Symbol('safe.set');
export const SetSymbol: unique symbol = Symbol('safe.set');
dubzzz marked this conversation as resolved.
Show resolved Hide resolved

/** Map instance enriched with aliased methods that cannot be poisoned */
export type PoisoningFreeMap<K, V> = Map<K, V> & {
Expand Down
4 changes: 2 additions & 2 deletions packages/poisoning/src/internals/PoisoningFreeSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const safeSetHas = Set.prototype.has;
const safeObjectDefineProperty = Object.defineProperty;

/** Alias for Set.prototype.add */
export const AddSymbol = Symbol('safe.add');
export const AddSymbol: unique symbol = Symbol('safe.add');
/** Alias for Set.prototype.has */
export const HasSymbol = Symbol('safe.has');
export const HasSymbol: unique symbol = Symbol('safe.has');
dubzzz marked this conversation as resolved.
Show resolved Hide resolved

/** Set instance enriched with aliased methods that cannot be poisoned */
export type PoisoningFreeSet<K> = Set<K> & {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.common.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"noEmit": true,
"declaration": false,
"declaration": true,
"isolatedDeclarations": true,
"incremental": false,
"sourceMap": true,
"target": "es2017",
Expand Down
1 change: 1 addition & 0 deletions tsconfig.publish.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"noEmit": false,
"declaration": false,
"isolatedDeclarations": false,
"removeComments": true,
"sourceMap": false
}
Expand Down
1 change: 1 addition & 0 deletions tsconfig.publish.types.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
"isolatedDeclarations": true,
"removeComments": false,
"sourceMap": false,
"stripInternal": true
Expand Down
Loading