1

I have an angular 12 project and i wanna use graphql with apollo-angular. i create a category.js file with the codes below:

import gql from 'graphql-tag';

const CATEGORIES_QUERY = gql`
query Categories {
    categories {
        id
        name
    }
}
`;

export default CATEGORIES_QUERY;

and in my component.ts i wanna import this js file:

import CATEGORIES_QUERY from "../apollo/queries/category/categories";

but i got the error below:

Could not find a declaration file for module '../apollo/queries/category/categories'. 
'c:/Users/Diba Computer/vscode/blog- 
strapi/frontend/src/app/apollo/queries/category/categories.js' implicitly has an 'any' type.

can anyone help?

fariba.j
  • 1,737
  • 7
  • 23
  • 42

1 Answers1

1

You might need to add the following to tsconfig.json

{
  "compilerOptions": {
    ...
  "allowJs": true,
  "checkJs": false,
    ...
  }
}

This prevents typescript from applying module types to imported javascript.

Mikefox2k
  • 76
  • 7