TypeScript ```import '@types/handlebars';``` leads to "Cannot resolve dependency '@types/handlebars'"
See original GitHub issueChoose one: 🐛 bug report
// index.ts
import '@types/handlebars';
parsel index.ts
X Cannot resolve dependency ‘@types/handlebars’
🎛 Configuration (.babelrc, package.json, cli command)
Babel: no
🤔 Expected Behavior
The import command tells TypeScript to include a declaration file. Without this line any reference to Handlebars module are highlighted as invalid (PhpStorm). Even if the JS file for handlebars is imported with
import 'handlebars/dist/handlebars.min.js';
😯 Current Behavior
parcel entry.html Server running at http://localhost:1234 × RenderOpportunities.ts:3:8: Cannot resolve dependency ‘@types/handlebars’ 1 | ‘use strict’; 2 | 3 | import ‘@types/handlebars’; | ^
💁 Possible Solution
No idea.
🔦 Context
It’s hard/impossible to continue working with parcel-bundler and Handlebars library with TypeScript which requires the declaration file to be imported.
💻 Code Sample
See above.
🌍 Your Environment
parcel -V 1.4.1
node -v v9.3.0
npm -v 5.6.0
yarn -v 1.3.2
ver Microsoft Windows [Version 6.1.7601]
Thanks.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
I created #587 to warn instead of throwing when a fs call cannot be statically evaluated, you can try it while it’s being reviewed.
If it does not work I’m not aware of a resolve alias feature in Parcel, the TypeScript plugin supports TypeScript path rewriting using the
paths
compiler option, you can use it if thehandlebars
typings declares thehandlebars/dist/handlebars.min.js
module.This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.