fix types

This commit is contained in:
Vendicated 2024-07-19 20:45:01 +02:00
parent 22fdde6e39
commit 44cd30b23a
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18

View file

@ -16,15 +16,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* @param {string} filePath
* @returns {string | null}
*/
export function getPluginTarget(filePath) {
export function getPluginTarget(filePath: string) {
const pathParts = filePath.split(/[/\\]/);
if (/^index\.tsx?$/.test(pathParts.at(-1))) pathParts.pop();
if (/^index\.tsx?$/.test(pathParts.at(-1)!)) pathParts.pop();
const identifier = pathParts.at(-1).replace(/\.tsx?$/, "");
const identifier = pathParts.at(-1)!.replace(/\.tsx?$/, "");
const identiferBits = identifier.split(".");
return identiferBits.length === 1 ? null : identiferBits.at(-1);
}