Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Cannot find module 'dsl/message' error in 10.2.0 #974

Closed
1 of 5 tasks
qmg-akara opened this issue Nov 14, 2022 · 7 comments
Closed
1 of 5 tasks

Getting Cannot find module 'dsl/message' error in 10.2.0 #974

qmg-akara opened this issue Nov 14, 2022 · 7 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@qmg-akara
Copy link

Hi guys, thanks for the great work!

We just upgraded to version 10.2.0 but our yarn lint is failing due to 2 import paths:

node_modules/.store/@pact-foundation-pact-npm-10.2.0-8ecf80a526/node_modules/@pact-foundation/pact/src/dsl/verifier/proxy/types.d.ts:4:34 - error TS2307: Cannot find module 'dsl/message' or its corresponding type declarations.

4 import { MessageProviders } from 'dsl/message';
                                   ~~~~~~~~~~~~~

node_modules/.store/@pact-foundation-pact-npm-10.2.0-8ecf80a526/node_modules/@pact-foundation/pact/src/dsl/verifier/types.d.ts:2:40 - error TS2307: Cannot find module 'dsl/options' or its corresponding type declarations.

2 import { MessageProviderOptions } from 'dsl/options';
                                         ~~~~~~~~~~~~~

Are aliased import paths typo or intentional?

Software versions

Please provide at least OS and version of pact-js

  • OS: e.g. Mac OSX 10.11.5
  • Consumer Pact library: Pact JS v10.2.0
  • Provider Pact library: N/A
  • Node Version: 18

Issue Checklist

Please confirm the following:

  • I have upgraded to the latest
  • I have the read the FAQs in the Readme
  • I have triple checked, that there are no unhandled promises in my code and have read the section on intermittent test failures
  • I have set my log level to debug and attached a log file showing the complete request/response cycle
  • For bonus points and virtual high fives, I have created a reproduceable git repository (see below) to illustrate the problem

Expected behaviour

No linting error

Actual behaviour

Getting the above errors

Steps to reproduce

It can be tested with a fresh install

Relevant log files

See above

@qmg-akara qmg-akara added the bug Indicates an unexpected problem or unintended behavior label Nov 14, 2022
@mefellows
Copy link
Member

mefellows commented Nov 14, 2022

Gah! I really need to find a way to prevent my editor from using aliased imports, and investigate if this can be easily added to our CI to fail a build.

I'll get a patch out ASAP.

(also, thank you for the kind words)

@qmg-akara
Copy link
Author

Thanks for the quick fix!

@mefellows
Copy link
Member

You're welcome

mefellows added a commit that referenced this issue Nov 14, 2022
Some IDEs (such as VS Code) are aware of the `baseUrl'
property, and will auto-complete imports using the base
URL as a prefix in the import, instead of a relative URL.

This creates problems for consumers of the library, as the path
is no longer relative to the top level project base (I think).

Even if this is untrue, it's best to stick with a single,
consistent approach.

As an example, see a20ad80 which had to correct one such
problem.

See also #974
@TimothyJones
Copy link
Contributor

The problem is that if you're using aliases or a baseurl typescript doesn't convert the import paths on compilation, and as far as I know you can't make it convert them (unless you compile with something like babel or webpack as a post processing step)

I really need to find a way to prevent my editor from using aliased import

I don't remember which editor you use, but in VS Code this is under TypeScript › Preferences: Import Module Specifier.

Not using baseUrl at all is another solution, of course. It probably shouldn't be set in a library anyway.

@TimothyJones
Copy link
Contributor

I guess this isn't picked up at test time because ts-jest just runs the typescript :/

@mefellows
Copy link
Member

I don't remember which editor you use, but in VS Code this is under TypeScript › Preferences: Import Module Specifier.

Ah yes, thanks - I've made that change now.

Not using baseUrl at all is another solution, of course. It probably shouldn't be set in a library anyway.

Removing this makes it a compilation error, which I think is what we want (I added that change in yesterday, and found two more imports). Thanks for the tips everyone.

@TimothyJones
Copy link
Contributor

I read the docs for that option after my comment last night, and it is there in typescript as a convenience for systems that use a different import structure or have a post processing step that moves files around. So we shouldn’t have had it set anyway. Probably my fault, sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants