AlexTorresDev / custom-electron-titlebar

Custom electon title bar inpire on VS Code title bar
MIT License
866 stars 148 forks source link

Errors of imports in `*.d.ts*` files | Cannot find module 'x' or its corresponding type declarations. ts(2397) #198

Closed IvanGodinez21 closed 1 year ago

IvanGodinez21 commented 2 years ago

Describe the bug Every time I compile using tsc in the console, I get these errors, I guess it is just a problem with the paths in the *.d.ts files.

Errors  Files
     1  node_modules/custom-electron-titlebar/dist/index.d.ts:2
     3  node_modules/custom-electron-titlebar/dist/menu.d.ts:2
     1  node_modules/custom-electron-titlebar/dist/menubar.d.ts:2
     3  node_modules/custom-electron-titlebar/dist/menuitem.d.ts:2
     1  node_modules/custom-electron-titlebar/dist/titlebar.d.ts:2

To Reproduce Steps to reproduce the behavior:

  1. Run tsc in console
  2. See error:
node_modules/custom-electron-titlebar/dist/index.d.ts:2:23 - error TS2307: Cannot find module 'vs/base/common/color' or its corresponding type declarations.

2 import { Color } from 'vs/base/common/color';
                        ~~~~~~~~~~~~~~~~~~~~~~

node_modules/custom-electron-titlebar/dist/menu.d.ts:2:23 - error TS2307: Cannot find module 'vs/base/common/color' or its corresponding type declarations.

2 import { Color } from "vs/base/common/color";
                        ~~~~~~~~~~~~~~~~~~~~~~

node_modules/custom-electron-titlebar/dist/menu.d.ts:4:28 - error TS2307: Cannot find module 'vs/base/common/lifecycle' or its corresponding type declarations.

4 import { Disposable } from "vs/base/common/lifecycle";
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/custom-electron-titlebar/dist/menu.d.ts:5:23 - error TS2307: Cannot find module 'vs/base/common/event' or its corresponding type declarations.

5 import { Event } from "vs/base/common/event";
                        ~~~~~~~~~~~~~~~~~~~~~~

node_modules/custom-electron-titlebar/dist/menubar.d.ts:2:23 - error TS2307: Cannot find module 'vs/base/common/event' or its corresponding type declarations.

2 import { Event } from 'vs/base/common/event';
                        ~~~~~~~~~~~~~~~~~~~~~~

node_modules/custom-electron-titlebar/dist/menuitem.d.ts:2:27 - error TS2307: Cannot find module 'vs/base/common/dom' or its corresponding type declarations.

2 import { EventLike } from "vs/base/common/dom";
                            ~~~~~~~~~~~~~~~~~~~~

node_modules/custom-electron-titlebar/dist/menuitem.d.ts:4:25 - error TS2307: Cannot find module 'vs/base/common/keyCodes' or its corresponding type declarations.

4 import { KeyCode } from "vs/base/common/keyCodes";
                          ~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/custom-electron-titlebar/dist/menuitem.d.ts:5:28 - error TS2307: Cannot find module 'vs/base/common/lifecycle' or its corresponding type declarations.

5 import { Disposable } from "vs/base/common/lifecycle";
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/custom-electron-titlebar/dist/titlebar.d.ts:2:23 - error TS2307: Cannot find module 'vs/base/common/color' or its corresponding type declarations.

2 import { Color } from 'vs/base/common/color';
                        ~~~~~~~~~~~~~~~~~~~~~~

Found 9 errors in 5 files.

Errors  Files
     1  node_modules/custom-electron-titlebar/dist/index.d.ts:2
     3  node_modules/custom-electron-titlebar/dist/menu.d.ts:2
     1  node_modules/custom-electron-titlebar/dist/menubar.d.ts:2
     3  node_modules/custom-electron-titlebar/dist/menuitem.d.ts:2
     1  node_modules/custom-electron-titlebar/dist/titlebar.d.ts:2

Expected behavior No errors with imports in the console when compile is done.

Screenshots image

Desktop (please complete the following information):

AlexTorresDev commented 1 year ago

But, what are you doing, a project with typescript, you can indicate to exactly reproduce the error.

wchar-t commented 1 year ago

i managed to fix this by changing all broken imports from the original code, making them relative, like so:

image

IvanGodinez21 commented 1 year ago

i managed to fix this by changing all broken imports from the original code, making them relative, like so:

image

Yes, it also worked for me, but I forgot to open a PR and I deleted the code accidentally in my computer 😅, it would be great if the owner fixes this 👀

AlexTorresDev commented 1 year ago

@IvanGodinez21 You should explain the steps to reproduce the error and attach your code, as I run tsc on a sample typescript project and the output returns no error.

IvanGodinez21 commented 1 year ago

@AlexTorresSk to reproduce, I just run the tsc command, maybe it's my tsconfig.json?, @wchar-t has the same problem, so I don't think that's the problem...

This is my configuration:

{
    "compilerOptions": {
        /* Basic Options */
        "target": "ES6",                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
        "module": "CommonJS",                     /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */
        // "lib": [],                             /* Specify library files to be included in the compilation:  */
        // "allowJs": true,                       /* Allow javascript files to be compiled. */
        // "checkJs": true,                       /* Report errors in .js files. */
        // "jsx": "preserve",                     /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
        // "declaration": true,                   /* Generates corresponding '.d.ts' file. */
        "sourceMap": true,                     /* Generates corresponding '.map' file. */
        // "outFile": "./",                       /* Concatenate and emit output to single file. */
        "outDir": "./build",                        /* Redirect output structure to the directory. */
        "rootDir": "./app",                       /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
        // "removeComments": true,                /* Do not emit comments to output. */
        // "noEmit": true,                        /* Do not emit outputs. */
        // "importHelpers": true,                 /* Import emit helpers from 'tslib'. */
        // "downlevelIteration": true,            /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
        // "isolatedModules": true,               /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
        "resolveJsonModule": true,
        "forceConsistentCasingInFileNames": true,

        /* Strict Type-Checking Options */        
        "strict": true,                            /* Enable all strict type-checking options. */
        "noImplicitAny": true,                     /* Raise error on expressions and declarations with an implied 'any' type. */
        // "strictNullChecks": true,               /* Enable strict null checks. */
        // "noImplicitThis": true,                 /* Raise error on 'this' expressions with an implied 'any' type. */
        // "alwaysStrict": true,                   /* Parse in strict mode and emit "use strict" for each source file. */

        /* Additional Checks */                   
        // "noUnusedLocals": true,                /* Report errors on unused locals. */
        // "noUnusedParameters": true,            /* Report errors on unused parameters. */
        // "noImplicitReturns": true,             /* Report error when not all code paths in function return a value. */
        // "noFallthroughCasesInSwitch": true,    /* Report errors for fallthrough cases in switch statement. */

        /* Module Resolution Options */           
        // "moduleResolution": "node",            /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
        // "baseUrl": "./",                       /* Base directory to resolve non-absolute module names. */
        // "paths": {},                           /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
        // "rootDirs": [],                        /* List of root folders whose combined content represents the structure of the project at runtime. */
        // "typeRoots": [],                       /* List of folders to include type definitions from. */
        // "types": [],                           /* Type declaration files to be included in compilation. */
        // "allowSyntheticDefaultImports": true,  /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
        "esModuleInterop": true,

        /* Source Map Options */                  
        // "sourceRoot": "./",                    /* Specify the location where debugger should locate TypeScript files instead of source locations. */
        // "mapRoot": "./",                       /* Specify the location where debugger should locate map files instead of generated locations. */
        // "inlineSourceMap": true,               /* Emit a single file with source maps instead of having a separate file. */
        // "inlineSources": true,                 /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

        /* Experimental Options */                
        // "experimentalDecorators": true,        /* Enables experimental support for ES7 decorators. */
        // "emitDecoratorMetadata": true,         /* Enables experimental support for emitting type metadata for decorators. */
    },
    "include": ["app/**/*"]
  }
AlexTorresDev commented 1 year ago

@AlexTorresSk to reproduce, I just run the tsc command, maybe it's my tsconfig.json?, @wchar-t has the same problem, so I don't think that's the problem...

This is my configuration:

{
    "compilerOptions": {
        /* Basic Options */
        "target": "ES6",                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
        "module": "CommonJS",                     /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */
        // "lib": [],                             /* Specify library files to be included in the compilation:  */
        // "allowJs": true,                       /* Allow javascript files to be compiled. */
        // "checkJs": true,                       /* Report errors in .js files. */
        // "jsx": "preserve",                     /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
        // "declaration": true,                   /* Generates corresponding '.d.ts' file. */
        "sourceMap": true,                     /* Generates corresponding '.map' file. */
        // "outFile": "./",                       /* Concatenate and emit output to single file. */
        "outDir": "./build",                        /* Redirect output structure to the directory. */
        "rootDir": "./app",                       /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
        // "removeComments": true,                /* Do not emit comments to output. */
        // "noEmit": true,                        /* Do not emit outputs. */
        // "importHelpers": true,                 /* Import emit helpers from 'tslib'. */
        // "downlevelIteration": true,            /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
        // "isolatedModules": true,               /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
        "resolveJsonModule": true,
        "forceConsistentCasingInFileNames": true,

        /* Strict Type-Checking Options */        
        "strict": true,                            /* Enable all strict type-checking options. */
        "noImplicitAny": true,                     /* Raise error on expressions and declarations with an implied 'any' type. */
        // "strictNullChecks": true,               /* Enable strict null checks. */
        // "noImplicitThis": true,                 /* Raise error on 'this' expressions with an implied 'any' type. */
        // "alwaysStrict": true,                   /* Parse in strict mode and emit "use strict" for each source file. */

        /* Additional Checks */                   
        // "noUnusedLocals": true,                /* Report errors on unused locals. */
        // "noUnusedParameters": true,            /* Report errors on unused parameters. */
        // "noImplicitReturns": true,             /* Report error when not all code paths in function return a value. */
        // "noFallthroughCasesInSwitch": true,    /* Report errors for fallthrough cases in switch statement. */

        /* Module Resolution Options */           
        // "moduleResolution": "node",            /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
        // "baseUrl": "./",                       /* Base directory to resolve non-absolute module names. */
        // "paths": {},                           /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
        // "rootDirs": [],                        /* List of root folders whose combined content represents the structure of the project at runtime. */
        // "typeRoots": [],                       /* List of folders to include type definitions from. */
        // "types": [],                           /* Type declaration files to be included in compilation. */
        // "allowSyntheticDefaultImports": true,  /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
        "esModuleInterop": true,

        /* Source Map Options */                  
        // "sourceRoot": "./",                    /* Specify the location where debugger should locate TypeScript files instead of source locations. */
        // "mapRoot": "./",                       /* Specify the location where debugger should locate map files instead of generated locations. */
        // "inlineSourceMap": true,               /* Emit a single file with source maps instead of having a separate file. */
        // "inlineSources": true,                 /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

        /* Experimental Options */                
        // "experimentalDecorators": true,        /* Enables experimental support for ES7 decorators. */
        // "emitDecoratorMetadata": true,         /* Enables experimental support for emitting type metadata for decorators. */
    },
    "include": ["app/**/*"]
  }

You can use "skipLibCheck": true, temporarily, while I look for a solution

blarfoon commented 1 year ago

any ETA on a fix for this? It's really annoying

ArcticLampyrid commented 1 year ago

Same problem when upgrading custom-electron-titlebar. The workaround skipLibCheck is okey.

ArcticLampyrid commented 1 year ago

@IvanGodinez21 You should explain the steps to reproduce the error and attach your code, as I run tsc on a sample typescript project and the output returns no error.

For the detail, you can have a look at Microsoft/TypeScript#15479