question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ignoring declares

See original GitHub issue

Bug report I’m bundling my code with webpack, and I have some declares in my files: Input code - src/globals.d.ts

declare const __DEV__: boolean;
declare module '*.pem' {
  const pem: string;
  export default pem;
}

Webpack bundles fine, and also my editor (vscode) recognizes everything, but when using you library (which is great btw!) it doesn’t consider the d.ts files which are placed in src folder.

Code - src/store/router/index.ts

...
private handleRouteChange(location: Location) {
    const { locationRegexes } = this;

    const foundLocation = locationRegexes.find(({ regex }) => testRegex(regex, location.pathname));

    if (!foundLocation) {
      if (__DEV__) {
        console.warn(`Route for ${location.pathname} not found, check config.`);
      }
...

Actual output

src/store/index.ts(26,5): error TS2304: Cannot find name '__DEV__'.
src/store/router/index.ts(38,11): error TS2304: Cannot find name '__DEV__'.
C:\Users\uv\dev\max-quality\node_modules\dts-bundle-generator\check-diagnostics-errors.js:20
    throw new Error(failMessage);
    ^

Error: Compiled with errors
    at checkDiagnosticsErrors (C:\Users\uv\dev\max-quality\node_modules\dts-bundle-generator\check-diagnostics-errors.js:20:11)
    at Object.checkProgramDiagnosticsErrors (C:\Users\uv\dev\max-quality\node_modules\dts-bundle-generator\check-diagnostics-errors.js:11:5)
    at getDeclarationFiles (C:\Users\uv\dev\max-quality\node_modules\dts-bundle-generator\compile-dts.js:67:32)
    at Object.compileDts (C:\Users\uv\dev\max-quality\node_modules\dts-bundle-generator\compile-dts.js:15:20)
    at generateDtsBundle (C:\Users\uv\dev\max-quality\node_modules\dts-bundle-generator\bundle-generator.js:33:33)
    at compilation.chunks.forEach (C:\Users\uv\dev\max-quality\node_modules\ts-declaration-webpack-plugin\index.js:25:19)
    at Array.forEach (<anonymous>)
    at compiler.plugin (C:\Users\uv\dev\max-quality\node_modules\ts-declaration-webpack-plugin\index.js:22:23)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\uv\dev\max-quality\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:7:1)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
igorpupkinablecommented, Oct 20, 2021

You are right. *.svg declaration should not be there after webpack has finished processing TS files. It just does not make sense for production version since no reference to SVG file will be in compiled code any more. Thank you for clarification.

1reaction
drudvcommented, Feb 27, 2019

I have the same problem with a code that imports .scss files. Initially I had multiple errors like: error TS2307: Cannot find module './whatever.scss'. and then by your suggestion, I added /// <reference path="./lib.d.ts" /> that contains the following:

declare module '*.scss' {
	const content: any;
	export default content;
}

Now it compiles, but the result check fails with: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible., because this d.ts file is added to the output with export modifier:

export declare module '*.scss' {
	const content: any;
	export default content;
}

Can I workaround it somehow?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Declaration IGNORE, IGNORABLE - CLHS
An ignore declaration specifies that for-value references to the indicated bindings will not occur within the scope of the declaration. Within the scope...
Read more >
How to resolve warning "ignoring return value of function ...
ignoring return value of function declared with 'warn_unused_result' attribute. I spent hours dealing with it but no result.
Read more >
Overruling by Ignoring | Re's Judicata - WordPress.com
There's been a lot of talk lately about SCOTUS's practice of overruling precedents by first ignoring them and then declaring them bad law....
Read more >
Ignoring a condition in an SQL procedure - Db2 - IBM
Procedure. To ignore a condition in an SQL procedure: Declare a condition handler that contains an empty compound statement.
Read more >
Musk declares New York Times 'lobbying firm for far left' after ...
Twitter owner Elon Musk called The New York Times a "lobbying firm for far left politicians" on Saturday after it was charged with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found