Package Exports
- sketch-for-jstypes
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sketch-for-jstypes) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Installation
Install and save to devDependencies:
npm install --save-dev git+https://github.com/qjebbs/sketch.d.ts.git
It's necessary to config TypeScript (use tsconfig.json) to use es6
lib only, since:
- "Sketch runs JavaScript code in JavaScriptCore, with full ES6 support"(Here).
- Otherwise, TypeScript will introduce libs like
DOM
, which leads to duplicated definition toDocument
etc., and other unexpected behaviours.
{
"compilerOptions": {
"lib": [
"es6"
]
}
}
Summary
This package contains type definitions for Sketch JavaScript API.
Examples
// Require all
var sketch: Sketch = require('sketch');
// Or, require without UI, Settings, DataSupplier, Async,
var sketchDom: SketchDom = require('sketch/dom');
// and require others according to your needs
var async: Async = require('sketch/async');
var DataSupplier: DataSupplier = require('sketch/data-supplier');
var UI: UI = require('sketch/ui');
var Settings: Settings = require('sketch/settings');
var document: Document = sketch.getSelectedDocument();
var page: Page = document.selectedPage;