问题描述
所以我已经转向在我的项目中使用 Yup 库进行表单验证,但是当我安装它时(并在此之后尝试了很多次),我一直遇到这个非常奇怪的库错误。
我完全不知道如何解决这个问题。任何帮助将不胜感激。
C:/Users/x/Documents/y/frontend/node_modules/yup/lib/array.d.ts
TypeScript error in C:/Users/x/Documents/y/frontend/node_modules/yup/lib/array.d.ts(2,13):
'=' expected. TS1005
1 | import { MixedLocale } from './locale';
> 2 | import type { AnyObject,InternalOptions,Callback,Message,Maybe,Preserve,Optionals } from './types';
| ^
3 | import type Reference from './Reference';
4 | import { Asserts,Defined,If,Thunk,TypeOf } from './util/types';
5 | import BaseSchema,{ AnySchema,SchemaInnerTypeDescription,SchemaSpec } from './schema';
解决方法
是的,项目的版本 0.32.8
使用的是 TypeScript 版本 v4.0.5
。
自 TypeScript import type
起支持编译器抱怨的功能 v3.8
这个功能是大多数用户可能永远不必考虑的;但是,如果您在 --isolatedModules、TypeScript 的 transpileModule API 或 Babel 下遇到问题,则此功能可能是相关的。
import type { SomeThing } from "./some-module.js";
export type { SomeThing };
来源:https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html