chore: use directive @ts-expect-error
instead of @ts-ignore
(#6429)
This commit is contained in:
parent
e1858e6334
commit
fe88f89512
21 changed files with 26 additions and 41 deletions
|
@ -3,12 +3,12 @@ import parser from '@babel/parser';
|
||||||
import traverse from '@babel/traverse';
|
import traverse from '@babel/traverse';
|
||||||
import * as t from '@babel/types';
|
import * as t from '@babel/types';
|
||||||
|
|
||||||
// @ts-ignore @babel/traverse isn't ESM and needs this trick
|
// @ts-expect-error @babel/traverse isn't ESM and needs this trick
|
||||||
export const visit = traverse.default as typeof traverse;
|
export const visit = traverse.default as typeof traverse;
|
||||||
export { t };
|
export { t };
|
||||||
|
|
||||||
export async function generate(ast: t.File) {
|
export async function generate(ast: t.File) {
|
||||||
// @ts-ignore @babel/generator isn't ESM and needs this trick
|
// @ts-expect-error @babel/generator isn't ESM and needs this trick
|
||||||
const astToText = generator.default as typeof generator;
|
const astToText = generator.default as typeof generator;
|
||||||
const { code } = astToText(ast);
|
const { code } = astToText(ast);
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -15,7 +15,6 @@ export function vitePluginInternals(input: Set<string>, internals: BuildInternal
|
||||||
external.push('shiki');
|
external.push('shiki');
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
extra.ssr = {
|
extra.ssr = {
|
||||||
external,
|
external,
|
||||||
noExternal,
|
noExternal,
|
||||||
|
|
|
@ -51,7 +51,7 @@ function createAPIContext({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
url: new URL(request.url),
|
url: new URL(request.url),
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
get clientAddress() {
|
get clientAddress() {
|
||||||
if (!(clientAddressSymbol in request)) {
|
if (!(clientAddressSymbol in request)) {
|
||||||
if (adapterName) {
|
if (adapterName) {
|
||||||
|
|
|
@ -174,7 +174,6 @@ export function createResult(args: CreateResultArgs): SSRResult {
|
||||||
const Astro: AstroGlobal = {
|
const Astro: AstroGlobal = {
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
__proto__: astroGlobal,
|
__proto__: astroGlobal,
|
||||||
// @ts-ignore
|
|
||||||
get clientAddress() {
|
get clientAddress() {
|
||||||
if (!(clientAddressSymbol in request)) {
|
if (!(clientAddressSymbol in request)) {
|
||||||
if (args.adapterName) {
|
if (args.adapterName) {
|
||||||
|
@ -221,7 +220,7 @@ export function createResult(args: CreateResultArgs): SSRResult {
|
||||||
writable: false,
|
writable: false,
|
||||||
// TODO: Remove this hole "Deno" logic once our plugin gets Deno support
|
// TODO: Remove this hole "Deno" logic once our plugin gets Deno support
|
||||||
value: async function (content: string, opts: MarkdownRenderingOptions) {
|
value: async function (content: string, opts: MarkdownRenderingOptions) {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
if (typeof Deno !== 'undefined') {
|
if (typeof Deno !== 'undefined') {
|
||||||
throw new Error('Markdown is not supported in Deno SSR');
|
throw new Error('Markdown is not supported in Deno SSR');
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ const renderer = {
|
||||||
jsxTransformOptions: async () => {
|
jsxTransformOptions: async () => {
|
||||||
const {
|
const {
|
||||||
default: { default: jsx },
|
default: { default: jsx },
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
} = await import('@babel/plugin-transform-react-jsx');
|
} = await import('@babel/plugin-transform-react-jsx');
|
||||||
const { default: astroJSX } = await import('./babel.js');
|
const { default: astroJSX } = await import('./babel.js');
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import type { SSRManifest } from 'astro';
|
import type { SSRManifest } from 'astro';
|
||||||
import { App } from 'astro/app';
|
import { App } from 'astro/app';
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
import { fromFileUrl, serveFile, Server } from '@astrojs/deno/__deno_imports.js';
|
import { fromFileUrl, serveFile, Server } from '@astrojs/deno/__deno_imports.js';
|
||||||
|
|
||||||
interface Options {
|
interface Options {
|
||||||
|
@ -15,7 +15,7 @@ let _server: Server | undefined = undefined;
|
||||||
let _startPromise: Promise<void> | undefined = undefined;
|
let _startPromise: Promise<void> | undefined = undefined;
|
||||||
|
|
||||||
async function* getPrerenderedFiles(clientRoot: URL): AsyncGenerator<URL> {
|
async function* getPrerenderedFiles(clientRoot: URL): AsyncGenerator<URL> {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
for await (const ent of Deno.readDir(clientRoot)) {
|
for await (const ent of Deno.readDir(clientRoot)) {
|
||||||
if (ent.isDirectory) {
|
if (ent.isDirectory) {
|
||||||
yield* getPrerenderedFiles(new URL(`./${ent.name}/`, clientRoot));
|
yield* getPrerenderedFiles(new URL(`./${ent.name}/`, clientRoot));
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { APIRoute } from 'astro';
|
import type { APIRoute } from 'astro';
|
||||||
import mime from 'mime';
|
import mime from 'mime';
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
import loader from 'virtual:image-loader';
|
import loader from 'virtual:image-loader';
|
||||||
import { etag } from './utils/etag.js';
|
import { etag } from './utils/etag.js';
|
||||||
import { isRemoteImage } from './utils/paths.js';
|
import { isRemoteImage } from './utils/paths.js';
|
||||||
|
|
|
@ -111,7 +111,7 @@ export async function getImage(
|
||||||
let loader = globalThis.astroImage?.loader;
|
let loader = globalThis.astroImage?.loader;
|
||||||
|
|
||||||
if (!loader) {
|
if (!loader) {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
const { default: mod } = await import('virtual:image-loader').catch(() => {
|
const { default: mod } = await import('virtual:image-loader').catch(() => {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'[@astrojs/image] Builtin image loader not found. (Did you remember to add the integration to your Astro config?)'
|
'[@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(
|
||||||
const attributes = await loader.getImageAttributes(resolved);
|
const attributes = await loader.getImageAttributes(resolved);
|
||||||
|
|
||||||
// `.env` must be optional to support running in environments outside of `vite` (such as `astro.config`)
|
// `.env` must be optional to support running in environments outside of `vite` (such as `astro.config`)
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
const isDev = import.meta.env?.DEV;
|
const isDev = import.meta.env?.DEV;
|
||||||
const isLocalImage = !isRemoteImage(resolved.src);
|
const isLocalImage = !isRemoteImage(resolved.src);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
// @ts-ignore
|
|
||||||
import { red } from 'kleur/colors';
|
import { red } from 'kleur/colors';
|
||||||
import { error } from '../utils/logger.js';
|
import { error } from '../utils/logger.js';
|
||||||
import { metadata } from '../utils/metadata.js';
|
import { metadata } from '../utils/metadata.js';
|
||||||
|
|
|
@ -35,46 +35,37 @@ export interface RotateOptions {
|
||||||
|
|
||||||
// MozJPEG
|
// MozJPEG
|
||||||
import type { MozJPEGModule as MozJPEGEncodeModule } from './mozjpeg/mozjpeg_enc'
|
import type { MozJPEGModule as MozJPEGEncodeModule } from './mozjpeg/mozjpeg_enc'
|
||||||
// @ts-ignore
|
|
||||||
import mozEnc from './mozjpeg/mozjpeg_node_enc.js'
|
import mozEnc from './mozjpeg/mozjpeg_node_enc.js'
|
||||||
const mozEncWasm = new URL('./mozjpeg/mozjpeg_node_enc.wasm', getModuleURL(import.meta.url))
|
const mozEncWasm = new URL('./mozjpeg/mozjpeg_node_enc.wasm', getModuleURL(import.meta.url))
|
||||||
// @ts-ignore
|
|
||||||
import mozDec from './mozjpeg/mozjpeg_node_dec.js'
|
import mozDec from './mozjpeg/mozjpeg_node_dec.js'
|
||||||
const mozDecWasm = new URL('./mozjpeg/mozjpeg_node_dec.wasm', getModuleURL(import.meta.url))
|
const mozDecWasm = new URL('./mozjpeg/mozjpeg_node_dec.wasm', getModuleURL(import.meta.url))
|
||||||
|
|
||||||
// WebP
|
// WebP
|
||||||
import type { WebPModule as WebPEncodeModule } from './webp/webp_enc'
|
import type { WebPModule as WebPEncodeModule } from './webp/webp_enc'
|
||||||
// @ts-ignore
|
|
||||||
import webpEnc from './webp/webp_node_enc.js'
|
import webpEnc from './webp/webp_node_enc.js'
|
||||||
const webpEncWasm = new URL('./webp/webp_node_enc.wasm', getModuleURL(import.meta.url))
|
const webpEncWasm = new URL('./webp/webp_node_enc.wasm', getModuleURL(import.meta.url))
|
||||||
// @ts-ignore
|
|
||||||
import webpDec from './webp/webp_node_dec.js'
|
import webpDec from './webp/webp_node_dec.js'
|
||||||
const webpDecWasm = new URL('./webp/webp_node_dec.wasm', getModuleURL(import.meta.url))
|
const webpDecWasm = new URL('./webp/webp_node_dec.wasm', getModuleURL(import.meta.url))
|
||||||
|
|
||||||
// AVIF
|
// AVIF
|
||||||
import type { AVIFModule as AVIFEncodeModule } from './avif/avif_enc'
|
import type { AVIFModule as AVIFEncodeModule } from './avif/avif_enc'
|
||||||
// @ts-ignore
|
|
||||||
import avifEnc from './avif/avif_node_enc.js'
|
import avifEnc from './avif/avif_node_enc.js'
|
||||||
const avifEncWasm = new URL('./avif/avif_node_enc.wasm', getModuleURL(import.meta.url))
|
const avifEncWasm = new URL('./avif/avif_node_enc.wasm', getModuleURL(import.meta.url))
|
||||||
// @ts-ignore
|
|
||||||
import avifDec from './avif/avif_node_dec.js'
|
import avifDec from './avif/avif_node_dec.js'
|
||||||
const avifDecWasm = new URL('./avif/avif_node_dec.wasm', getModuleURL(import.meta.url))
|
const avifDecWasm = new URL('./avif/avif_node_dec.wasm', getModuleURL(import.meta.url))
|
||||||
|
|
||||||
// PNG
|
// PNG
|
||||||
// @ts-ignore
|
|
||||||
import * as pngEncDec from './png/squoosh_png.js'
|
import * as pngEncDec from './png/squoosh_png.js'
|
||||||
const pngEncDecWasm = new URL('./png/squoosh_png_bg.wasm', getModuleURL(import.meta.url))
|
const pngEncDecWasm = new URL('./png/squoosh_png_bg.wasm', getModuleURL(import.meta.url))
|
||||||
const pngEncDecInit = () =>
|
const pngEncDecInit = () =>
|
||||||
pngEncDec.default(fsp.readFile(pathify(pngEncDecWasm.toString())))
|
pngEncDec.default(fsp.readFile(pathify(pngEncDecWasm.toString())))
|
||||||
|
|
||||||
// OxiPNG
|
// OxiPNG
|
||||||
// @ts-ignore
|
|
||||||
import * as oxipng from './png/squoosh_oxipng.js'
|
import * as oxipng from './png/squoosh_oxipng.js'
|
||||||
const oxipngWasm = new URL('./png/squoosh_oxipng_bg.wasm', getModuleURL(import.meta.url))
|
const oxipngWasm = new URL('./png/squoosh_oxipng_bg.wasm', getModuleURL(import.meta.url))
|
||||||
const oxipngInit = () => oxipng.default(fsp.readFile(pathify(oxipngWasm.toString())))
|
const oxipngInit = () => oxipng.default(fsp.readFile(pathify(oxipngWasm.toString())))
|
||||||
|
|
||||||
// Resize
|
// Resize
|
||||||
// @ts-ignore
|
|
||||||
import * as resize from './resize/squoosh_resize.js'
|
import * as resize from './resize/squoosh_resize.js'
|
||||||
const resizeWasm = new URL('./resize/squoosh_resize_bg.wasm', getModuleURL(import.meta.url))
|
const resizeWasm = new URL('./resize/squoosh_resize_bg.wasm', getModuleURL(import.meta.url))
|
||||||
const resizeInit = () => resize.default(fsp.readFile(pathify(resizeWasm.toString())))
|
const resizeInit = () => resize.default(fsp.readFile(pathify(resizeWasm.toString())))
|
||||||
|
|
|
@ -91,7 +91,6 @@ export async function processBuffer(
|
||||||
encoding: OutputFormat,
|
encoding: OutputFormat,
|
||||||
quality?: number
|
quality?: number
|
||||||
): Promise<Uint8Array> {
|
): Promise<Uint8Array> {
|
||||||
// @ts-ignore
|
|
||||||
const worker = await getWorker();
|
const worker = await getWorker();
|
||||||
|
|
||||||
let imageData = await worker.dispatchJob({
|
let imageData = await worker.dispatchJob({
|
||||||
|
|
|
@ -44,7 +44,6 @@ export async function decodeBuffer(
|
||||||
const encoder = supportedFormats[key]
|
const encoder = supportedFormats[key]
|
||||||
const mod = await encoder.dec()
|
const mod = await encoder.dec()
|
||||||
const rgba = mod.decode(new Uint8Array(buffer))
|
const rgba = mod.decode(new Uint8Array(buffer))
|
||||||
// @ts-ignore
|
|
||||||
return rgba
|
return rgba
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
import { runBuild } from './test-utils.ts';
|
import { runBuild } from './test-utils.ts';
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
import { assertEquals, assert, DOMParser } from './deps.ts';
|
import { assertEquals, assert, DOMParser } from './deps.ts';
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
Deno.env.set('SECRET_STUFF', 'secret');
|
Deno.env.set('SECRET_STUFF', 'secret');
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
Deno.test({
|
Deno.test({
|
||||||
// TODO: debug why build cannot be found in "await import"
|
// TODO: debug why build cannot be found in "await import"
|
||||||
ignore: true,
|
ignore: true,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
import { runBuild } from './test-utils.ts';
|
import { runBuild } from './test-utils.ts';
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
import { assertEquals } from './deps.ts';
|
import { assertEquals } from './deps.ts';
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
Deno.test({
|
Deno.test({
|
||||||
name: 'Prerender',
|
name: 'Prerender',
|
||||||
async fn() {
|
async fn() {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
import { runBuild } from './test-utils.ts';
|
import { runBuild } from './test-utils.ts';
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
import { assertEquals, assert, DOMParser } from './deps.ts';
|
import { assertEquals, assert, DOMParser } from './deps.ts';
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
Deno.test({
|
Deno.test({
|
||||||
// TODO: debug why build cannot be found in "await import"
|
// TODO: debug why build cannot be found in "await import"
|
||||||
ignore: true,
|
ignore: true,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
import { fromFileUrl, readableStreamFromReader } from './deps.ts';
|
import { fromFileUrl, readableStreamFromReader } from './deps.ts';
|
||||||
const dir = new URL('./', import.meta.url);
|
const dir = new URL('./', import.meta.url);
|
||||||
|
|
||||||
export async function runBuild(fixturePath: string) {
|
export async function runBuild(fixturePath: string) {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
let proc = Deno.run({
|
let proc = Deno.run({
|
||||||
cmd: ['node', '../../../../../../astro/astro.js', 'build', '--silent'],
|
cmd: ['node', '../../../../../../astro/astro.js', 'build', '--silent'],
|
||||||
cwd: fromFileUrl(new URL(fixturePath, dir)),
|
cwd: fromFileUrl(new URL(fixturePath, dir)),
|
||||||
|
|
|
@ -70,7 +70,7 @@ function readerIterator<T>(reader: ReadableStreamDefaultReader<T>): AsyncIterabl
|
||||||
|
|
||||||
if (canUseAsyncIteratorSymbol) {
|
if (canUseAsyncIteratorSymbol) {
|
||||||
iterator[Symbol.asyncIterator] = function (): AsyncIterator<T> {
|
iterator[Symbol.asyncIterator] = function (): AsyncIterator<T> {
|
||||||
//@ts-ignore
|
//@ts-expect-error
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
// @ts-ignore
|
|
||||||
import 'preact/debug';
|
import 'preact/debug';
|
||||||
import clientFn from './client.js';
|
import clientFn from './client.js';
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ function prefixError(err: any, prefix: string) {
|
||||||
const wrappedError = new Error(`${prefix}${err ? `: ${err}` : ''}`);
|
const wrappedError = new Error(`${prefix}${err ? `: ${err}` : ''}`);
|
||||||
try {
|
try {
|
||||||
wrappedError.stack = err.stack;
|
wrappedError.stack = err.stack;
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
wrappedError.cause = err;
|
wrappedError.cause = err;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// It's ok if we could not set the stack or cause - the message is the most important part
|
// It's ok if we could not set the stack or cause - the message is the most important part
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { HTMLImageElement } from './HTMLImageElement'
|
||||||
import * as _ from './utils'
|
import * as _ from './utils'
|
||||||
|
|
||||||
export function Image() {
|
export function Image() {
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
_.INTERNALS.set(this, {
|
_.INTERNALS.set(this, {
|
||||||
attributes: {},
|
attributes: {},
|
||||||
localName: 'img',
|
localName: 'img',
|
||||||
|
|
|
@ -17,7 +17,7 @@ export const __object_isPrototypeOf = Function.call.bind(
|
||||||
/** Current high resolution millisecond timestamp. */
|
/** Current high resolution millisecond timestamp. */
|
||||||
export const __performance_now = performance.now as () => number
|
export const __performance_now = performance.now as () => number
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-expect-error
|
||||||
export const INTERNALS = new WeakMap<unknown, any>()
|
export const INTERNALS = new WeakMap<unknown, any>()
|
||||||
|
|
||||||
export const internalsOf = <T extends object>(
|
export const internalsOf = <T extends object>(
|
||||||
|
|
Loading…
Add table
Reference in a new issue