From f7e2d23a206bb8403878a319019dbc716b743635 Mon Sep 17 00:00:00 2001 From: prisis Date: Wed, 18 Sep 2024 22:29:36 +0200 Subject: [PATCH] fix: improved types --- packages/packem/src/constants.ts | 5 +++-- .../src/rollup/plugins/chunk-splitter/parse/index.ts | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/packem/src/constants.ts b/packages/packem/src/constants.ts index ff134ee86..303e38134 100644 --- a/packages/packem/src/constants.ts +++ b/packages/packem/src/constants.ts @@ -42,9 +42,10 @@ export const SPECIAL_EXPORT_CONVENTIONS: Set = new Set([DEVELOPM export const EXCLUDE_REGEXP: RegExp = /node_modules/; // eslint-disable-next-line @typescript-eslint/no-inferrable-types -export const ENDING_RE: RegExp = /(?:\.d\.[mc]?ts|\.\w+)$/; +export const ENDING_RE: RegExp = /(?:\.d\.[mc]?tsx?|\.\w+)$/; export const CHUNKS_PACKEM_FOLDER = "packem_chunks"; export const SHARED_PACKEM_FOLDER = "packem_shared"; -export const ALLOWED_TRANSFORM_EXTENSIONS_REGEX = /\.(?:m|c)?(?:j|t)sx?$/; +// eslint-disable-next-line @typescript-eslint/no-inferrable-types +export const ALLOWED_TRANSFORM_EXTENSIONS_REGEX: RegExp = /\.(?:m|c)?(?:j|t)sx?$/; diff --git a/packages/packem/src/rollup/plugins/chunk-splitter/parse/index.ts b/packages/packem/src/rollup/plugins/chunk-splitter/parse/index.ts index bda7bd8fe..2f5ce1d77 100644 --- a/packages/packem/src/rollup/plugins/chunk-splitter/parse/index.ts +++ b/packages/packem/src/rollup/plugins/chunk-splitter/parse/index.ts @@ -4,7 +4,7 @@ import assert from "node:assert/strict"; import { extractAssignedNames } from "@rollup/pluginutils"; -import type { ExportAllDeclaration, ExportNamedDeclaration } from "estree"; +import type { ExportAllDeclaration, ExportNamedDeclaration, Identifier } from "estree"; import type { ModuleInfo, PluginContext } from "rollup"; import type { ParsedExportInfo } from "./types"; @@ -45,8 +45,8 @@ const parseExportNamed = function* (statement: ExportNamedDeclaration): Generato yield { bindings: statement.specifiers.map((specifier) => { return { - exportedName: specifier.exported.name, - importedName: specifier.local.name, + exportedName: (specifier.exported as Identifier).name, + importedName: (specifier.local as Identifier).name, }; }), from: "other", @@ -56,7 +56,7 @@ const parseExportNamed = function* (statement: ExportNamedDeclaration): Generato } else { for (const specifier of statement.specifiers) { yield { - exportedName: specifier.exported.name, + exportedName: (specifier.exported as Identifier).name, from: "self", type: "named", }; @@ -67,7 +67,7 @@ const parseExportNamed = function* (statement: ExportNamedDeclaration): Generato const parseExportAll = function* (statement: ExportAllDeclaration): Generator { if (statement.exported) { yield { - exportedName: statement.exported.name, + exportedName: (statement.exported as Identifier).name, from: "self", type: "named", };