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

Typescript build issues #1241

Closed
partyzan opened this issue Jun 2, 2023 · 7 comments
Closed

Typescript build issues #1241

partyzan opened this issue Jun 2, 2023 · 7 comments

Comments

@partyzan
Copy link

partyzan commented Jun 2, 2023

Hi,
Using the 1.2.3 version of @inquirer/prompts with Yarn, installed using yarn add as documented, I am getting the following build errors when building with tsc (4.9.5):

node_modules/@inquirer/checkbox/dist/cjs/types/index.d.cts:1:10 - error TS2305: Module '"@inquirer/core"' has no exported member 'Separator'.

1 import { Separator } from '@inquirer/core';
           ~~~~~~~~~

node_modules/@inquirer/core/dist/cjs/types/index.d.cts:6:27 - error TS2691: An import path cannot end with a '.d.cts' extension. Consider importing './lib/prefix' instead.

6 export { usePrefix } from './lib/prefix.d.cts';
                            ~~~~~~~~~~~~~~~~~~~~

node_modules/@inquirer/core/dist/cjs/types/index.d.cts:7:15 - error TS2691: An import path cannot end with a '.d.cts' extension. Consider importing './lib/key' instead.

7 export * from './lib/key.d.cts';
                ~~~~~~~~~~~~~~~~~

node_modules/@inquirer/core/dist/cjs/types/index.d.cts:8:15 - error TS2691: An import path cannot end with a '.d.cts' extension. Consider importing './lib/Paginator' instead.

8 export * from './lib/Paginator.d.cts';
                ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@inquirer/core/dist/cjs/types/index.d.cts:9:15 - error TS2691: An import path cannot end with a '.d.cts' extension. Consider importing './lib/Separator' instead.

9 export * from './lib/Separator.d.cts';
                ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@inquirer/prompts/dist/cjs/types/index.d.cts:9:10 - error TS2305: Module '"@inquirer/core"' has no exported member 'Separator'.

9 import { Separator } from '@inquirer/core';
           ~~~~~~~~~

node_modules/@inquirer/rawlist/dist/cjs/types/index.d.cts:1:29 - error TS2305: Module '"@inquirer/core"' has no exported member 'Separator'.

1 import { AsyncPromptConfig, Separator } from '@inquirer/core';
                              ~~~~~~~~~

node_modules/@inquirer/select/dist/cjs/types/index.d.cts:1:10 - error TS2305: Module '"@inquirer/core"' has no exported member 'Separator'.

1 import { Separator, AsyncPromptConfig } from '@inquirer/core';
           ~~~~~~~~~


Found 8 errors in 5 files.

Errors  Files
     1  node_modules/@inquirer/checkbox/dist/cjs/types/index.d.cts:1
     4  node_modules/@inquirer/core/dist/cjs/types/index.d.cts:6
     1  node_modules/@inquirer/prompts/dist/cjs/types/index.d.cts:9
     1  node_modules/@inquirer/rawlist/dist/cjs/types/index.d.cts:1
     1  node_modules/@inquirer/select/dist/cjs/types/index.d.cts:1

tsconfig.json:

{
  "compilerOptions": {
    "esModuleInterop": true,
    "declaration": true,
    "importHelpers": true,
    "module": "commonjs",
    "outDir": "dist",
    "rootDir": "src",
    "strict": true,
    "target": "es2019"
  },
  "include": [
    "src/**/*"
  ]
}

What am I missing?

@partyzan
Copy link
Author

partyzan commented Jun 2, 2023

Adding "skipLibCheck": true to compilerOptions solves this, but I am wondering if this is expected?

@SBoudrias
Copy link
Owner

SBoudrias commented Jun 2, 2023

Well, it's not "expected" by Inquirer, but running TS on the libs means they all must match the rules of your own project - and that's not always possible. So IMO, skipLibCheck is a good option to reduce headaches on your side.

Otherwise, I would recommend:

  1. Maybe try the allowImportingTsExtensions option
  2. Make sure you're on a recent-ish version on Typescript. I'm not sure when .cts where introduced.
  3. Post this tsconfig issue on StackOverflow; it'll reach more people and it's more likely someone ran into this issue with other libs.

@partyzan
Copy link
Author

partyzan commented Jun 2, 2023

Thanks, will do! Closing this for now.

@partyzan partyzan closed this as completed Jun 2, 2023
@everhardt
Copy link

everhardt commented Jul 13, 2023

I think this issue needs to be reopened, this is the only package in my whole node_modules folder that gives tsc errors, so just setting skipLibCheck for this one does not make sense to me. Also, it will disable type checking for any d.ts file, also those outside node_modules. Third, I think that Module '"@inquirer/core"' has no exported member 'Separator'. is really an error in this project. For now I'm reverting to https://github.com/SBoudrias/Inquirer.js/tree/master/packages/inquirer

@SBoudrias
Copy link
Owner

Third, I think that Module '"@inquirer/core"' has no exported member 'Separator'.

Can you provide a full trace?

Or a repo with a small project setup reproducing the issue?

I'd be happy to look deeper into it; but I need more data to go on.

@everhardt
Copy link

See https://github.com/everhardt/inquirer-ts-build-issues.

npm i
npm run build

gives me:

npm run build

> inquirer-ts-build-issues@0.0.1 build
> rm -rf dist/ && tsc

node_modules/@inquirer/checkbox/dist/cjs/types/index.d.cts:1:10 - error TS2305: Module '"@inquirer/core"' has no exported member 'Separator'.

1 import { Separator } from '@inquirer/core';
           ~~~~~~~~~

node_modules/@inquirer/core/dist/cjs/types/index.d.cts:1:23 - error TS2688: Cannot find type definition file for 'node'.

1 /// <reference types="node" />
                        ~~~~

node_modules/@inquirer/core/dist/cjs/types/index.d.cts:2:23 - error TS2688: Cannot find type definition file for 'node'.

2 /// <reference types="node" />
                        ~~~~

node_modules/@inquirer/core/dist/cjs/types/index.d.cts:3:22 - error TS2307: Cannot find module 'node:readline' or its corresponding type declarations.

3 import readline from 'node:readline';
                       ~~~~~~~~~~~~~~~

node_modules/@inquirer/core/dist/cjs/types/index.d.cts:5:24 - error TS7016: Could not find a declaration file for module 'mute-stream'. '/Users/robeverhardt/Offline/inquirer-ts-build-issues/node_modules/mute-stream/lib/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/mute-stream` if it exists or add a new declaration (.d.ts) file containing `declare module 'mute-stream';`

5 import MuteStream from 'mute-stream';
                         ~~~~~~~~~~~~~

node_modules/@inquirer/core/dist/cjs/types/index.d.cts:6:27 - error TS2691: An import path cannot end with a '.d.cts' extension. Consider importing './lib/prefix' instead.

6 export { usePrefix } from './lib/prefix.d.cts';
                            ~~~~~~~~~~~~~~~~~~~~

node_modules/@inquirer/core/dist/cjs/types/index.d.cts:7:15 - error TS2691: An import path cannot end with a '.d.cts' extension. Consider importing './lib/key' instead.

7 export * from './lib/key.d.cts';
                ~~~~~~~~~~~~~~~~~

node_modules/@inquirer/core/dist/cjs/types/index.d.cts:8:15 - error TS2691: An import path cannot end with a '.d.cts' extension. Consider importing './lib/Paginator' instead.

8 export * from './lib/Paginator.d.cts';
                ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@inquirer/core/dist/cjs/types/index.d.cts:9:15 - error TS2691: An import path cannot end with a '.d.cts' extension. Consider importing './lib/Separator' instead.

9 export * from './lib/Separator.d.cts';
                ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@inquirer/core/dist/cjs/types/index.d.cts:12:12 - error TS2503: Cannot find namespace 'NodeJS'.

12     input: NodeJS.ReadableStream;
              ~~~~~~

node_modules/@inquirer/rawlist/dist/cjs/types/index.d.cts:1:29 - error TS2305: Module '"@inquirer/core"' has no exported member 'Separator'.

1 import { AsyncPromptConfig, Separator } from '@inquirer/core';
                              ~~~~~~~~~

node_modules/@inquirer/select/dist/cjs/types/index.d.cts:1:10 - error TS2305: Module '"@inquirer/core"' has no exported member 'Separator'.

1 import { Separator, AsyncPromptConfig } from '@inquirer/core';
           ~~~~~~~~~

node_modules/@inquirer/type/dist/cjs/types/index.d.cts:1:23 - error TS2688: Cannot find type definition file for 'node'.

1 /// <reference types="node" />
                        ~~~~

node_modules/@inquirer/type/dist/cjs/types/index.d.cts:6:13 - error TS2503: Cannot find namespace 'NodeJS'.

6     input?: NodeJS.ReadableStream;
              ~~~~~~

node_modules/@inquirer/type/dist/cjs/types/index.d.cts:7:14 - error TS2503: Cannot find namespace 'NodeJS'.

7     output?: NodeJS.WritableStream;
               ~~~~~~


SBoudrias added a commit that referenced this issue Jul 13, 2023
@SBoudrias SBoudrias reopened this Jul 13, 2023
@SBoudrias
Copy link
Owner

Thanks for the minimal repro case @everhardt! Allowed me to find out quickly the common.js type files were indeed broken. There's a now patch published on npm!

Let me know if anything comes up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants