DefinitelyTyped/types/node/node-tests.ts
Nathan Shively-Sanders 6e8dd401ba
Put current version of node in the root (#47195)
* Put current version of node in the root

Previously, the code that supports the oldest version of Typescript was
in the root: 3.1 and below. Newer versions were is ts*/ subdirectories.

This PR puts the newest version in the root, and older versions --
usually 3.7 and below -- in ts*/ subdirectories. This is possible
because all supported versions of the Typescript now understand the
typesVersions property in package.json.

This PR needs a new version of DefinitelyTyped-tools and dtslint, which
I will ship soon. It also needs to be brought up to date with master.

* Delete missed files

* fix relative reference
2020-09-02 08:25:00 -07:00

60 lines
1.1 KiB
TypeScript

import * as assert from 'assert';
assert(true, "it's working");
assert.ok(true, 'inner functions work as well');
assert.throws(() => {});
assert.throws(() => {}, /Regex test/);
assert.throws(
() => {},
() => {},
'works wonderfully',
);
assert['fail'](true, true, 'works like a charm');
{
const a = null as any;
assert.ifError(a);
a; // $ExpectType null | undefined
}
{
const a = true as boolean;
assert(a);
a; // $ExpectType true
}
{
// tslint:disable-next-line: no-null-undefined-union
const a = 13 as number | null | undefined;
assert(a);
a; // $ExpectType number
}
{
const a = true as boolean;
assert.ok(a);
a; // $ExpectType true
}
{
// tslint:disable-next-line: no-null-undefined-union
const a = 13 as number | null | undefined;
assert.ok(a);
a; // $ExpectType number
}
{
const a = 'test' as any;
assert.strictEqual(a, 'test');
a; // $ExpectType string
}
{
const a = { b: 2 } as any;
assert.deepStrictEqual(a, { b: 2 });
a; // $ExpectType { b: number; }
}