Skip to content

Commit fe88f89

Browse files
authored
chore: use directive @ts-expect-error instead of @ts-ignore (#6429)
1 parent e1858e6 commit fe88f89

File tree

21 files changed

+26
-41
lines changed

21 files changed

+26
-41
lines changed

packages/astro/src/core/add/babel.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import parser from '@babel/parser';
33
import traverse from '@babel/traverse';
44
import * as t from '@babel/types';
55

6-
// @ts-ignore @babel/traverse isn't ESM and needs this trick
6+
// @ts-expect-error @babel/traverse isn't ESM and needs this trick
77
export const visit = traverse.default as typeof traverse;
88
export { t };
99

1010
export async function generate(ast: t.File) {
11-
// @ts-ignore @babel/generator isn't ESM and needs this trick
11+
// @ts-expect-error @babel/generator isn't ESM and needs this trick
1212
const astToText = generator.default as typeof generator;
1313
const { code } = astToText(ast);
1414
return code;

packages/astro/src/core/build/plugins/plugin-internals.ts

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export function vitePluginInternals(input: Set<string>, internals: BuildInternal
1515
external.push('shiki');
1616
}
1717

18-
// @ts-ignore
1918
extra.ssr = {
2019
external,
2120
noExternal,

packages/astro/src/core/endpoint/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function createAPIContext({
5151
});
5252
},
5353
url: new URL(request.url),
54-
// @ts-ignore
54+
// @ts-expect-error
5555
get clientAddress() {
5656
if (!(clientAddressSymbol in request)) {
5757
if (adapterName) {

packages/astro/src/core/render/result.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ export function createResult(args: CreateResultArgs): SSRResult {
174174
const Astro: AstroGlobal = {
175175
// @ts-expect-error
176176
__proto__: astroGlobal,
177-
// @ts-ignore
178177
get clientAddress() {
179178
if (!(clientAddressSymbol in request)) {
180179
if (args.adapterName) {
@@ -221,7 +220,7 @@ export function createResult(args: CreateResultArgs): SSRResult {
221220
writable: false,
222221
// TODO: Remove this hole "Deno" logic once our plugin gets Deno support
223222
value: async function (content: string, opts: MarkdownRenderingOptions) {
224-
// @ts-ignore
223+
// @ts-expect-error
225224
if (typeof Deno !== 'undefined') {
226225
throw new Error('Markdown is not supported in Deno SSR');
227226
}

packages/astro/src/jsx/renderer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const renderer = {
55
jsxTransformOptions: async () => {
66
const {
77
default: { default: jsx },
8-
// @ts-ignore
8+
// @ts-expect-error
99
} = await import('@babel/plugin-transform-react-jsx');
1010
const { default: astroJSX } = await import('./babel.js');
1111
return {

packages/integrations/deno/src/server.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import type { SSRManifest } from 'astro';
33
import { App } from 'astro/app';
44

5-
// @ts-ignore
5+
// @ts-expect-error
66
import { fromFileUrl, serveFile, Server } from '@astrojs/deno/__deno_imports.js';
77

88
interface Options {
@@ -15,7 +15,7 @@ let _server: Server | undefined = undefined;
1515
let _startPromise: Promise<void> | undefined = undefined;
1616

1717
async function* getPrerenderedFiles(clientRoot: URL): AsyncGenerator<URL> {
18-
// @ts-ignore
18+
// @ts-expect-error
1919
for await (const ent of Deno.readDir(clientRoot)) {
2020
if (ent.isDirectory) {
2121
yield* getPrerenderedFiles(new URL(`./${ent.name}/`, clientRoot));

packages/integrations/image/src/endpoint.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { APIRoute } from 'astro';
22
import mime from 'mime';
3-
// @ts-ignore
3+
// @ts-expect-error
44
import loader from 'virtual:image-loader';
55
import { etag } from './utils/etag.js';
66
import { isRemoteImage } from './utils/paths.js';

packages/integrations/image/src/lib/get-image.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export async function getImage(
111111
let loader = globalThis.astroImage?.loader;
112112

113113
if (!loader) {
114-
// @ts-ignore
114+
// @ts-expect-error
115115
const { default: mod } = await import('virtual:image-loader').catch(() => {
116116
throw new Error(
117117
'[@astrojs/image] Builtin image loader not found. (Did you remember to add the integration to your Astro config?)'
@@ -127,7 +127,7 @@ export async function getImage(
127127
const attributes = await loader.getImageAttributes(resolved);
128128

129129
// `.env` must be optional to support running in environments outside of `vite` (such as `astro.config`)
130-
// @ts-ignore
130+
// @ts-expect-error
131131
const isDev = import.meta.env?.DEV;
132132
const isLocalImage = !isRemoteImage(resolved.src);
133133

packages/integrations/image/src/loaders/squoosh.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @ts-ignore
21
import { red } from 'kleur/colors';
32
import { error } from '../utils/logger.js';
43
import { metadata } from '../utils/metadata.js';

packages/integrations/image/src/vendor/squoosh/codecs.ts

-9
Original file line numberDiff line numberDiff line change
@@ -35,46 +35,37 @@ export interface RotateOptions {
3535

3636
// MozJPEG
3737
import type { MozJPEGModule as MozJPEGEncodeModule } from './mozjpeg/mozjpeg_enc'
38-
// @ts-ignore
3938
import mozEnc from './mozjpeg/mozjpeg_node_enc.js'
4039
const mozEncWasm = new URL('./mozjpeg/mozjpeg_node_enc.wasm', getModuleURL(import.meta.url))
41-
// @ts-ignore
4240
import mozDec from './mozjpeg/mozjpeg_node_dec.js'
4341
const mozDecWasm = new URL('./mozjpeg/mozjpeg_node_dec.wasm', getModuleURL(import.meta.url))
4442

4543
// WebP
4644
import type { WebPModule as WebPEncodeModule } from './webp/webp_enc'
47-
// @ts-ignore
4845
import webpEnc from './webp/webp_node_enc.js'
4946
const webpEncWasm = new URL('./webp/webp_node_enc.wasm', getModuleURL(import.meta.url))
50-
// @ts-ignore
5147
import webpDec from './webp/webp_node_dec.js'
5248
const webpDecWasm = new URL('./webp/webp_node_dec.wasm', getModuleURL(import.meta.url))
5349

5450
// AVIF
5551
import type { AVIFModule as AVIFEncodeModule } from './avif/avif_enc'
56-
// @ts-ignore
5752
import avifEnc from './avif/avif_node_enc.js'
5853
const avifEncWasm = new URL('./avif/avif_node_enc.wasm', getModuleURL(import.meta.url))
59-
// @ts-ignore
6054
import avifDec from './avif/avif_node_dec.js'
6155
const avifDecWasm = new URL('./avif/avif_node_dec.wasm', getModuleURL(import.meta.url))
6256

6357
// PNG
64-
// @ts-ignore
6558
import * as pngEncDec from './png/squoosh_png.js'
6659
const pngEncDecWasm = new URL('./png/squoosh_png_bg.wasm', getModuleURL(import.meta.url))
6760
const pngEncDecInit = () =>
6861
pngEncDec.default(fsp.readFile(pathify(pngEncDecWasm.toString())))
6962

7063
// OxiPNG
71-
// @ts-ignore
7264
import * as oxipng from './png/squoosh_oxipng.js'
7365
const oxipngWasm = new URL('./png/squoosh_oxipng_bg.wasm', getModuleURL(import.meta.url))
7466
const oxipngInit = () => oxipng.default(fsp.readFile(pathify(oxipngWasm.toString())))
7567

7668
// Resize
77-
// @ts-ignore
7869
import * as resize from './resize/squoosh_resize.js'
7970
const resizeWasm = new URL('./resize/squoosh_resize_bg.wasm', getModuleURL(import.meta.url))
8071
const resizeInit = () => resize.default(fsp.readFile(pathify(resizeWasm.toString())))

packages/integrations/image/src/vendor/squoosh/image-pool.ts

-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ export async function processBuffer(
9191
encoding: OutputFormat,
9292
quality?: number
9393
): Promise<Uint8Array> {
94-
// @ts-ignore
9594
const worker = await getWorker();
9695

9796
let imageData = await worker.dispatchJob({

packages/integrations/image/src/vendor/squoosh/impl.ts

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export async function decodeBuffer(
4444
const encoder = supportedFormats[key]
4545
const mod = await encoder.dec()
4646
const rgba = mod.decode(new Uint8Array(buffer))
47-
// @ts-ignore
4847
return rgba
4948
}
5049

packages/integrations/netlify/test/edge-functions/edge-basic.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// @ts-ignore
1+
// @ts-expect-error
22
import { runBuild } from './test-utils.ts';
3-
// @ts-ignore
3+
// @ts-expect-error
44
import { assertEquals, assert, DOMParser } from './deps.ts';
55

6-
// @ts-ignore
6+
// @ts-expect-error
77
Deno.env.set('SECRET_STUFF', 'secret');
88

9-
// @ts-ignore
9+
// @ts-expect-error
1010
Deno.test({
1111
// TODO: debug why build cannot be found in "await import"
1212
ignore: true,

packages/integrations/netlify/test/edge-functions/prerender.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// @ts-ignore
1+
// @ts-expect-error
22
import { runBuild } from './test-utils.ts';
3-
// @ts-ignore
3+
// @ts-expect-error
44
import { assertEquals } from './deps.ts';
55

6-
// @ts-ignore
6+
// @ts-expect-error
77
Deno.test({
88
name: 'Prerender',
99
async fn() {

packages/integrations/netlify/test/edge-functions/root-dynamic.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// @ts-ignore
1+
// @ts-expect-error
22
import { runBuild } from './test-utils.ts';
3-
// @ts-ignore
3+
// @ts-expect-error
44
import { assertEquals, assert, DOMParser } from './deps.ts';
55

6-
// @ts-ignore
6+
// @ts-expect-error
77
Deno.test({
88
// TODO: debug why build cannot be found in "await import"
99
ignore: true,

packages/integrations/netlify/test/edge-functions/test-utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// @ts-ignore
1+
// @ts-expect-error
22
import { fromFileUrl, readableStreamFromReader } from './deps.ts';
33
const dir = new URL('./', import.meta.url);
44

55
export async function runBuild(fixturePath: string) {
6-
// @ts-ignore
6+
// @ts-expect-error
77
let proc = Deno.run({
88
cmd: ['node', '../../../../../../astro/astro.js', 'build', '--silent'],
99
cwd: fromFileUrl(new URL(fixturePath, dir)),

packages/integrations/node/src/response-iterator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function readerIterator<T>(reader: ReadableStreamDefaultReader<T>): AsyncIterabl
7070

7171
if (canUseAsyncIteratorSymbol) {
7272
iterator[Symbol.asyncIterator] = function (): AsyncIterator<T> {
73-
//@ts-ignore
73+
//@ts-expect-error
7474
return this;
7575
};
7676
}

packages/integrations/preact/src/client-dev.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @ts-ignore
21
import 'preact/debug';
32
import clientFn from './client.js';
43

packages/markdown/remark/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ function prefixError(err: any, prefix: string) {
144144
const wrappedError = new Error(`${prefix}${err ? `: ${err}` : ''}`);
145145
try {
146146
wrappedError.stack = err.stack;
147-
// @ts-ignore
147+
// @ts-expect-error
148148
wrappedError.cause = err;
149149
} catch (error) {
150150
// It's ok if we could not set the stack or cause - the message is the most important part

packages/webapi/src/lib/Image.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { HTMLImageElement } from './HTMLImageElement'
22
import * as _ from './utils'
33

44
export function Image() {
5-
// @ts-ignore
5+
// @ts-expect-error
66
_.INTERNALS.set(this, {
77
attributes: {},
88
localName: 'img',

packages/webapi/src/lib/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const __object_isPrototypeOf = Function.call.bind(
1717
/** Current high resolution millisecond timestamp. */
1818
export const __performance_now = performance.now as () => number
1919

20-
// @ts-ignore
20+
// @ts-expect-error
2121
export const INTERNALS = new WeakMap<unknown, any>()
2222

2323
export const internalsOf = <T extends object>(

0 commit comments

Comments
 (0)