DEV Community

faridz974
faridz974

Posted on

Auto import with type

In version 3.8, Typescript enabled a new syntax for type-only import.
This enables to erase of the import at runtime.

For example:

import type { SQSEvent, SQSHandler } from 'aws-lambda';
Enter fullscreen mode Exit fullscreen mode

By default, Visual Studio Code import without type

Import without type

To enable import with type, you need to add the following to your tsconfig.json

{
    "compilerOptions": {
        "importsNotUsedAsValues": "error",
    },
}
Enter fullscreen mode Exit fullscreen mode

Now, Visual Studio Code import with type

Import with type

Top comments (0)