Skip to content

Commit

Permalink
feat: skypack support
Browse files Browse the repository at this point in the history
  • Loading branch information
awlayton committed Mar 7, 2024
1 parent fd02182 commit 1d7259f
Show file tree
Hide file tree
Showing 12 changed files with 3,323 additions and 4,149 deletions.
10 changes: 5 additions & 5 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ extends:
- plugin:github/recommended
- plugin:promise/recommended
- plugin:regexp/recommended
- plugin:array-func/recommended
#- plugin:array-func/recommended
- plugin:optimize-regex/recommended
- plugin:import/recommended
- plugin:unicorn/recommended
- plugin:security/recommended
#- plugin:security/recommended
- plugin:sonarjs/recommended
- plugin:ava/recommended
- xo
Expand All @@ -22,7 +22,7 @@ plugins:
- github
- promise
- regexp
- array-func
#- array-func
- optimize-regex
- no-constructor-bind
- import
Expand Down Expand Up @@ -114,7 +114,7 @@ rules:
*/
onNonMatchingHeader: append
nonMatchingTolerance: 0.7
sonarjs/no-duplicate-string: [warn, 5]
sonarjs/no-duplicate-string: [warn, { threshold: 5 }]
sonarjs/cognitive-complexity: warn
eslint-comments/no-unused-disable: off
import/extensions: off
Expand All @@ -126,7 +126,7 @@ rules:
eslint-comments/no-use: off
no-secrets/no-secrets: [error, { tolerance: 5 }]
no-empty-label: off
no-warning-comments: off
no-warning-comments: 0
node/no-missing-import: off
import/no-unresolved: off
unicorn/prefer-spread: off
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"tags.*": true,
"**/.pnp.*": true
},
"prettier.prettierPath": ".yarn/sdks/prettier/index.js",
"prettier.prettierPath": ".yarn/sdks/prettier/index.cjs",
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"eslint.nodePath": ".yarn/sdks",
Expand Down
541 changes: 0 additions & 541 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

This file was deleted.

9 changes: 0 additions & 9 deletions .yarn/plugins/@yarnpkg/plugin-typescript.cjs

This file was deleted.

873 changes: 0 additions & 873 deletions .yarn/releases/yarn-3.5.1.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.1.1.cjs

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
compressionLevel: mixed

yarnPath: .yarn/releases/yarn-3.5.1.cjs
enableGlobalCache: false

yarnPath: .yarn/releases/yarn-4.1.1.cjs
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# @qlever-llc/interface2class

[![Coverage Status](https://coveralls.io/repos/Qlever-LLC/@qlever-llc/interface2class/badge.svg?branch=master)](https://coveralls.io/r/Qlever-LLC/@qlever-llc/interface2class?branch=master)
[![Version](https://img.shields.io/npm/v/@qlever-llc/interface2class.svg)](https://npmjs.org/package/@qlever-llc/interface2class)
[![Coverage Status](https://coveralls.io/repos/Qlever-LLC/interface2class/badge.svg?branch=master)](https://coveralls.io/r/Qlever-LLC/interface2class?branch=master)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![License](https://img.shields.io/github/license/Qlever-LLC/@qlever-llc/interface2class)](LICENSE)
[![License](https://img.shields.io/github/license/Qlever-LLC/interface2class)](LICENSE)

A TypeScript utility to create a class from an interface
without having to duplicate the interface's properties.
Expand Down
64 changes: 35 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{
"name": "@qlever-llc/interface2class",
"version": "1.0.0",
"version": "1.1.0",
"author": "Alex <[email protected]>",
"description": "TypeScript library for making classes from interfaces without repeating the properties",
"main": "src/index.mjs",
"homepage": "https://github.com/Qlever-LLC/interface2class",
"repository": {
"type": "git",
"url": "https://github.com/qlever-llc/interface2class"
},
"main": "./src/index.mjs",
"types": "./src/index.d.ts",
"exports": {
"import": "./src/index.mjs",
"types": "./src/index.d.ts"
Expand All @@ -15,7 +21,7 @@
"files": [
"src/**/*"
],
"tags": [
"keywords": [
"typescript",
"class",
"interface"
Expand Down Expand Up @@ -66,44 +72,44 @@
}
},
"devDependencies": {
"@ava/typescript": "^4.0.0",
"@tsconfig/node16": "^1.0.3",
"@types/node": "^16.18.28",
"@typescript-eslint/eslint-plugin": "^5.59.5",
"@typescript-eslint/parser": "^5.59.5",
"@yarnpkg/sdks": "^3.0.0-rc.43",
"ava": "5.2.0",
"c8": "^7.13.0",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0",
"eslint-config-xo": "^0.43.1",
"eslint-config-xo-typescript": "^0.57.0",
"eslint-plugin-array-func": "^3.1.8",
"@ava/typescript": "^4.1.0",
"@tsconfig/node16": "^16.1.1",
"@types/node": "^16.18.87",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"@yarnpkg/sdks": "^3.1.0",
"ava": "6.1.2",
"c8": "^9.1.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-xo": "^0.44.0",
"eslint-config-xo-typescript": "^3.0.0",
"eslint-plugin-array-func": "^5.0.1",
"eslint-plugin-ava": "^14.0.0",
"eslint-plugin-escompat": "^3.4.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-filenames": "^1.3.2",
"eslint-plugin-github": "^4.7.0",
"eslint-plugin-github": "^4.10.2",
"eslint-plugin-i18n-text": "^1.0.1",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-no-constructor-bind": "^2.0.4",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-no-secrets": "^0.8.9",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-notice": "^0.9.10",
"eslint-plugin-optimize-regex": "^1.2.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-regexp": "^1.15.0",
"eslint-plugin-security": "^1.7.1",
"eslint-plugin-sonarjs": "^0.19.0",
"eslint-plugin-unicorn": "^47.0.0",
"prettier": "^2.8.8",
"type-fest": "^3.10.0",
"typescript": "^5.0.4"
"eslint-plugin-regexp": "^2.2.0",
"eslint-plugin-security": "^2.1.1",
"eslint-plugin-sonarjs": "^0.24.0",
"eslint-plugin-unicorn": "^51.0.1",
"prettier": "^3.2.5",
"type-fest": "^4.11.1",
"typescript": "^5.4.2"
},
"packageManager": "yarn@3.5.1",
"packageManager": "yarn@4.1.1",
"volta": {
"node": "16.19.0"
"node": "20.11.1"
}
}
}
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ export interface I2Class<I, D extends keyof I = never>
* @typeParam D - The keys of `I` that should be required to set
* @see {@link I2Class}
*/
export const makeClass: <I, D = never>() => I2Class<I, D>;
export const makeClass: <I, D extends keyof I = never>() => I2Class<I, D>;
6 changes: 3 additions & 3 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ class FooClass2 extends makeClass<Foo, 'a'>() {
}

test('Create class from interface', (t) => {
const foo: Foo = { a: 1, b: '2' };
const foo = { a: 1, b: '2' } as const satisfies Foo;
const fooClass = new FooClass(foo) satisfies Foo;

t.deepEqual(Object.entries(fooClass), Object.entries(foo));
});

test('Extend class from interface', (t) => {
const foo: Foo = { a: 1, b: '2' };
const foo = { a: 1, b: '2' } as const satisfies Foo;
const fooClass = new F(foo) satisfies Foo;

t.deepEqual(Object.entries(fooClass), Object.entries(foo));
Expand All @@ -58,7 +58,7 @@ test('Access interface fields on class', (t) => {
});

test('Add defaults for optional fields', (t) => {
const foo: Foo = { b: '2' };
const foo = { b: '2' } as const satisfies Foo;
const fooClass = new FooClass2(foo) satisfies Foo;

const { a } = fooClass;
Expand Down
Loading

0 comments on commit 1d7259f

Please sign in to comment.