Skip to content

Commit

Permalink
Merge pull request #6 from moonrailgun/master
Browse files Browse the repository at this point in the history
feat: add typescript support
  • Loading branch information
remarkablemark committed Nov 7, 2019
2 parents 519d167 + 6c2a09d commit 85dbd12
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
39 changes: 39 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Parses inline style to object.
*
* @example
* import StyleToObject from 'style-to-object';
* StyleToObject('line-height: 42;');
*
*/

declare function StyleToObject(
style: string,
iterator?: StyleToObject.Iterator
): { [name: string]: any } | null;
export = StyleToObject;

declare namespace StyleToObject {
interface DeclarationPos {
line: number;
column: number;
}

// declaration is object from module `inline-style-parser`
interface Declaration {
type: string;
property: string;
value: string;
position: {
start: DeclarationPos;
end: DeclarationPos;
source: any;
};
}

type Iterator = (
property: string,
value: string,
declaration: Declaration
) => void;
}
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Converts inline style to object.",
"author": "Mark <mark@remarkablemark.org>",
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"build": "npm run clean && npm run build:min && npm run build:unmin",
"build:min": "NODE_ENV=production rollup --config --file dist/style-to-object.min.js --sourcemap",
Expand All @@ -12,6 +13,7 @@
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"lint": "eslint --ignore-path .gitignore .",
"lint:fix": "npm run lint -- --fix",
"lint:dts": "dtslint .",
"prepublishOnly": "npm run build",
"release": "standard-version --no-verify",
"test": "mocha",
Expand Down Expand Up @@ -42,6 +44,7 @@
"@commitlint/cli": "^8.0.0",
"@commitlint/config-conventional": "^8.0.0",
"coveralls": "^3.0.4",
"dtslint": "^1.0.3",
"eslint": "^6.0.0",
"eslint-plugin-prettier": "^3.1.0",
"husky": "^2.4.1",
Expand All @@ -56,7 +59,8 @@
"standard-version": "^6.0.1"
},
"files": [
"/dist"
"/dist",
"index.d.ts"
],
"license": "MIT"
}
11 changes: 11 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"module": "umd",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noEmit": true
}
}
3 changes: 3 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dtslint.json"
}

0 comments on commit 85dbd12

Please sign in to comment.