flow icon indicating copy to clipboard operation
flow copied to clipboard

untyped-type-import doesn't seem to work

Open pbondoer opened this issue 7 years ago • 3 comments

Flow version: 0.97.0

Expected behavior

The untyped-type-import lint should not warn.

Actual behavior

Importing a type from an untyped module makes it any and is not safe!
Did you mean to add // @flow to the top of my-internal-module?
(untyped-type-import)

How to reproduce

.flowconfig

[lints]
untyped-type-import=error

[options]
module.system.node.resolve_dirname=node_modules

Code

test.js

import type { MyType } from 'my-internal-module';

node_modules/my-internal-module

my-internal-module
└── dist
    ├── index.js.flow
    └── modules
        └── test.js
index.js.flow
export { MyType } from './modules/test';
test.js
export type MyType = {
  // ...
};

Am I doing something wrong? Flow is able to pick up the types with flow type-at-pos.

Would be happy to assist further with debugging and/or submit a PR with some guidance :smile:

pbondoer avatar Apr 19 '19 12:04 pbondoer

+1

I have the same problem.

After I upgrade to the last version of Flow (0.141.0) all my third-party library throw an error

Flow: Importing a type from an untyped module makes it anyand is not safe! Did you mean to add// @flowto the top ofredux-observable?

There is a way to fix it?

my flowconfig:

[ignore]
./test/nightwatch/reports/**
./scripts/**
.*/node_modules/redux-form/lib/index.js.flow

[include]
./packages/common/components/src
./packages/common/function/src
./packages/common/storeComponents/src
./packages/common/types/src
./packages/gipsyApp/src
./packages/initialization/src
./packages/media/src
./packages/setting/src

[libs]
./flow-typed

[lints]

[options]
module.name_mapper='^@domain' ->'<PROJECT_ROOT>/packages/gipsyApp/src/domain/'
esproposal.optional_chaining=enable
esproposal.export_star_as=enable
types_first=false
[strict]

[untyped]
<PROJECT_ROOT>/node_modules/react-select/*

amirbr avatar Jan 17 '21 09:01 amirbr

Did anyone find a fix for this?

akshaaatt avatar Feb 08 '22 13:02 akshaaatt

Can you use flow find-module MyModuleName path/to/file/that/imports/it.js to find out if the modules are being resolved correctly?

Also, if you are actually trying to import a type from an untyped module, it's going to error as that is nonsensical.

gkz avatar Feb 09 '22 19:02 gkz