Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add Symbol.observable typings and isolate const enums #141

Merged
merged 4 commits into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/new-feet-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'wonka': patch
---

Fix missing `Symbol.observable` typings and remove `const enum` exports, which aren't usable in isolated modules.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"rollup-plugin-cjs-check": "^1.0.1",
"rollup-plugin-dts": "^5.1.1",
"tslib": "^2.4.1",
"typescript": "^4.9.3",
"typescript": "^4.9.5",
"vitest": "^0.25.3",
"zen-observable": "^0.10.0"
}
Expand Down
66 changes: 33 additions & 33 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@
* @packageDocumentation
*/

export * from './types';
export type {
TeardownFn,
Signal,
Sink,
Source,
Operator,
TypeOfSource,
Subscription,
Observer,
Subject,
} from './types';

export * from './sources';
export * from './operators';
export * from './sinks';
Expand Down
9 changes: 8 additions & 1 deletion src/observable.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { Source, SignalKind, TalkbackKind } from './types';
import { push, start, talkbackPlaceholder } from './helpers';

declare global {
interface SymbolConstructor {
readonly observable: symbol;
}
}

/** A definition of the ES Observable Subscription type that is returned by
* {@link Observable.subscribe}
*
Expand Down Expand Up @@ -124,7 +130,8 @@ interface Observable<T> {
*
* @internal
*/
const observableSymbol = (): typeof Symbol.observable => Symbol.observable || '@@observable';
const observableSymbol = (): typeof Symbol.observable =>
Symbol.observable || ('@@observable' as any);

/** Converts an ES Observable to a {@link Source}.
* @param input - The {@link ObservableLike} object that will be converted.
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"importsNotUsedAsValues": "remove",
"noEmit": true,
"esModuleInterop": true,
"noUnusedLocals": true,
Expand All @@ -16,7 +17,8 @@
"strict": true,
"noImplicitAny": false,
"noUnusedParameters": true,
"skipLibCheck": true
"skipLibCheck": true,
"isolatedModules": true
},
"include": ["src"]
}