Skip to content

importables/importable

Repository files navigation

Importable

Importable allows you to import files with strong typing based on import attributes (presently import assertions).

Screenshot of the strong typing for a variable from a YAML file revealed in an editor

Installation

npm install importable
{
  "compilerOptions": {
    "plugins": [
      {
        "name": "importable",
        "plugins": [
          // importable plugins go here, like this:
          "@importable/yaml"
        ]
      }
    ]
  }
}

Plugins

FAQ

Still seeing a "Cannot find module" error after installing importable and the plugin for a given import?

Screenshot of a 'Cannot find module' error

To resolve this, switch to the workspace version of TypeScript.

In VS Code, this can be done by clicking on the TypeScript version number in the Status Bar.

Screenshot of the "Select Version" for TypeScript option in VS Code

A message box will appear asking you which version of TypeScript VS Code should use. Choose "Use Workspace Version". Once that is done, close and open your file to see the typings. That should be it.

More information about setting the workspace version of TypeScript is available in the VS Code documentation.

Regarding Import Assertions

Internally, Importable treats import assertions as if they are import attributes, in anticipation of the new import assertions syntax.

Once TypeScript supports import assertions, this plugin will provide an update to support the new syntax.

License

Code original to this project is licensed under the CC0-1.0 License.

About

Import files with strong typing based on import attributes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published