Skip to content

Commit

Permalink
[env:node] Add assert module (#4520)
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalduez committed Sep 29, 2023
1 parent 5ef6b0e commit 6fef4eb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
34 changes: 20 additions & 14 deletions definitions/environments/node/flow_v0.155.x-/node.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
// https://nodejs.org/api/fs.html#promises-api
// https://nodejs.org/api/esm.html#node-imports

declare module 'fs/promises' {
declare module.exports: $Exports<'fs'>['promises'];
declare module 'node:assert' {
declare module.exports: $Exports<'assert'>;
}

declare module 'process' {
declare module.exports: Process;
declare module 'node:assert/strict' {
declare module.exports: $Exports<'assert'>['strict'];
}

declare module 'node:process' {
declare module.exports: $Exports<'process'>;
}

// https://nodejs.org/api/esm.html#node-imports

declare module 'node:events' {
declare module.exports: $Exports<'events'>;
}
Expand All @@ -22,18 +16,30 @@ declare module 'node:fs' {
declare module.exports: $Exports<'fs'>;
}

declare module 'node:fs/promises' {
declare module 'node:os' {
declare module.exports: $Exports<'os'>;
}

declare module 'fs/promises' {
declare module.exports: $Exports<'fs'>['promises'];
}

declare module 'node:os' {
declare module.exports: $Exports<'os'>;
declare module 'node:fs/promises' {
declare module.exports: $Exports<'fs'>['promises'];
}

declare module 'node:path' {
declare module.exports: $Exports<'path'>;
}

declare module 'process' {
declare module.exports: Process;
}

declare module 'node:process' {
declare module.exports: $Exports<'process'>;
}

declare module 'node:util' {
declare module.exports: $Exports<'util'>;
}
Expand Down
15 changes: 15 additions & 0 deletions definitions/environments/node/flow_v0.155.x-/test_node.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// @flow
import { describe, it } from 'flow-typed-test';

import assert from 'assert';
import events from 'events';
import fs from 'fs';
import os from 'os';
import path from 'path';
import util from 'util';
import url from 'url';

import nodeAssert from 'node:assert';
import nodeAssertStrict from 'node:assert/strict';
import nodeEvents from 'node:events';
import fsPromises from 'fs/promises';
import importProcess from 'process';
Expand All @@ -20,6 +23,18 @@ import nodeUtil from 'node:util';
import nodeUrl from 'node:url';

describe('node', () => {
describe('node:assert', () => {
it('should retrieve the corresponding Flow core types', () => {
(nodeAssert.equal: typeof assert.equal);
});
});

describe('node:assert/strict', () => {
it('should retrieve the corresponding Flow core types', () => {
(nodeAssertStrict.equal: typeof assert.strict.equal);
});
});

describe('node:events', () => {
it('should retrieve the corresponding Flow core types', () => {
(nodeEvents.EventEmitter: typeof events.EventEmitter);
Expand Down

0 comments on commit 6fef4eb

Please sign in to comment.