π Search Terms
compiler option to prevent importing non-existent files
β
Viability Checklist
β Suggestion
I would like to see an error when importing a module, that doesn't exist
π Motivating Example
I have util repo, where I recently added a module called new-module
In other repos I wanted to import it, I did it like that:
import '@company/util/cjs/new-module'
And the problem is that TS doesn't care if this module exists. I get no error even when I do this:
import 'asdasd'
Before I deployed my changes I should have updated util to the newer version with new-module, but I forgot. I wish TS informed me that this module doesn't exist for this version of util and prevented me from building the code.
My suggestion is to add a check to this:
import '@company/util/cjs/new-module'
π» Use Cases
- Validate imports of modules
- Modules are not validated
- My current workaround is:
import {} from '@company/util/cjs/new-module'
import '@company/util/cjs/new-module'
One line checks if I have the module and the other imports it. Not very neat though
π Search Terms
compiler option to prevent importing non-existent files
β Viability Checklist
β Suggestion
I would like to see an error when importing a module, that doesn't exist
π Motivating Example
I have util repo, where I recently added a module called new-module
In other repos I wanted to import it, I did it like that:
import '@company/util/cjs/new-module'And the problem is that TS doesn't care if this module exists. I get no error even when I do this:
import 'asdasd'Before I deployed my changes I should have updated util to the newer version with new-module, but I forgot. I wish TS informed me that this module doesn't exist for this version of util and prevented me from building the code.
My suggestion is to add a check to this:
import '@company/util/cjs/new-module'π» Use Cases
One line checks if I have the module and the other imports it. Not very neat though