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

Ensure no implicit @types/ includes #912

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 4 additions & 3 deletions source/structured-cloneable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ type StructuredCloneableData =
| Date
| Error
| RegExp
| TypedArray
| Blob
| File;
| TypedArray;
// Requires DOM or @types/node
// | Blob
// | File
// DOM exclusive types
// | AudioData
// | CropTarget
Expand Down
5 changes: 2 additions & 3 deletions test-d/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import {expectAssignable, expectNotAssignable, expectType} from 'tsd';
import type {Class, Constructor, IsAny} from '../index';

class Foo {
constructor(x: number, y: any) {
console.log(x, y);
}
// eslint-disable-next-line @typescript-eslint/no-useless-constructor, @typescript-eslint/no-empty-function
constructor(_x: number, _y: any) {}

// eslint-disable-next-line @typescript-eslint/no-empty-function
method(): void {}
Expand Down
2 changes: 0 additions & 2 deletions test-d/multidimensional-array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ function createArray<T extends number>(dimensions: T): MultidimensionalArray<unk

let array = root;
for (let dimension = 1; dimension < dimensions; ++dimension) {
console.log(`Initializing dimension #${dimension}`);

array[0] = [];
array = array[0] as unknown[];
}
Expand Down
2 changes: 0 additions & 2 deletions test-d/multidimensional-readonly-array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ function createArray<T extends number>(dimensions: T): MultidimensionalReadonlyA

let array = root;
for (let dimension = 1; dimension < dimensions; ++dimension) {
console.log(`Initializing dimension #${dimension}`);

array[0] = [];
if (dimension < dimensions - 1) {
array = array[0] as unknown[];
Expand Down
7 changes: 7 additions & 0 deletions test-d/set-parameter-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ function function_(_a: number, _b: string, _c: Object, ..._arguments: boolean[])
return null;
}

// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore Global requires @types/node
function functionWithThis(this: Global, _a: number) {
return null;
}
Expand Down Expand Up @@ -41,5 +43,10 @@ expectType<(a: string) => null>(test5);

// Test the function that has `this` parameter
declare const testThis: SetParameterType<typeof functionWithThis, {0: string}>;
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore Global requires @types/node
expectType<(this: Global, a: string) => null>(testThis);
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore global requires @types/node
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
testThis.call(global, '1');
4 changes: 4 additions & 0 deletions test-d/structured-cloneable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ expectAssignable<StructuredCloneable>(new Set<string[]>());
expectAssignable<StructuredCloneable>(new Set<Set<string>>());

// Web/API types
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore Requires dom or @types/node@>=20
declare const blob: Blob;
expectAssignable<StructuredCloneable>(blob);
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore Requires dom or @types/node@>=20
declare const file: File;
expectAssignable<StructuredCloneable>(file);
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"lib": [
"ES2021",
],
"types": [], // Ensures no @types/ are unintentionally included
"exactOptionalPropertyTypes": true,
"skipLibCheck": false, // Ensures .d.ts files are checked: https://github.com/sindresorhus/tsconfig/issues/15

Expand Down