@checkdigit/typescript-config 3.3.0-PR.29-5bac → 3.3.0-PR.30-8d2b
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/module-directory/index.ts +3 -0
- package/src/module.ts +9 -0
- package/tsconfig.json +2 -2
- package/src/index.ts +0 -135
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"name":"@checkdigit/typescript-config","version":"3.3.0-PR.
|
1
|
+
{"name":"@checkdigit/typescript-config","version":"3.3.0-PR.30-8d2b","description":"Check Digit standard Typescript configuration","prettier":"@checkdigit/prettier-config","engines":{"node":">=16"},"peerDependencies":{"@types/node":">=16","typescript":">=5.0.4 <5.1"},"repository":{"type":"git","url":"git+https://github.com/checkdigit/typescript-config.git"},"author":"Check Digit, LLC","license":"MIT","bugs":{"url":"https://github.com/checkdigit/typescript-config/issues"},"homepage":"https://github.com/checkdigit/typescript-config#readme","scripts":{"preversion":"npm test","postversion":"git push && git push --tags","prettier":"prettier --ignore-path .gitignore --list-different .","prettier:fix":"prettier --ignore-path .gitignore --write .","test":"npm run ci:compile && npm run ci:test && npm run ci:style","build-tsc":"rimraf build && tsc","build-es":"rimraf build-es && esbuild ./src/*.ts ./src/*/*.ts --platform=node --bundle --format=esm --sourcemap=inline --outdir=build-es","build-swc":"rimraf build-swc && swc ./src -d ./build-swc","ci:test":"NODE_OPTIONS=\"--no-warnings --experimental-vm-modules\" jest --coverage=false","ci:compile":"npm run build-tsc && npm run build-es","ci:style":"npm run prettier"},"devDependencies":{"@checkdigit/prettier-config":"^3.4.0","@swc/cli":"^0.1.62","@swc/core":"^1.3.50","@types/jest":"^29.5.0","esbuild":"^0.17.16","get-port":"^6.1.2","got":"11.8.6","jest":"^29.5.0","rimraf":"^5.0.0","ts-jest":"^29.1.0"},"jest":{"extensionsToTreatAsEsm":[".mts"],"transform":{"^.+\\.ts$":["ts-jest",{"isolatedModules":true,"diagnostics":false,"useESM":false}]},"collectCoverageFrom":["<rootDir>/src/**","!<rootDir>/src/**/*.spec.ts","!<rootDir>/src/**/*.test.ts"],"testMatch":["<rootDir>/src/**/*.spec.ts"]},"files":["tsconfig.json","SECURITY.md","/src/"]}
|
package/src/module.ts
ADDED
package/tsconfig.json
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"compilerOptions": {
|
3
3
|
"module": "commonjs",
|
4
|
-
"target": "
|
5
|
-
"lib": ["esnext", "dom", "webworker"],
|
4
|
+
"target": "esnext",
|
6
5
|
"sourceMap": true,
|
7
6
|
"inlineSources": true,
|
8
7
|
"outDir": "build",
|
@@ -24,6 +23,7 @@
|
|
24
23
|
"emitDecoratorMetadata": true,
|
25
24
|
"experimentalDecorators": true,
|
26
25
|
"resolveJsonModule": true,
|
26
|
+
"esModuleInterop": true,
|
27
27
|
"noUncheckedIndexedAccess": true,
|
28
28
|
"noPropertyAccessFromIndexSignature": true,
|
29
29
|
"allowUnusedLabels": false,
|
package/src/index.ts
DELETED
@@ -1,135 +0,0 @@
|
|
1
|
-
// index.ts
|
2
|
-
|
3
|
-
import { strict as assert } from 'node:assert';
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Check for Typescript 4.4 features
|
7
|
-
*/
|
8
|
-
|
9
|
-
interface SymbolIndexSignature44 {
|
10
|
-
[name: symbol]: number;
|
11
|
-
}
|
12
|
-
|
13
|
-
assert.ok({} as SymbolIndexSignature44);
|
14
|
-
|
15
|
-
interface Person44 {
|
16
|
-
name: string;
|
17
|
-
age?: number;
|
18
|
-
}
|
19
|
-
|
20
|
-
// @ts-expect-error
|
21
|
-
const person: Person44 = {
|
22
|
-
name: 'Bob',
|
23
|
-
age: undefined, // errors with exactOptionalPropertyTypes = true.
|
24
|
-
};
|
25
|
-
|
26
|
-
try {
|
27
|
-
console.log('hello');
|
28
|
-
} catch (error) {
|
29
|
-
// @ts-expect-error
|
30
|
-
console.error(err.message); // errors with useUnknownInCatchVariables = true
|
31
|
-
}
|
32
|
-
|
33
|
-
/**
|
34
|
-
* Check for Typescript 4.5 features
|
35
|
-
*/
|
36
|
-
|
37
|
-
// type modifiers on import names
|
38
|
-
import { ok, type AssertPredicate } from 'node:assert';
|
39
|
-
|
40
|
-
ok({} as AssertPredicate);
|
41
|
-
|
42
|
-
// Awaited type
|
43
|
-
ok({} as Awaited<Promise<string>>);
|
44
|
-
|
45
|
-
// template string types as discriminants
|
46
|
-
interface Success45 {
|
47
|
-
type: `${string}Success`;
|
48
|
-
body: string;
|
49
|
-
}
|
50
|
-
|
51
|
-
interface Error45 {
|
52
|
-
type: `${string}Error`;
|
53
|
-
message: string;
|
54
|
-
}
|
55
|
-
|
56
|
-
function handler45(r: Success45 | Error45) {
|
57
|
-
if (r.type === 'HttpSuccess') {
|
58
|
-
// 'r' has type 'Success'
|
59
|
-
assert.ok(r.body);
|
60
|
-
}
|
61
|
-
}
|
62
|
-
handler45({ type: 'HttpSuccess', body: 'Hello' });
|
63
|
-
|
64
|
-
/**
|
65
|
-
* Check for Typescript 4.6 features
|
66
|
-
*/
|
67
|
-
|
68
|
-
// control flow analysis for destructured discriminated unions
|
69
|
-
type Action46 = { kind: 'NumberContents'; payload: number } | { kind: 'StringContents'; payload: string };
|
70
|
-
|
71
|
-
function processAction46(action: Action46) {
|
72
|
-
const { kind, payload } = action;
|
73
|
-
if (kind === 'NumberContents') {
|
74
|
-
assert.ok(payload * 2);
|
75
|
-
} else if (kind === 'StringContents') {
|
76
|
-
assert.ok(payload.trim());
|
77
|
-
}
|
78
|
-
}
|
79
|
-
assert.equal(processAction46({ kind: 'NumberContents', payload: 5 }), undefined);
|
80
|
-
|
81
|
-
/**
|
82
|
-
* Check for Typescript 4.7 features
|
83
|
-
*/
|
84
|
-
|
85
|
-
// control-flow analysis for bracketed element access
|
86
|
-
const key = Symbol();
|
87
|
-
const numberOrString = Math.random() < 0.5 ? 42 : 'hello';
|
88
|
-
const obj = {
|
89
|
-
[key]: numberOrString,
|
90
|
-
};
|
91
|
-
if (typeof obj[key] === 'string') {
|
92
|
-
assert.ok(obj[key].toUpperCase()); // 4.7 knows that obj[key] is a string
|
93
|
-
}
|
94
|
-
|
95
|
-
/**
|
96
|
-
* Check for Typescript 4.8 features
|
97
|
-
*/
|
98
|
-
|
99
|
-
// improved intersection reduction, union compatibility, and narrowing
|
100
|
-
function f48(x: unknown, y: {} | null | undefined) {
|
101
|
-
x = y;
|
102
|
-
y = x; // works in 4.8
|
103
|
-
assert.equal(x, y);
|
104
|
-
}
|
105
|
-
f48(null, undefined);
|
106
|
-
|
107
|
-
function foo48<T>(x: NonNullable<T>, y: NonNullable<NonNullable<T>>) {
|
108
|
-
x = y;
|
109
|
-
y = x; // works in 4.8
|
110
|
-
assert.equal(x, y);
|
111
|
-
}
|
112
|
-
foo48<string>('hello', 'world');
|
113
|
-
|
114
|
-
function throwIfNullable48<T>(value: T): NonNullable<T> {
|
115
|
-
if (value === undefined || value === null) {
|
116
|
-
throw Error('Nullable value!');
|
117
|
-
}
|
118
|
-
return value; // works in 4.8
|
119
|
-
}
|
120
|
-
assert.equal(throwIfNullable48(42), 42);
|
121
|
-
|
122
|
-
/**
|
123
|
-
* Check for Typescript 4.9 features
|
124
|
-
*/
|
125
|
-
type Colors49 = 'red' | 'green' | 'blue';
|
126
|
-
type RGB49 = [red: number, green: number, blue: number];
|
127
|
-
const palette49 = {
|
128
|
-
red: [255, 0, 0],
|
129
|
-
green: '#00ff00',
|
130
|
-
// @ts-expect-error
|
131
|
-
bleu: [0, 0, 255], // typo is now caught
|
132
|
-
} satisfies Record<Colors49, string | RGB49>;
|
133
|
-
assert.equal(typeof palette49, 'object');
|
134
|
-
|
135
|
-
console.log('complete');
|