Skip to content

Commit e581f9f

Browse files
committed
feat(minor): add ReadonlyState<T> type
1 parent 5ef1909 commit e581f9f

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

eslint.config.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import jsdoc from "eslint-plugin-jsdoc";
55
import n from "eslint-plugin-n";
66
import tseslint from "typescript-eslint";
77
import stylistic from "@stylistic/eslint-plugin";
8+
import {defineConfig} from "eslint/config";
89

910

10-
export default tseslint.config({
11+
export default defineConfig({
1112
ignores: ["dist/", "docs-site/"]
1213
}, {
1314
files: ["**/**.{,c,m}{js,ts}"],
1415
extends: [
15-
stylistic.configs["recommended-flat"],
16+
stylistic.configs["recommended"],
1617
jsdoc.configs["flat/recommended"],
1718
importPlugin.flatConfigs.recommended
1819
],
@@ -42,7 +43,7 @@ export default tseslint.config({
4243
}
4344
},
4445
rules: {
45-
"@stylistic/indent": ["off"],
46+
"@stylistic/indent": ["warn", 4],
4647
"indent": ["warn", 4, {
4748
SwitchCase: 1,
4849
FunctionDeclaration: {
@@ -61,7 +62,8 @@ export default tseslint.config({
6162
args: "none",
6263
ignoreRestSiblings: true,
6364
varsIgnorePattern: "^set",
64-
caughtErrors: "none"
65+
caughtErrors: "none",
66+
ignoreUsingDeclarations: true
6567
}],
6668
"@stylistic/no-prototype-builtins": ["off"],
6769
"@stylistic/object-curly-spacing": ["warn", "never"],

src/State.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,8 @@ export class StateChangeListenerHandle {
226226
}
227227
}
228228

229+
export type ReadonlyState<T> = Omit<State<T>, "clearChangeListeners"> & {
230+
readonly state: T
231+
};
232+
229233
type TypeOfState<T extends State<any>> = T extends State<infer S> ? S : never;

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"outDir": "./dist",
2424
"strict": true,
2525
"sourceMap": true,
26+
"inlineSources": true,
2627
"composite": false,
2728
"declaration": true,
2829
"declarationMap": true,

0 commit comments

Comments
 (0)