/
githubmirror
/
babel
Обзор
Документация
Войти
/
githubmirror
/
babel
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/babel-plugin-transform-numeric-separator/src/index.ts
30 строк
848 B
Nicolò Ribaudo
Update publishing process for Babel 8 (#17660)
09 янв 2026, 20:05
Не верифицирован
09 янв 2026, 20:05
e537efa
Код
Авторство
О чём код?
import { declare } from "@babel/helper-plugin-utils"; import type { NodePath, types as t } from "@babel/core"; /** * Given a bigIntLiteral or NumericLiteral, remove numeric * separator `_` from its raw representation * * @param {NodePath<BigIntLiteral | NumericLiteral>} { node }: A Babel AST node path */ function remover({ node }: NodePath<t.BigIntLiteral | t.NumericLiteral>) { const { extra } = node; // @ts-expect-error todo(flow->ts) if (extra?.raw?.includes("_")) { // @ts-expect-error todo(flow->ts) extra.raw = extra.raw.replace(/_/g, ""); } } export default declare(api => { api.assertVersion(REQUIRED_VERSION("^7.0.0-0 || ^8.0.0")); return { name: "transform-numeric-separator", manipulateOptions: undefined, visitor: { NumericLiteral: remover, BigIntLiteral: remover, }, }; });