-
Notifications
You must be signed in to change notification settings - Fork 74
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: drop ts type inference for event source #706
Changes from all commits
c9b2c66
281d0e3
356a10a
cdc379e
cfaa469
500bfba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,6 @@ build/Release | |
# typescript lives in src, output in lib | ||
lib/ | ||
.vscode | ||
|
||
# test files | ||
/test-package |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo -e "\nTesting that the package can be installed in another project and compiled with TypeScript without errors" | ||
|
||
TEST_DIR="test-package" | ||
mkdir "$TEST_DIR" | ||
|
||
cp scripts/test-package/test-tsconfig.json "$TEST_DIR/tsconfig.json" | ||
cp scripts/test-package/test-package.json "$TEST_DIR/package.json" | ||
cd "$TEST_DIR" | ||
npm install --install-links | ||
mkdir src | ||
echo -e "import { Unleash } from 'unleash-client';\nvoid Unleash;\nconsole.log('Hello world');" > src/index.ts | ||
./node_modules/.bin/tsc -b tsconfig.json | ||
|
||
if [ "$(node . 2>&1)" = "Hello world" ]; then | ||
echo "Output is correct" | ||
(cd .. && rm -rf "$TEST_DIR") | ||
else | ||
echo "Output is incorrect" >&2 | ||
echo $(node . 2>&1) | ||
(cd .. && rm -rf "$TEST_DIR") | ||
exit 1 | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "test", | ||
"version": "1.0.0", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "tsc" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"description": "", | ||
"devDependencies": { | ||
"typescript": "^5.7.3" | ||
}, | ||
"dependencies": { | ||
"unleash-client": "file:.." | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noImplicitOverride": true, | ||
"noImplicitReturns": true, | ||
"declaration": true, | ||
"inlineSourceMap": true, | ||
"pretty": true, | ||
"noImplicitAny": true, | ||
"allowJs": false, | ||
"resolveJsonModule": true, | ||
"composite": true, | ||
"outDir": "./lib", | ||
"rootDir": "./src" | ||
}, | ||
"include": ["src/**/*"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { EventSource as moduleToPatch } from 'launchdarkly-eventsource'; | ||
|
||
export const EventSource = moduleToPatch; // Re-export from .js file, because the original module doesn't have types |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,7 +97,7 @@ export default class Metrics extends EventEmitter { | |
|
||
private url: string; | ||
|
||
private timer: NodeJS.Timer | undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how did you find that this needs to change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to update Node.js types to fix other error
And new types where complaining about NodeJS.Timer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW, we should add Node v22 to our test array. |
||
private timer: NodeJS.Timeout | undefined; | ||
|
||
private started: Date; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -731,10 +731,12 @@ | |
dependencies: | ||
undici-types "~5.26.4" | ||
|
||
"@types/node@^20.2.5": | ||
version "20.4.0" | ||
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.4.0.tgz#01d637d1891e419bc85763b46f42809cd2d5addb" | ||
integrity sha512-jfT7iTf/4kOQ9S7CHV9BIyRaQqHu67mOjsIQBC3BKZvzvUB6zLxEwJ6sBE3ozcvP8kF6Uk5PXN0Q+c0dfhGX0g== | ||
"@types/node@^20.17.17": | ||
version "20.17.17" | ||
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.17.17.tgz#5cea2af2e271313742c14f418eaf5dcfa8ae2e3a" | ||
integrity sha512-/WndGO4kIfMicEQLTi/mDANUu/iVUhT7KboZPdEqqHQ4aTS+3qT3U5gIqWDFV+XouorjfgGqvKILJeHhuQgFYg== | ||
dependencies: | ||
undici-types "~6.19.2" | ||
|
||
"@types/normalize-package-data@^2.4.0": | ||
version "2.4.4" | ||
|
@@ -5105,6 +5107,11 @@ undici-types@~5.26.4: | |
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" | ||
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== | ||
|
||
undici-types@~6.19.2: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it from the upgraded There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
version "6.19.8" | ||
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" | ||
integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== | ||
|
||
unique-filename@^3.0.0: | ||
version "3.0.0" | ||
resolved "https://registry.yarnpkg.com/unique-filename/-/unique-filename-3.0.0.tgz#48ba7a5a16849f5080d26c760c86cf5cf05770ea" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need those checks? Isn't checking exit code from tsc to be 0 enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way we can extend tests, and check if Unleash is reporting errors.