| .. | ||
| atom-tests.ts | ||
| autocomplete-plus.d.ts | ||
| index.d.ts | ||
| linter.d.ts | ||
| README.md | ||
| status-bar.d.ts | ||
| tsconfig.json | ||
| tslint.json | ||
Atom API Type Definitions
TypeScript type definitions for the Atom Text Editor public API, which is used to develop packages for the editor. Documentation for the public API can be found here.
Exports
The "atom" Variable
These definitions declare a global static variable named "atom" as ambient. Once these definitions have been referenced within your project, you will be able to access properties and member functions from the AtomEnvironment class off of this variable, as it is an instance of that class.
if (atom.inDevMode()) {}
The Atom Namespace
All of the types used by or referenced by the Atom public API have been pulled into the Atom namespace, providing a consistent and easy way to access each of them, without having to care about where that type actually lives within the Atom codebase.
function example(buffer: Atom.TextBuffer) {}
The AtomCore Namespace
All classes which are core to Atom itself have been provided under the AtomCore namespace.
function example(cursor: AtomCore.Cursor) {}
Service Type Definitions
There are many services provided by other Atom packages that you may want to use within your own Atom package. We bundle type definitions for several of these services with these type definitions. All type definitions for services are available only through ES6 imports.
import { AutocompleteProvider } from "atom/autocomplete-plus";
let completionProvider: AutocompleteProvider;
The currently supported services are:
- Autocomplete (atom/autocomplete-plus)
- Linter (atom/linter)
- Status Bar (atom/status-bar)
Exposing Private Methods and Properties
Declaration Merging can be used to augment any of the types used within Atom. As an example, if we wanted to reveal the private triggerActivationHook method within the PackageManager class, then we would create a file with the following contents:
// <<filename>>.d.ts
declare namespace AtomCore {
interface PackageManager {
triggerActivationHook(name: string): void;
triggerDeferredActivationHooks(): void;
}
}
Once this file is either referenced or included within your project, then this new member function would be freely usable on instances of the PackageManager class without TypeScript reporting errors.