Skip to content

lib.d.ts not detected? #4

@jasonkuhrt

Description

@jasonkuhrt

Project ok:

❯ npx tsc --noemit
❯ cat tsconfig.json
{
  "compilerOptions": {
    "strict": true,
    "noImplicitReturns": true,
    "esModuleInterop": true,
    "module": "commonjs",
    "target": "es2017",
    "sourceMap": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "lib": ["esnext"]
  },
  "include": ["src/**/*.ts", "lib.d.ts"]
}
❯ cat lib.d.ts
declare module 'serverless-http'

But not when checked from within jest runner:

❯ cat jest.config.js
module.exports = {
  projects: [
    {
      transform: {
        '^.+\\.ts$': 'ts-jest',
      },
      testRegex: '.*spec.ts$',
      moduleFileExtensions: ['ts', 'js'],
      collectCoverageFrom: ['**/src/**/*.ts', '!**/build/**/*'],
    },
    {
      runner: 'jest-runner-tsc',
      displayName: 'tsc',
      moduleFileExtensions: ['ts', 'tsx'],
      testMatch: ['<rootDir>/**/*.ts'],
    },
  ],
}
❯ npm test

> [email protected] test /Users/jasonkuhrt/projects/dialogue/orwell
> jest src plugins

 PASS   tsc  src/poetry.ts
 PASS   tsc  plugins/scribe.ts
 PASS   tsc  plugins/intercom.ts
 PASS   tsc  plugins/hollywood.ts (6.419s)
 FAIL   tsc  src/server.ts (8.77s)
Could not find a declaration file for module 'serverless-http'. '/Users/jasonkuhrt/projects/dialogue/orwell/node_modules/serverless-http/serverless-http.js' implicitly has an 'any' type.
  Try `npm install @types/serverless-http` if it exists or add a new declaration (.d.ts) file containing `declare module 'serverless-http';`
  3 | import express from 'express'
  4 | import QS from 'querystring'
> 5 | import serverless from 'serverless-http'
    |                        ^^^^^^^^^^^^^^^^^
  6 | import * as Plug from '../plugins'
  7 | import * as Config from './config'
  8 | import * as H from './helpers'
 PASS   tsc  src/config.ts (5.957s)
 PASS   tsc  src/helpers.spec.ts
 PASS   tsc  plugins/datadog.ts
 PASS   tsc  src/helpers.ts
 PASS   tsc  plugins/waldo.ts
 PASS   tsc  plugins/toktok.ts (5.651s)
 PASS   tsc  plugins/core.ts
 PASS   tsc  plugins/index.ts
 PASS  src/helpers.spec.ts

Test Suites: 1 failed, 13 passed, 14 total
Tests:       1 failed, 13 passed, 14 total
Snapshots:   0 total
Time:        19.859s
Ran all test suites matching /src|plugins/i in 2 projects.
npm ERR! Test failed.  See above for more details.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions