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

Could not find a declaration file for module '@aws-amplify/ui' #2460

Closed
samuelcastro opened this issue Jan 4, 2019 · 15 comments
Closed

Could not find a declaration file for module '@aws-amplify/ui' #2460

samuelcastro opened this issue Jan 4, 2019 · 15 comments
Assignees
Labels
Angular Related to Angular 2+ feature-request Request a new feature TypeScript Related to TypeScript issues UI Related to UI Components

Comments

@samuelcastro
Copy link

samuelcastro commented Jan 4, 2019

Describe the bug
When trying to build a typescript project I'm getting: Could not find a declaration file for module '@aws-amplify/ui':

node_modules/aws-amplify/lib/index.d.ts:8:16 - error TS7016: Could not find a declaration file for module '@aws-amplify/ui'. '/Users/samuelcastro/Projects/Control4/react-sdk/node_modules/@aws-amplify/ui/dist/aws-amplify-ui.js' implicitly has an 'any' type.
  Try `npm install @types/aws-amplify__ui` if it exists or add a new declaration (.d.ts) file containing `declare module '@aws-amplify/ui';`

8 import UI from '@aws-amplify/ui';

To Reproduce
Steps to reproduce the behavior:

  1. In a typescript (3.1.2) project run: ./node_modules/.bin/tsc
  2. See error

Expected behavior
Successfully build

@jordanranz jordanranz added UI Related to UI Components TypeScript Related to TypeScript issues labels Jan 4, 2019
@jordanranz
Copy link
Contributor

jordanranz commented Jan 4, 2019

Hey @samuelcastro, how are you including amplify into your project? I would like to reproduce this error and attempt to add type definitions to the amplify ui package.

At the moment Amplify UI does not have type definitions defined. It should be fairly easy to add them to provide Typescript support.

A workaround would be to add a new declaration as mentioned in the error or set noImplicitAny to false in your tsconfig.

@jordanranz jordanranz self-assigned this Jan 4, 2019
@mikecann
Copy link

mikecann commented Jan 8, 2019

I solved by adding a types.d.ts file in my src dir with:

declare module "@aws-amplify/ui"; // amplify hack :(

@jordanranz jordanranz added the feature-request Request a new feature label Jan 8, 2019
@samuelcastro
Copy link
Author

samuelcastro commented Jan 10, 2019

Yeah, an easy workaround would be just include it, I just wanted to see if a better solution is being take, like creating a typescript type definition of it.

Thanks anyway.

@toshi38
Copy link

toshi38 commented Jan 29, 2019

We have the same problem.

package.json:

    "aws-amplify": "1.1.18",

We import it like so (angular project)

import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { ICredentials } from '@aws-amplify/core';
import { CognitoUser } from 'amazon-cognito-identity-js';
import { Auth, AuthClass } from 'aws-amplify';
import { Observable } from 'rxjs/Observable';
import { fromPromise } from 'rxjs/observable/fromPromise';
import { map } from 'rxjs/operators';

It seems that in index.d.ts there is the following:

import Analytics, { AnalyticsClass, AnalyticsProvider, AWSPinpointProvider, AWSKinesisProvider } from '@aws-amplify/analytics';
import Auth, { AuthClass } from '@aws-amplify/auth';
import Storage, { StorageClass } from '@aws-amplify/storage';
import API, { APIClass, graphqlOperation } from '@aws-amplify/api';
import PubSub, { PubSubClass } from '@aws-amplify/pubsub';
import Cache from '@aws-amplify/cache';
import Interactions, { InteractionsClass } from '@aws-amplify/interactions';
import UI from '@aws-amplify/ui';
import XR, { XRClass } from '@aws-amplify/xr';
import Amplify, { ConsoleLogger as Logger, Hub, JS, ClientDevice, Signer, I18n, ServiceWorker } from '@aws-amplify/core';
export default Amplify;
export { Auth, Analytics, Storage, API, PubSub, I18n, Logger, Hub, Cache, JS, ClientDevice, Signer, ServiceWorker, Interactions, UI, XR };
export { AuthClass, AnalyticsClass, APIClass, StorageClass, PubSubClass, InteractionsClass, XRClass, AnalyticsProvider, AWSPinpointProvider, AWSKinesisProvider };
export { graphqlOperation };

import UI from '@aws-amplify/ui'; seems to be what results in the types being missing... although I'm not 100% on this 😄

Of course its easy enough to get around with adding a file as above... but it would be nice with proper types...

@jordanranz jordanranz added this to the Triage milestone Feb 5, 2019
@ffxsam
Copy link
Contributor

ffxsam commented Feb 13, 2019

Just stumbled upon this too. Everything else has a proper type declaration file in @aws-amplify. So this seems like just a tiny oversight. Other folders such as @aws-amplify/cache have a lib folder full of .d.ts files. But the UI folder does not.

@pl4yradam
Copy link

This should not be marked as a feature request, it completely breaks compiling

@vuongnguyen-agilityio
Copy link

Add "@aws-amplify/ui": "1.0.18", to package.json, below "aws-amplify": "1.1.26", and good luck :))

@willkara
Copy link

willkara commented Jul 30, 2019

Any updates on this for Angular 8 support?

Still getting this error:

G:\Development\Personal\Wamplify>ng build --prod

chunk {0} runtime-es2015.703a23e48ad83c851e49.js (runtime) 1.41 kB [entry] [rendered]
chunk {1} main-es2015.efedd750490b14de3f18.js (main) 128 bytes [initial] [rendered]
chunk {2} polyfills-es2015.66a9e684cc8ebe117187.js (polyfills) 130 bytes [initial] [rendered]
chunk {3} styles.766cbe8e00b1dc50cc5e.css (styles) 62.6 kB [initial] [rendered]
Date: 2019-07-30T03:04:02.215Z - Hash: deb8ed06f76c4a940511 - Time: 13248ms

ERROR in node_modules/aws-amplify/lib/index.d.ts:8:8 - error TS1192: Module '"G:/Development/Personal/Wamplify/node_modules/@aws-amplify/ui/lib/index"' has no default export.

8 import UI from '@aws-amplify/ui';
         ~~

From package.json

    "aws-amplify": "^1.1.27",
    "@aws-amplify/ui": "^1.0.22",

IVY is NOT enabled.

@rjjlucy
Copy link

rjjlucy commented Oct 9, 2019

I added
"noImplicitAny": false,
in my tsconfig.json and seems like the error is gone.

@ericclemmons ericclemmons added the Angular Related to Angular 2+ label Feb 14, 2020
@sammartinez
Copy link
Contributor

As the above callouts and merged PRs, this is resolved. Closing this issue

@half2me
Copy link

half2me commented Dec 18, 2020

@sammartinez I still have this issue on the latest version. How do I solve it?

@kevin4dhd
Copy link

same problem

@rekomerio
Copy link

Problem is here also. I'm trying to just use withAuthenticator in React and it crashes everything

@RobinBeekhof
Copy link

I have this problem to with the latest version

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Angular Related to Angular 2+ feature-request Request a new feature TypeScript Related to TypeScript issues UI Related to UI Components
Projects
None yet
Development

No branches or pull requests