"Yup" Validation Library fails to compile in TypeScript

Viewed 1858

So I have been turned to using the Yup library for form validation on my project however when I have installed it (and tried many many more times after that) I have been encountering this extremely odd library error consistently.

I am utterly clueless at how to get past this. Any help would be incredibly appreciated.


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';
1 Answers

Yup project's verison 0.32.8 uses TypeScript version v4.0.5.

Feature import type which compiler complains is supported since TypeScript v3.8

This feature is something most users may never have to think about; however, if you’ve hit issues under --isolatedModules, TypeScript’s transpileModule API, or Babel, this feature might be relevant.

import type { SomeThing } from "./some-module.js";
export type { SomeThing };

source: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html

Related