question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing TypeScript declaration file

See original GitHub issue

Version

3.x.x (Vue 3.x)

Describe the bug

I’m not being able to make the typings work on .ts files, the following errors are being shown:

Visual Studio Code 1.62.0:

"Could not find a declaration file for module '@asigloo/vue-dynamic-forms'."

IntelliJ IDEA 2021.2:

TS2307: Cannot find module '@asigloo/vue-dynamic-forms/dist' or its corresponding type declarations.

Using npm run serve command (on a new scaffolded vue project):

TS7016: Could not find a declaration file for module '@asigloo/vue-dynamic-forms'. 'H:/hello-world/node_modules/@asigloo/vue-dynamic-forms/dist/as-dynamic-forms.cjs.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/asigloo__vue-dynamic-forms` if it exists or add a new declaration (.d.ts) file containing `declare module '@asigloo/vue-dynamic-forms';`

Describe the bug

  1. Scaffold a new Vue 3 project with Vue CLI: vue create hello-world with TypeScript feature
  2. Run npm install @asigloo/vue-dynamic-forms.
  3. Create a main.ts file if not exist.
  4. Add import { createDynamicForms } from '@asigloo/vue-dynamic-forms' to main.ts file.

Expected behavior

The IDE can recognize the typings of imported modules from @asigloo/vue-dynamic-forms on TypeScript files.

System Info

System:
    OS: Windows 10 10.0.19043
    CPU: (16) x64 AMD Ryzen 7 2700 Eight-Core Processor
    Memory: 14.66 GB / 31.93 GB
  Binaries:
    Node: 14.15.4 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.10 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 95.0.4638.69
    Edge: Spartan (44.19041.1266.0), Chromium (95.0.1020.44)
    Internet Explorer: 11.0.19041.1202
  npmPackages:
    @asigloo/vue-dynamic-forms: ^3.18.0 => 3.18.0

Additional context

No response

Validations

  • Read the docs.
  • Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

1reaction
mrweinercommented, Dec 10, 2021

FWIW, I was seeing this until I added declarations to my main.ts as described in https://github.com/asigloo/vue-dynamic-forms/issues/235, as well as the “failed to resolve component” described in the ticket. The ts error went away and everything started working after I made those updates.

0reactions
mjcc007commented, Apr 21, 2022

please publish your typescript .d.ts use run build:tsd.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing typescript declaration file in javascript - Stack Overflow
My project is mixed javascript and typescript files.
Read more >
How to Declare Missing Types for External Libraries -- newline
However, sometimes libraries don't have type declarations. In this case type to find them in DefinitelyTyped repository and install them.
Read more >
v4.0.0 missing TypeScript declaration files #3846 - GitHub
Version 4.0.0 is missing the declaration files to make use of TypeScript typing. This is affecting all packages part of v4.0.0: @tanstack ...
Read more >
TypeScript — Type Declaration Files | by Makesh Kumar
TypeScript itself comes with a bunch of type declaration files to support all JavaScript features. After installing TypeScript, navigate to the node_modules/ ...
Read more >
Could not find declaration file for module 'X' Error | bobbyhadz
The error "Could not find declaration file for module" occurs when TypeScript cannot find the type declaration for a module. To solve the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found