Open schwartzmj opened 4 years ago
As a workaround to the OP do the following:
typings
with a file called plugins.d.ts
to your project.declare module "gatsby-theme-shopify-manager";
.tsconfig.json
to include
the typings
directory.This will satisfy the type checker at the import
line in your project. If you're adding local web fonts you'll likely need ot do something similar, i.e. declare module "*.woff2";
in a fonts.d.ts
.
I'm not receiving type information for gatsby-theme-shopify-manager in Webstorm. Here's the error:
TS7016: Could not find a declaration file for module 'gatsby-theme-shopify-manager'. '/Users/myusername/Dev/myproject/node_modules/gatsby-theme-shopify-manager/index.js' implicitly has an 'any' type. Try 'npm install @types/gatsby-theme-shopify-manager' if it exists or add a new declaration (.d.ts) file containing 'declare module 'gatsby-theme-shopify-manager';
I noticed that
index.js
at the project root is a one-liner that exports everything fromsrc/index.ts
. I found that if instead of doingimport { useCart } from "gatsby-theme-shopify-manager";
, I do:import { useCart } from "gatsby-theme-shopify-manager/src";
, then I get all of the proper type information. I also found that if I rename the file fromindex.js
toindex.ts
I get all the types.Having not created a project like this before, I'm not sure what the best solution is for this.
I believe Gatsby comes with Typescript support out of the box. Are we able to just change the file name from
.js
to.ts
? I have no idea what the repercussions are for that.I glanced at the Formik repository and it looks like there's a /dist folder that gets created with an
index.d.ts
file alongsideindex.js
. I then came across this webpage. Could you take a look and see how difficult implementing something like this might be? It looks like there needs to be a build process added to get from javascript to typescript, but theindex.d.ts
file gets created automatically.