alpaca-ts: Does not compile with TypeScript 4.7 module = nodenext

Description Can’t compile TypeScript project using @master-chief/alpaca with module = nodenext in tsconfig.json.

Expected TypeScript compilation pass.

Reproduction

  1. Install latest TypeScript (4.7.3)
  2. Install latest @master-chief/alpaca (6.3.20): npm i @master-chief/alpaca
  3. Create tsconfig with module=NodeNext:
    "compilerOptions": {
      "target": "es2020",
      "module": "NodeNext",
      "strict": true,
      "allowSyntheticDefaultImports": true,
      "esModuleInterop": true
    },
    
  4. Create index.ts importing alpaca stuff:
    import { AlpacaClient, AlpacaStream } from '@master-chief/alpaca';
    
  5. Try to compile TypeScript: tsc

Logs

error TS7016: Could not find a declaration file for module '@master-chief/alpaca'. '.../node_modules/@master-chief/alpaca/dist/mjs/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/master-chief__alpaca` if it exists or add a new declaration (.d.ts) file containing `declare module '@master-chief/alpaca';`

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 26

Most upvoted comments

i’m going to write a new build script and config which generates the new declarations tomorrow. too tired right now

Will investigate.

Ok! Before I publish it please test and let me know if this solves it for you. Try npm i 117/alpaca and let me know 😃

  "dependencies": {
    "@master-chief/alpaca": "github:117/alpaca"
  },

I have tested this personally with the following tsconfig.

{
  "compilerOptions": {
    "target": "es2020",
    "module": "NodeNext",
    "strict": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true
  }
}

@WinstonNau @vitalets