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

Resolve error: TSError: ⨯ Unable to compile TypeScript: #3423

Open
sanket1726 opened this issue Feb 14, 2023 · 5 comments
Open

Resolve error: TSError: ⨯ Unable to compile TypeScript: #3423

sanket1726 opened this issue Feb 14, 2023 · 5 comments
Labels

Comments

@sanket1726
Copy link

image

@sanket1726 sanket1726 added the bug label Feb 14, 2023
@lucasrabiec
Copy link
Contributor

lucasrabiec commented Mar 23, 2023

I noticed the similar issue:

Resolve error: TSError: ⨯ Unable to compile TypeScript:
   .erb/configs/webpack.config.renderer.dev.ts(2,5): error TS7022: '__importDefault' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.

Any ideas?

@theronburger
Copy link

Having a similar issue when importing a typescript file without the extension.
The error reports the checkNodeEnv function being implicitly any

Resolve error: TSError: ⨯ Unable to compile TypeScript:
app/.erb/configs/webpack.config.renderer.dev.ts(12,26):
error TS7016: Could not find a declaration file for module '../scripts/check-node-env'. 
'/Users/theron/Developer/CodeWorks/Rulie/app/.erb/scripts/check-node-env.js'
implicitly has an 'any' type.

Adding the extension to the import clears up the error.
However typescript imports should not have extensions.
The app runs as normal despite VS Code displaying the error.

Steps to reproduce :
Clean install as per https://electron-react-boilerplate.js.org/docs/installation
Create a component typescript file in renderer/components, say "Menu.tsx"

export default function Menu() {
  return <div className="text-sky-500">I am the menu</div>;
}

in App, importing without the .tsx extension causes the error

import { MemoryRouter as Router, Routes, Route } from 'react-router-dom';
import Menu from './components/Menu';

@habibatabay
Copy link

I have the same issue. Anyone help?

@jamiejcole
Copy link
Contributor

Getting the same issue as well with a clean install of ERB.

I'm getting the following error (8 of them) on line 1 of src/renderer/index.tsx:

Resolve error: TSError: ⨯ Unable to compile TypeScript:
electron/.erb/configs/webpack.config.renderer.dev.ts(12,26): error TS7016: Could not find a declaration file for module '../scripts/check-node-env'. 'C:/Users/admin/Documents/project/electron/.erb/scripts/check-node-env.js' implicitly has an 'any' type.

    at createTSError (C:\Users\admin\Documents\project\electron\node_modules\ts-node\src\index.ts:859:12)
    at reportTSError (C:\Users\admin\Documents\project\electron\node_modules\ts-node\src\index.ts:863:19)
    at getOutput (C:\Users\admin\Documents\project\electron\node_modules\ts-node\src\index.ts:1077:36)
    at Object.compile (C:\Users\admin\Documents\project\electron\node_modules\ts-node\src\index.ts:1433:41)
    at Module.m._compile (C:\Users\admin\Documents\project\electron\node_modules\ts-node\src\index.ts:1617:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1326:10)
    at Object.require.extensions.<computed> [as .ts] (C:\Users\admin\Documents\project\electron\node_modules\ts-node\src\index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1126:32)
    at Module._load (node:internal/modules/cjs/loader:967:12)
    at Function.c._load (node:electron/js2c/node_init:2:13672)eslint[import/no-duplicates](https://github.com/import-js/eslint-plugin-import/blob/v2.28.1/docs/rules/no-duplicates.md)

Adding the .js file extension import checkNodeEnv from '../scripts/check-node-env.js'; in webpack.config.renderer.dev.ts doesn't clear the error for me either.

Having a similar issue when importing a typescript file without the extension. The error reports the checkNodeEnv function being implicitly any

Resolve error: TSError: ⨯ Unable to compile TypeScript:
app/.erb/configs/webpack.config.renderer.dev.ts(12,26):
error TS7016: Could not find a declaration file for module '../scripts/check-node-env'. 
'/Users/theron/Developer/CodeWorks/Rulie/app/.erb/scripts/check-node-env.js'
implicitly has an 'any' type.

Adding the extension to the import clears up the error. However typescript imports should not have extensions. The app runs as normal despite VS Code displaying the error.

Steps to reproduce : Clean install as per https://electron-react-boilerplate.js.org/docs/installation Create a component typescript file in renderer/components, say "Menu.tsx"

export default function Menu() {
  return <div className="text-sky-500">I am the menu</div>;
}

in App, importing without the .tsx extension causes the error

import { MemoryRouter as Router, Routes, Route } from 'react-router-dom';
import Menu from './components/Menu';

@jamiejcole
Copy link
Contributor

Modifying .eslintrc.js in root folder to include node config has cleaned up the error for me. Seems to be a duplicate of #3235.

settings: {
    'import/resolver': {
      // See https://github.com/benmosher/eslint-plugin-import/issues/1396#issuecomment-575727774 for line below
      node: {
        extensions: ['.js', '.jsx', '.ts', '.tsx'],
        moduleDirectory: ['node_modules', 'src/'],
      },
      webpack: {
        config: require.resolve('./.erb/configs/webpack.config.eslint.ts'),
      },
      typescript: {},
    },
    'import/parsers': {
      '@typescript-eslint/parser': ['.ts', '.tsx'],
    },
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants