Definitelytyped: [@types/validator] Circular definition of import alias 'Validator'.

Created on 18 Nov 2019  路  19Comments  路  Source: DefinitelyTyped/DefinitelyTyped

If you know how to fix the issue, make a pull request instead.

  • [x] I tried using the @types/xxxx package and had problems.
  • [x] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [x] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • [x] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @MunifTanjim @samuelneff @CodeAnimal @drinchev @babolivier @kukoo1 @oktapodia @MorpheusXAUT @TitaneBoy @zjy01 @nidzov @Raigen @todd @nrschultz @Thomas-B @Antoine38660 @smff @truongkhanhduy95 @emmanuelgautier @dancrumb @lalayueh @rohitsud @Torhal @tgfjt @chrootsu @IOAyman @louy @kacepe @deptno @builtinnya @qqilihq @keatz55

Example:

import validator from 'validator';
5:11:26 PM: ERROR in /opt/build/repo/node_modules/@types/validator/index.d.ts
5:11:26 PM: ERROR in /opt/build/repo/node_modules/@types/validator/index.d.ts(1247,8):
5:11:26 PM: TS2303: Circular definition of import alias 'Validator'.

It is caused by the release of @types/[email protected] (https://github.com/DefinitelyTyped/DefinitelyTyped/pull/40192)

Most helpful comment

@topwood yeah actually updating to the latest should give you the same issue as above

TS2303: Circular definition of import alias 'Validator'.

I have a fix in #40491

All 19 comments

mark

node_modules/_@[email protected]@@types/sequelize/index.d.ts:6296:33 - error TS2503: Cannot find namespace 'ValidatorJS'.

Related to https://github.com/DefinitelyTyped/DefinitelyTyped/pull/40192, I don't have time to do a PR right now unfortunately

@topwood are you using an older version of sequelize types? I think that might be your issue, which is different to the other one

I鈥檒l try to take a look later today. Strange how CI didn鈥檛 catch that circular reference

In my package.json

"sequelize": "^4.43.1",
"sequelize-typescript": "^0.6.9"

How to slove this? @louy Thank you !

image

@topwood Can you try updating both packages to the latest?

npm i -S @types/sequelize@latest @types/validator@latest

It still do not work for me..sad

@topwood yeah actually updating to the latest should give you the same issue as above

TS2303: Circular definition of import alias 'Validator'.

I have a fix in #40491

@louy is there any way to circumvent this until we wait for this to get merged?

You can try using an older version of the types package

You can try using an older version of the types package

Is this possible if validator is a dependency of a dependency? In my case sequelize is using validator.

Ok, downgrading @types/sequelize from 4.28.8 to 4.28.1 solved my issue.

i have same problem with
@types/[email protected] and @sequelize-typescript 1.0.0
how can i solve this problem?

Have the same error. I downgraded @types/sequelize to the previous version 10.11.3 and my tsc is working fine now.

ref: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/40192#issuecomment-555203904

@asmsuechan @types/sequelize latest version is 4.28.7, do you mean you downgraded to 4.28.6, or are you talking about a different lib?

Edit: Looks like you actually meant @types/validator to 10.11.3

That alone gets rid of namespace issues, but still errors out at circule dependency

As a temporary workaround, installing both @types/[email protected] and @types/[email protected] worked for my project.

@types/[email protected] should now solve this problem

@types/[email protected] should now solve this problem

From my practice, @types/[email protected] cannot solve this problem.
my package.json is
"sequelize": "^5.21.3", "@types/validator": "^12.0.1",
I still have this error (Cannot find namespace 'ValidatorJS')

My solution was to remove the @types/validator package
npm remove @types/validator
Don't need to use it explicitly after all

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JWT
svipas picture svipas  路  3Comments

JudeAlquiza picture JudeAlquiza  路  3Comments

jamespero picture jamespero  路  3Comments

csharpner picture csharpner  路  3Comments

jrmcdona picture jrmcdona  路  3Comments