未验证 提交 57535b5a 编写于 作者: M Maxi Gimenez 提交者: GitHub

chore(next/build/babel): missing types (#13189)

上级 da5a05dc
import { NodePath, PluginObj, types } from '@babel/core'
export default function AmpAttributePatcher(...args: any): PluginObj {
export default function AmpAttributePatcher(): PluginObj {
return {
visitor: {
JSXOpeningElement(path: NodePath<types.JSXOpeningElement>) {
......
......@@ -4,7 +4,7 @@ import { PageConfig } from 'next/types'
const STRING_LITERAL_DROP_BUNDLE = '__NEXT_DROP_CLIENT_FILE__'
// replace program path with just a variable with the drop identifier
function replaceBundle(path: any, t: typeof BabelTypes) {
function replaceBundle(path: any, t: typeof BabelTypes): void {
path.parentPath.replaceWith(
t.program(
[
......@@ -24,7 +24,7 @@ function replaceBundle(path: any, t: typeof BabelTypes) {
)
}
function errorMessage(state: any, details: string) {
function errorMessage(state: any, details: string): string {
const pageName =
(state.filename || '').split(state.cwd || '').pop() || 'unknown'
return `Invalid page config export found. ${details} in file ${pageName}. See: https://err.sh/zeit/next.js/invalid-page-config`
......
......@@ -33,7 +33,7 @@ function decorateSsgExport(
t: typeof BabelTypes,
path: NodePath<BabelTypes.Program>,
state: PluginState
) {
): void {
const gsspName = state.isPrerender ? STATIC_PROPS_ID : SERVER_PROPS_ID
const gsspId = t.identifier(gsspName)
......@@ -41,7 +41,7 @@ function decorateSsgExport(
path: NodePath<
BabelTypes.ExportDefaultDeclaration | BabelTypes.ExportNamedDeclaration
>
) => {
): void => {
if (state.done) {
return
}
......@@ -156,7 +156,7 @@ export default function nextTransformSsg({
| BabelTypes.ArrowFunctionExpression
>,
state: PluginState
) {
): void {
const ident = getIdentifier(path)
if (ident?.node && isIdentifierReferenced(ident)) {
state.refs.add(ident)
......@@ -170,7 +170,7 @@ export default function nextTransformSsg({
| BabelTypes.ImportNamespaceSpecifier
>,
state: PluginState
) {
): void {
const local = path.get('local')
if (isIdentifierReferenced(local)) {
state.refs.add(local)
......@@ -314,7 +314,7 @@ export default function nextTransformSsg({
| BabelTypes.FunctionExpression
| BabelTypes.ArrowFunctionExpression
>
) {
): void {
const ident = getIdentifier(path)
if (
ident?.node &&
......@@ -340,7 +340,7 @@ export default function nextTransformSsg({
| BabelTypes.ImportDefaultSpecifier
| BabelTypes.ImportNamespaceSpecifier
>
) {
): void {
const local = path.get('local')
if (refs.has(local) && !isIdentifierReferenced(local)) {
++count
......
......@@ -54,7 +54,7 @@ type BabelPreset = {
}
// Taken from https://github.com/babel/babel/commit/d60c5e1736543a6eac4b549553e107a9ba967051#diff-b4beead8ad9195361b4537601cc22532R158
function supportsStaticESM(caller: any) {
function supportsStaticESM(caller: any): boolean {
return !!caller?.supportsStaticESM
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册