-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Add TypeScript type tests for check, random, email, fetch and tracker packages #13951
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
base: devel
Are you sure you want to change the base?
Conversation
Addresses issue meteor#13676 by adding TypeScript type tests to verify type definitions work correctly. This establishes a pattern for adding type tests to other packages with .d.ts files. Changes: - check: Added comprehensive type tests for Match patterns and check() assertions - random: Added type tests for all Random methods (id, secret, fraction, hexString, choice) - tracker: Added type tests for Tracker.autorun, Computation, Dependency, and reactive utilities
✅ Deploy Preview for v3-meteor-api-docs canceled.
|
✅ Deploy Preview for v3-migration-docs canceled.
|
- fetch: Added type tests for fetch(), Headers, Request, and Response APIs - email: Added type tests for Email.sendAsync(), hookSend(), customTransport(), and MailComposer
| import { Tinytest } from "meteor/tinytest"; | ||
| import { check, Match } from "meteor/check"; | ||
|
|
||
| Tinytest.add("Check - TypeScript types - basic check function", (test) => { |
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.
would be better to have a test for "general types" so test string, number, obj...
| test.equal(upper, "HELLO"); | ||
| }); | ||
|
|
||
| Tinytest.add("Check - TypeScript types - Match.test with primitives", (test) => { |
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.
Check lib isnt a typescript feature, all this file have TypeScript types in the test descriptions, bu none of them is testing typescript related things, Number and String is js native
| api.use(['check', 'tinytest', 'ejson', 'ecmascript', 'typescript'], ['client', 'server']); | ||
|
|
||
| api.addFiles('match_test.js', ['client', 'server']); | ||
| api.mainModule('match_test.ts'); |
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.
the file is .ts but isnt using ts statement 🤷🏻♂️
vote to remove it
|
|
||
| Tinytest.add("Email - TypeScript types - sendAsync options", (test) => { | ||
| // Type check that sendAsync accepts proper options | ||
| const options = { |
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.
is missing the type EmailOptions
| }); | ||
|
|
||
| Tinytest.add("Email - TypeScript types - hookSend", (test) => { | ||
| Email.hookSend((options) => { |
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.
missing the type EmailOptions into options Email.hookSend((options: EmailOptions) => {
| import { Tinytest } from "meteor/tinytest"; | ||
| import { fetch, Headers, Request, Response } from "meteor/fetch"; | ||
|
|
||
| Tinytest.addAsync("Fetch - TypeScript types - fetch function", async (test, done) => { |
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.
here we are testing node's fetch, not a method stuff, remove all tests like this, please
featch already have your own tests
| }); | ||
|
|
||
| Tinytest.add("Tracker - TypeScript types - Computation properties", (test) => { | ||
| const computation = Tracker.autorun((c) => { |
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.
missing the type ...: Tracker.Computation =...
| const stopped: boolean = c.stopped; | ||
| const promise: Promise<unknown> = c.firstRunPromise; | ||
|
|
||
| test.equal(typeof firstRun, "boolean"); |
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.
it's typescript, Boolean doent work here?
|
|
||
| // This ensures the type signature is correct | ||
| const sendPromise: Promise<void> = Email.sendAsync(options); | ||
| test.equal(typeof sendPromise.then, "function"); |
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.
it's typescript, instanceof Promise doesnt work here?
| test.equal(computation.invalidated, true); | ||
|
|
||
| computation.onInvalidate((c: Tracker.Computation) => { | ||
| test.equal(typeof c, "object"); |
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.
should be typeof c, Tracker.Computation
Summary
.d.tsfilescheck,random,tracker,fetch, andemailChanges
Pattern for other packages
Each package now follows this pattern:
'typescript'toPackage.onTest()dependencies*_test.tsfile with type tests usingapi.mainModule()Fixes #13676