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

lib.d.ts not detected? #4

Open
jasonkuhrt opened this issue Jun 6, 2018 · 12 comments
Open

lib.d.ts not detected? #4

jasonkuhrt opened this issue Jun 6, 2018 · 12 comments
Assignees
Labels

Comments

@jasonkuhrt
Copy link

jasonkuhrt commented Jun 6, 2018

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

> orwell@0.1.0 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.

@azz azz added the bug label Jun 6, 2018
@azz
Copy link
Owner

azz commented Jun 6, 2018

The include probably isn't being respected. If you add a /// <reference path="../lib.d.ts" /> does it work?

@jasonkuhrt
Copy link
Author

@azz Where exactly should I put that?

@azz
Copy link
Owner

azz commented Jun 6, 2018

At the top of src/server.ts (just temporarily to diagnose)

@azz azz self-assigned this Jun 6, 2018
@jasonkuhrt
Copy link
Author

Ok I'll try that, should have some time later today.

@jasonkuhrt
Copy link
Author

@azz confirmed that works!

@azz
Copy link
Owner

azz commented Jun 7, 2018

Cool, confirms my suspicion. I'll try and fix it soon, but good that the workaround works 😄.

@philkeys
Copy link

@azz Hey, just seeing if this has been fixed. Using the workaround (reference path) for now.

@YBogomolov
Copy link

Any plans on fixing this issue? As Jest had been updated to 24.x, ts-jest no longer can be used with it, and the documentation suggest using jest-runner-tsc. However, due to this issue I cannot use it either :(

@sandiiarov
Copy link

sandiiarov commented Mar 2, 2019

I solved this problem by adding typeRoots

"compilerOptions": {
  ...
  "typeRoots": ["./src/@types", "./node_modules/@types"]
}

@ease-space
Copy link

@azz When this issue is fixed?

@ease-space
Copy link

ease-space commented Jun 26, 2021

@azz I found a solution, you need to add in tsconfig.ts gain on custom types and be sure to add a subfolder. This solution worked
Снимок экрана 2021-06-26 в 17 17 06
Снимок экрана 2021-06-26 в 17 17 14
Снимок экрана 2021-06-26 в 17 17 20

@Mifrill
Copy link

Mifrill commented Apr 8, 2022

Any plans on fixing this issue?

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

No branches or pull requests

7 participants