Page updated Jan 16, 2024

Typescript Strict Mode

This section lists known TypeScript errors and their workarounds when strict mode is enabled on your application.

Declaration file for GraphQL

If you see the error

1Could not find a declaration file for module 'graphql/error/GraphQLError'`
2Could not find a declaration file for module 'graphql/language/ast'`

Add a declaration file src/types.d.ts with the following content to resolve the error:

1declare module 'graphql/language/ast' { export type DocumentNode = any }
2declare module 'graphql/error/GraphQLError' { export type GraphQLError = any }

Declaration file for aws-exports

If you see the error

1Could not find a declaration file for module './aws-exports'. 'aws-exports.js' implicitly has an 'any' type.

Create a aws-exports.d.ts file on the same level as aws-exports with the following content:

1declare const awsmobile: Record<string, any>
2export default awsmobile;