Skip to content

Commit

Permalink
Upgrade to TypeScript 5.7.2
Browse files Browse the repository at this point in the history
Also, use node's built-in type stripping instead of @swc-node/register.

Also, add support for node:test runner VS Code plugin.
  • Loading branch information
mjackson committed Dec 6, 2024
1 parent c46c3d1 commit 2ff3044
Show file tree
Hide file tree
Showing 94 changed files with 243 additions and 603 deletions.
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{
"deno.enablePaths": ["./packages/multipart-parser/examples/deno"]
"deno.enablePaths": ["./packages/multipart-parser/examples/deno"],
"nodejs-testing.extensions": [
{
"extensions": ["ts"],
"parameters": ["--experimental-strip-types", "--disable-warning=ExperimentalWarning"]
}
],
"typescript.tsdk": "node_modules/typescript/lib"
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"private": true,
"packageManager": "[email protected]",
"devDependencies": {
"prettier": "^3.3.3"
"prettier": "^3.3.3",
"typescript": "^5.7.2"
},
"engines": {
"node": ">=22"
Expand Down
6 changes: 2 additions & 4 deletions packages/fetch-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@
"@mjackson/headers": "workspace:^"
},
"devDependencies": {
"@swc-node/register": "^1.10.9",
"@types/node": "^20.14.10",
"tsup": "^8.3.5",
"typescript": "^5.6.3"
"tsup": "^8.3.5"
},
"scripts": {
"build": "tsup",
"test": "node --import @swc-node/register/esm-register --test ./src/**/*.spec.ts",
"test": "node --experimental-strip-types --disable-warning=ExperimentalWarning --test ./src/**/*.test.ts",
"prepare": "pnpm run build"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/fetch-proxy/src/fetch-proxy.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { type FetchProxyOptions, type FetchProxy, createFetchProxy } from './lib/fetch-proxy.js';
export { type FetchProxyOptions, type FetchProxy, createFetchProxy } from './lib/fetch-proxy.ts';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';

import { FetchProxyOptions, createFetchProxy } from './fetch-proxy.js';
import { type FetchProxyOptions, createFetchProxy } from './fetch-proxy.ts';

async function runProxy(
request: Request,
Expand Down
12 changes: 8 additions & 4 deletions packages/fetch-proxy/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"compilerOptions": {
"lib": ["DOM", "ES2020"],
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true
"strict": true,
"lib": ["DOM", "DOM.Iterable", "ES2020"],
"module": "ES2022",
"moduleResolution": "Bundler",
"target": "ESNext",
"allowImportingTsExtensions": true,
"rewriteRelativeImportExtensions": true,
"verbatimModuleSyntax": true
}
}
9 changes: 0 additions & 9 deletions packages/fetch-proxy/tsconfig.lib.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/fetch-proxy/tsconfig.spec.json

This file was deleted.

File renamed without changes.
6 changes: 2 additions & 4 deletions packages/file-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,12 @@
"@mjackson/lazy-file": "workspace:^"
},
"devDependencies": {
"@swc-node/register": "^1.10.9",
"@types/node": "^20.14.10",
"tsup": "^8.3.5",
"typescript": "^5.6.3"
"tsup": "^8.3.5"
},
"scripts": {
"build": "tsup",
"test": "node --import @swc-node/register/esm-register --test ./src/**/*.spec.ts",
"test": "node --experimental-strip-types --disable-warning=ExperimentalWarning --test ./src/**/*.test.ts",
"prepare": "pnpm run build"
},
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { after, describe, it } from 'node:test';
import * as fs from 'node:fs';
import * as path from 'node:path';

import { LocalFileStorage } from './local-file-storage.js';
import { LocalFileStorage } from './local-file-storage.ts';

const __dirname = new URL('.', import.meta.url).pathname;

Expand Down
2 changes: 1 addition & 1 deletion packages/file-storage/src/lib/local-file-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as fsp from 'node:fs/promises';
import * as path from 'node:path';
import { openFile, writeFile } from '@mjackson/lazy-file/fs';

import { FileStorage } from './file-storage.js';
import { type FileStorage } from './file-storage.ts';

/**
* A `FileStorage` that is backed by the local filesystem.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';

import { MemoryFileStorage } from './memory-file-storage.js';
import { MemoryFileStorage } from './memory-file-storage.ts';

describe('MemoryFileStorage', () => {
it('stores and retrieves files', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/file-storage/src/lib/memory-file-storage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FileStorage } from './file-storage.js';
import { type FileStorage } from './file-storage.ts';

/**
* A simple, in-memory implementation of the `FileStorage` interface.
Expand Down
12 changes: 8 additions & 4 deletions packages/file-storage/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"compilerOptions": {
"lib": ["DOM", "ES2020"],
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true
"strict": true,
"lib": ["DOM", "DOM.Iterable", "ES2020"],
"module": "ES2022",
"moduleResolution": "Bundler",
"target": "ESNext",
"allowImportingTsExtensions": true,
"rewriteRelativeImportExtensions": true,
"verbatimModuleSyntax": true
}
}
9 changes: 0 additions & 9 deletions packages/file-storage/tsconfig.lib.json

This file was deleted.

8 changes: 0 additions & 8 deletions packages/file-storage/tsconfig.spec.json

This file was deleted.

6 changes: 2 additions & 4 deletions packages/form-data-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@
"@mjackson/multipart-parser": "workspace:^"
},
"devDependencies": {
"@swc-node/register": "^1.10.9",
"@types/node": "^22.4.1",
"tsup": "^8.3.5",
"typescript": "^5.6.3"
"tsup": "^8.3.5"
},
"scripts": {
"build": "tsup",
"test": "node --import @swc-node/register/esm-register --test ./src/**/*.spec.ts",
"test": "node --experimental-strip-types --disable-warning=ExperimentalWarning --test ./src/**/*.test.ts",
"prepare": "pnpm run build"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/form-data-parser/src/form-data-parser.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { FileUpload, type FileUploadHandler, parseFormData } from './lib/form-data.js';
export { FileUpload, type FileUploadHandler, parseFormData } from './lib/form-data.ts';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as assert from 'node:assert/strict';
import { describe, it, mock } from 'node:test';

import { FileUploadHandler, parseFormData } from './form-data.js';
import { type FileUploadHandler, parseFormData } from './form-data.ts';

describe('parseFormData', () => {
it('parses a application/x-www-form-urlencoded request', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/form-data-parser/src/lib/form-data.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
isMultipartRequest,
parseMultipartRequest,
MultipartParserOptions,
type MultipartParserOptions,
MultipartPart,
} from '@mjackson/multipart-parser';

Expand Down
12 changes: 8 additions & 4 deletions packages/form-data-parser/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"compilerOptions": {
"lib": ["DOM", "ES2020"],
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true
"strict": true,
"lib": ["DOM", "DOM.Iterable", "ES2020"],
"module": "ES2022",
"moduleResolution": "Bundler",
"target": "ESNext",
"allowImportingTsExtensions": true,
"rewriteRelativeImportExtensions": true,
"verbatimModuleSyntax": true
}
}
9 changes: 0 additions & 9 deletions packages/form-data-parser/tsconfig.lib.json

This file was deleted.

8 changes: 0 additions & 8 deletions packages/form-data-parser/tsconfig.spec.json

This file was deleted.

6 changes: 2 additions & 4 deletions packages/headers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@
"./package.json": "./package.json"
},
"devDependencies": {
"@swc-node/register": "^1.10.9",
"@types/node": "^20.14.10",
"tsup": "^8.3.5",
"typescript": "^5.6.3"
"tsup": "^8.3.5"
},
"scripts": {
"build": "tsup",
"test": "node --import @swc-node/register/esm-register --test ./src/**/*.spec.ts",
"test": "node --experimental-strip-types --disable-warning=ExperimentalWarning --test ./src/**/*.test.ts",
"prepare": "pnpm run build"
},
"keywords": [
Expand Down
18 changes: 11 additions & 7 deletions packages/headers/src/headers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
export { AcceptLanguageInit, AcceptLanguage } from './lib/accept-language.js';
export { CacheControlInit, CacheControl } from './lib/cache-control.js';
export { ContentDispositionInit, ContentDisposition } from './lib/content-disposition.js';
export { ContentTypeInit, ContentType } from './lib/content-type.js';
export { CookieInit, Cookie } from './lib/cookie.js';
export { SetCookieInit, SetCookie } from './lib/set-cookie.js';
export { type AcceptLanguageInit, AcceptLanguage } from './lib/accept-language.ts';
export { type CacheControlInit, CacheControl } from './lib/cache-control.ts';
export { type ContentDispositionInit, ContentDisposition } from './lib/content-disposition.ts';
export { type ContentTypeInit, ContentType } from './lib/content-type.ts';
export { type CookieInit, Cookie } from './lib/cookie.ts';
export { type SetCookieInit, SetCookie } from './lib/set-cookie.ts';

export { SuperHeaders as default, SuperHeadersInit, SuperHeaders } from './lib/super-headers.js';
export {
type SuperHeadersInit,
SuperHeaders,
SuperHeaders as default,
} from './lib/super-headers.ts';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';

import { AcceptLanguage } from './accept-language.js';
import { AcceptLanguage } from './accept-language.ts';

describe('Accept-Language', () => {
it('initializes with an empty string', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/headers/src/lib/accept-language.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HeaderValue } from './header-value.js';
import { parseParams } from './param-values.js';
import { isIterable } from './utils.js';
import { type HeaderValue } from './header-value.ts';
import { parseParams } from './param-values.ts';
import { isIterable } from './utils.ts';

export type AcceptLanguageInit =
| Iterable<string | [string] | [string, number | undefined]>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';

import { CacheControl } from './cache-control.js';
import { CacheControl } from './cache-control.ts';

describe('CacheControl', () => {
it('initializes with an empty string', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/headers/src/lib/cache-control.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HeaderValue } from './header-value.js';
import { parseParams } from './param-values.js';
import { type HeaderValue } from './header-value.ts';
import { parseParams } from './param-values.ts';

// Taken from https://github.com/jjenzz/pretty-cache-header by jjenzz
// License: MIT https://github.com/jjenzz/pretty-cache-header/blob/main/LICENSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';

import { ContentDisposition } from './content-disposition.js';
import { ContentDisposition } from './content-disposition.ts';

describe('ContentDisposition', () => {
it('initializes with an empty string', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/headers/src/lib/content-disposition.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HeaderValue } from './header-value.js';
import { parseParams, quote } from './param-values.js';
import { type HeaderValue } from './header-value.ts';
import { parseParams, quote } from './param-values.ts';

export interface ContentDispositionInit {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';

import { ContentType } from './content-type.js';
import { ContentType } from './content-type.ts';

describe('ContentType', () => {
it('initializes with an empty string', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/headers/src/lib/content-type.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HeaderValue } from './header-value.js';
import { parseParams, quote } from './param-values.js';
import { type HeaderValue } from './header-value.ts';
import { parseParams, quote } from './param-values.ts';

export interface ContentTypeInit {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';

import { Cookie } from './cookie.js';
import { Cookie } from './cookie.ts';

describe('Cookie', () => {
it('initializes with an empty string', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/headers/src/lib/cookie.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HeaderValue } from './header-value.js';
import { parseParams, quote } from './param-values.js';
import { isIterable } from './utils.js';
import { type HeaderValue } from './header-value.ts';
import { parseParams, quote } from './param-values.ts';
import { isIterable } from './utils.ts';

export type CookieInit = Iterable<[string, string]> | Record<string, string>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';

import { canonicalHeaderName } from './header-names.js';
import { canonicalHeaderName } from './header-names.ts';

describe('normalizeHeaderName', () => {
it('handles common headers correctly', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';

import { parseParams } from './param-values.js';
import { parseParams } from './param-values.ts';

describe('parseParams', () => {
it('correctly parses a string of parameters for a Content-Type header', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';

import { SetCookie } from './set-cookie.js';
import { SetCookie } from './set-cookie.ts';

describe('SetCookie', () => {
it('initializes with an empty string', () => {
Expand Down
Loading

0 comments on commit 2ff3044

Please sign in to comment.