Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Remove some ts-ignores
Browse files Browse the repository at this point in the history
  • Loading branch information
ismail-syed committed Sep 16, 2019
1 parent 71f9f1e commit 11207eb
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 45 deletions.
2 changes: 1 addition & 1 deletion packages/async/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type RequestIdleCallback = (
deadline: RequestIdleCallbackDeadline,
) => void;

export interface WindowWithRequestIdleCallback {
export interface WindowWithRequestIdleCallback extends Window {
requestIdleCallback(
callback: RequestIdleCallback,
opts?: RequestIdleCallbackOptions,
Expand Down
1 change: 0 additions & 1 deletion packages/jest-mock-apollo/src/graphqlClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export default function configureClient({
});

const client = new ApolloClient({
// @ts-ignore
link: memoryLink.concat(mockLink),
cache,
ssrMode,
Expand Down
8 changes: 4 additions & 4 deletions packages/performance/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ export function withEntriesOfType<T extends keyof EntryMap>(
) {
try {
const initialEntries = performance.getEntriesByType(type);
// @ts-ignore
initialEntries.forEach(entry => handler(entry));
initialEntries.forEach(entry => handler(entry as EntryMap[T]));

if (!hasGlobal('PerformanceObserver')) {
return;
}

const observer = new PerformanceObserver(entries => {
// @ts-ignore
entries.getEntriesByType(type).forEach(entry => handler(entry));
entries
.getEntriesByType(type)
.forEach(entry => handler(entry as EntryMap[T]));
});

observer.observe({
Expand Down
4 changes: 1 addition & 3 deletions packages/polyfills/src/idle-callback.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ interface CallbackParams {
didTimeout: boolean;
timeRemaining(): number;
}

interface PolyfilledWindow extends Window {
requestIdleCallback(cb: IdleCallback): any;
cancelIdleCallback(): any;
Expand All @@ -29,8 +28,7 @@ function fallbackQueueingFunction(cb: IdleCallback) {
});
}

// @ts-ignore
const extendedWindow = window as PolyfilledWindow;
const extendedWindow = window as PolyfilledWindow & typeof globalThis;

extendedWindow.requestIdleCallback =
extendedWindow.requestIdleCallback || fallbackQueueingFunction;
Expand Down
3 changes: 1 addition & 2 deletions packages/polyfills/src/idle-callback.jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ function fallbackQueueingFunction(cb: IdleCallback) {
}

if (typeof window !== 'undefined') {
// @ts-ignore
const extendedWindow = window as PolyfilledWindow;
const extendedWindow = window as PolyfilledWindow & typeof globalThis;

extendedWindow.requestIdleCallback =
extendedWindow.requestIdleCallback || fallbackQueueingFunction;
Expand Down
5 changes: 3 additions & 2 deletions packages/react-form-state/src/FormState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,11 @@ export default class FormState<
return;
}

const {validators = {}} = this.props;
const {
validators = {} as Partial<ValidatorDictionary<Fields>>,
} = this.props;
const {fields} = this.state;

// @ts-ignore
return runValidator(validators[fieldPath], value, fields);
}

Expand Down
3 changes: 1 addition & 2 deletions packages/react-graphql/src/hooks/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,5 @@ export default function useMutation<Data = any, Variables = OperationVariables>(
],
);

// @ts-ignore
return runMutation;
return runMutation as MutationHookResult<Data, Variables>;
}
12 changes: 4 additions & 8 deletions packages/react-idle/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ export function useIdleCallback(
useEffect(
() => {
if ('requestIdleCallback' in window) {
// @ts-ignore
handle.current = (window as WindowWithRequestIdleCallback).requestIdleCallback(
() => callback(),
);
handle.current = (window as WindowWithRequestIdleCallback &
typeof globalThis).requestIdleCallback(() => callback());
} else if (unsupportedBehavior === UnsupportedBehavior.AnimationFrame) {
handle.current = window.requestAnimationFrame(() => {
callback();
Expand All @@ -35,10 +33,8 @@ export function useIdleCallback(
}

if ('cancelIdleCallback' in window) {
// @ts-ignore
(window as WindowWithRequestIdleCallback).cancelIdleCallback(
currentHandle,
);
(window as WindowWithRequestIdleCallback &
typeof globalThis).cancelIdleCallback(currentHandle);
} else if (unsupportedBehavior === UnsupportedBehavior.AnimationFrame) {
window.cancelAnimationFrame(currentHandle);
}
Expand Down
6 changes: 2 additions & 4 deletions packages/react-import-remote/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,8 @@ export function useImportRemote<Imported = unknown>(
() => {
if (defer === DeferTiming.Idle) {
if ('requestIdleCallback' in window) {
// @ts-ignore
idleCallbackHandle.current = (window as WindowWithRequestIdleCallback).requestIdleCallback(
loadRemote,
);
idleCallbackHandle.current = (window as WindowWithRequestIdleCallback &
typeof globalThis).requestIdleCallback(loadRemote);
} else {
loadRemote();
}
Expand Down
3 changes: 1 addition & 2 deletions packages/react-import-remote/src/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ export default function load<
function scriptTagOnLoad() {
scriptTag.removeEventListener('load', scriptTagOnLoad);
scriptTag.removeEventListener('error', scriptTagOnError);
// @ts-ignore
resolve(getImport(window as CustomWindow));
resolve(getImport(window as CustomWindow & typeof globalThis));
}

function scriptTagOnError() {
Expand Down
15 changes: 0 additions & 15 deletions packages/react-server-webpack-plugin/tsconfig.build.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/react-server-webpack-plugin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"./src/**/*.ts",
"./src/**/*.tsx"
],
"exclude": ["**/*.test.ts", "**/*.test.tsx"],
"exclude": ["**/*.test.ts", "**/*.test.tsx", "**/*/templates/**/*"],
"references": [{"path": "../react-testing"}]
}

0 comments on commit 11207eb

Please sign in to comment.