Typescript 3.5.3
Angular 8.2.11
Firebase 7.2.1
We recently installed Firebase into our app (have filed an issue there as well)
They have an file that exports undefined. Now Auto Import will allways import "undefined" from this file. This gives a bad developer experience that it imports this whenever someone presses tab when writing "undefined".
The Auto import :
import undefined = require('firebase/empty-import');
We have tried to exclude this import in tsconfig.json and tsconfig.app.json
tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "esnext",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
],
"baseUrl": "./src",
"paths": {
"~/*": [ "*" ],
"@exp/structure/pages/*": ["app/structure/pages/*"],
"@exp/services/*": ["app/shared/services/*"],
"@exp/modals/*": ["app/shared/modals/*"],
"@exp/components/*": ["app/shared/components/*"],
"@exp/dropdowns/*": ["app/shared/dropdowns/*"],
"@exp/old/*": ["shared/*"],
},
},
"exclude": [
"node_modules/firebase/empty-import",
"node_modules/firebase/empty-import.d.ts",
"firebase/empty-import.d.ts"
],
"angularCompilerOptions": {
"enableIvy": false
}
}
tsconfig.app.json:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
}, "include": [
"src/**/*.ts"
],
"exclude": [
"test.ts",
"**/*.spec.ts",
"src/**/*.worker.ts",
"node_modules/firebase/empty-import",
"node_modules/firebase/**/*",
"firebase/empty-import",
"node_modules/firebase/empty-import.d.ts",
"firebase/empty-import.d.ts"
]
}
The problematic file from Firebase's library:
import undefined = require('firebase/empty-import');:
/**
* @license
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export = undefined;
Probably some file that is included references it (most likely is an indirect reference). From tsconfig.json documentation:
Any files that are referenced by files included via the "files" or "include" properties are also included. Similarly, if a file B.ts is referenced by another file A.ts, then B.ts cannot be excluded unless the referencing file A.ts is also specified in the "exclude" list.
exclude only modifies the "initial set" of files TypeScript uses to start determining the scope of the program; it does not stop module resolution from finding those files.
Logging a separate issue about auto-import pulling in undefined
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow.
Ok, as @RyanCavanaugh wrote exclude only affects the include initial set.
The question remains, if there is a way to somehow exclude referenced files from being compiled?
Why am I asking:
I have scenario with compile and testCompile tasks. I do not want testCompile to recompile the whole project but only test sources.
Most helpful comment
Ok, as @RyanCavanaugh wrote
excludeonly affects the include initial set.The question remains, if there is a way to somehow exclude referenced files from being compiled?
Why am I asking:
I have scenario with
compileandtestCompiletasks. I do not wanttestCompileto recompile the whole project but only test sources.