Check out example codes for "type annotations can only be used in typescript files.ts(8010)". It will help you in understanding the concepts better.

Code Example 1

// @ts-check

module.exports = {
  someMethod: (param: string): string => {
    return param;
  },
};

Learn ReactJs, React Native from akashmittal.com