Ignoring declares
See original GitHub issueBug 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:
- Created 5 years ago
- Comments:20 (10 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.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: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 withexport
modifier:Can I workaround it somehow?