Skip to content

Commit

Permalink
feat: upgrade to TypeScript 5.2 (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Nov 14, 2023
1 parent d0f8617 commit 9be930c
Show file tree
Hide file tree
Showing 16 changed files with 147 additions and 86 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target
.vscode
.vscode
tests/*/npm
18 changes: 15 additions & 3 deletions lib/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function getCompilerScriptTarget(target: ScriptTarget) {
}
}

// Created from https://github.com/microsoft/TypeScript/blob/0ad5f82d6243db80d42bc0abb7a191dd380e980e/src/compiler/commandLineParser.ts
// Created from https://github.com/microsoft/TypeScript/blob/v5.2.2/src/compiler/commandLineParser.ts
// then aligned with tsconfig.json's casing
export type LibName =
| "ES5"
Expand All @@ -58,6 +58,7 @@ export type LibName =
| "ES2020"
| "ES2021"
| "ES2022"
| "ES2023"
| "ESNext"
| "DOM"
| "DOM.Iterable"
Expand All @@ -75,6 +76,7 @@ export type LibName =
| "ES2015.Symbol"
| "ES2015.Symbol.WellKnown"
| "ES2016.Array.Include"
| "ES2017.Date"
| "ES2017.Object"
| "ES2017.SharedMemory"
| "ES2017.String"
Expand All @@ -89,7 +91,8 @@ export type LibName =
| "ES2019.Object"
| "ES2019.String"
| "ES2019.Symbol"
| "ES2020.BigInt"
| "ES2019.Intl"
| "ES2020.Bigint"
| "ES2020.Date"
| "ES2020.Promise"
| "ES2020.SharedMemory"
Expand All @@ -105,15 +108,24 @@ export type LibName =
| "ES2022.Error"
| "ES2022.Intl"
| "ES2022.Object"
| "ES2022.SharedMemory"
| "ES2022.String"
| "ES2022.RegExp"
| "ES2023.Array"
| "ES2023.Collection"
| "ESNext.Array"
| "ESNext.Collection"
| "ESNext.Symbol"
| "ESNext.AsyncIterable"
| "ESNext.Intl"
| "ESNext.Disposable"
| "ESNext.BigInt"
| "ESNext.String"
| "ESNext.Promise"
| "ESNext.WeakRef";
| "ESNext.WeakRef"
| "ESNext.Decorators"
| "Decorators"
| "Decorators.Legacy";

export function getCompilerLibOption(target: ScriptTarget): LibName[] {
switch (target) {
Expand Down
8 changes: 4 additions & 4 deletions lib/mod.deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export * from "./transform.deps.ts";
export {
createProjectSync,
ts,
} from "https://deno.land/x/ts_morph@18.0.0/bootstrap/mod.ts";
} from "https://deno.land/x/ts_morph@20.0.0/bootstrap/mod.ts";
export { default as CodeBlockWriter } from "https://deno.land/x/code_block_writer@12.0.0/mod.ts";
export * as colors from "https://deno.land/std@0.182.0/fmt/colors.ts";
export * as glob from "https://deno.land/std@0.182.0/fs/expand_glob.ts";
export { emptyDir } from "https://deno.land/std@0.182.0/fs/empty_dir.ts";
export * as colors from "https://deno.land/std@0.181.0/fmt/colors.ts";
export * as glob from "https://deno.land/std@0.181.0/fs/expand_glob.ts";
export { emptyDir } from "https://deno.land/std@0.181.0/fs/empty_dir.ts";
2 changes: 1 addition & 1 deletion lib/pkg/snippets/dnt-wasm-a15ef721fa5290c5/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createCache } from "https://deno.land/x/deno_cache@0.5.2/mod.ts";
import { createCache } from "https://deno.land/x/deno_cache@0.6.1/mod.ts";

const fileFetcher = createCache();

Expand Down
2 changes: 1 addition & 1 deletion lib/test.deps.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.

export * from "https://deno.land/std@0.182.0/testing/asserts.ts";
export * from "https://deno.land/std@0.181.0/testing/asserts.ts";
2 changes: 1 addition & 1 deletion lib/transform.deps.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.

export * as path from "https://deno.land/std@0.182.0/path/mod.ts";
export * as path from "https://deno.land/std@0.181.0/path/mod.ts";
3 changes: 2 additions & 1 deletion mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export async function build(options: BuildOptions): Promise<void> {
jsxFragmentFactory: "React.Fragment",
importsNotUsedAsValues: ts.ImportsNotUsedAsValues.Remove,
module: ts.ModuleKind.ESNext,
moduleResolution: ts.ModuleResolutionKind.Node16,
moduleResolution: ts.ModuleResolutionKind.Bundler,
target: compilerScriptTarget,
lib: libNamesToCompilerOption(
options.compilerOptions?.lib ?? getCompilerLibOption(scriptTarget),
Expand Down Expand Up @@ -379,6 +379,7 @@ export async function build(options: BuildOptions): Promise<void> {
module: options.scriptModule === "umd"
? ts.ModuleKind.UMD
: ts.ModuleKind.CommonJS,
moduleResolution: ts.ModuleResolutionKind.Node10,
});
program = getProgramAndMaybeTypeCheck("script");
emit({
Expand Down
30 changes: 15 additions & 15 deletions rs-lib/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ async fn transform_remote_files() {
"/mod.ts",
concat!(
"import * as other from 'http://localhost/mod.ts';\n",
"import 'https://deno.land/std@0.182.0/mod.ts';",
"import 'https://deno.land/std@0.181.0/mod.ts';",
),
)
.add_remote_file(
Expand Down Expand Up @@ -607,7 +607,7 @@ async fn transform_remote_files() {
&[("content-type", "application/javascript")],
)
.add_remote_file(
"https://deno.land/std@0.182.0/mod.ts",
"https://deno.land/std@0.181.0/mod.ts",
"console.log(5);",
)
.add_remote_file_with_headers(
Expand Down Expand Up @@ -640,7 +640,7 @@ async fn transform_remote_files() {
"mod.ts",
concat!(
"import * as other from './deps/localhost/mod.js';\n",
"import './deps/deno.land/std@0.182.0/mod.js';",
"import './deps/deno.land/std@0.181.0/mod.js';",
)
),
(
Expand Down Expand Up @@ -671,7 +671,7 @@ async fn transform_remote_files() {
"deps/localhost/sub/subfolder.js",
"import * as localhost2 from '../../localhost2.js';"
),
("deps/deno.land/std@0.182.0/mod.ts", "console.log(5);"),
("deps/deno.land/std@0.181.0/mod.ts", "console.log(5);"),
(
"deps/localhost2.js",
"import * as localhost3Mod from './localhost3/mod.js';"
Expand Down Expand Up @@ -1217,7 +1217,7 @@ async fn node_module_mapping() {
.add_local_file(
"/mod.ts",
concat!(
"import * as path from 'https://deno.land/std@0.182.0/node/path.ts';\n",
"import * as path from 'https://deno.land/std@0.181.0/node/path.ts';\n",
"import { performance } from 'https://deno.land/std@0.156.0/node/perf_hooks.ts';\n",
"import * as fs from 'https://deno.land/std/node/fs/promises.ts';",
),
Expand Down Expand Up @@ -1551,7 +1551,7 @@ async fn test_entry_points_same_module_multiple_places() {
.add_local_file(
"/mod.ts",
concat!(
"export * from 'https://deno.land/std@0.182.0/path.ts';\n",
"export * from 'https://deno.land/std@0.181.0/path.ts';\n",
"import * as deps from './deps.ts';",
),
)
Expand All @@ -1560,16 +1560,16 @@ async fn test_entry_points_same_module_multiple_places() {
.add_local_file(
"/deps.ts",
concat!(
"export * from 'https://deno.land/std@0.182.0/path.ts';\n",
"export * from 'https://deno.land/std@0.182.0/flags.ts';",
"export * from 'https://deno.land/std@0.181.0/path.ts';\n",
"export * from 'https://deno.land/std@0.181.0/flags.ts';",
),
)
.add_remote_file(
"https://deno.land/std@0.182.0/flags.ts",
"https://deno.land/std@0.181.0/flags.ts",
"export class Flags {}",
)
.add_remote_file(
"https://deno.land/std@0.182.0/path.ts",
"https://deno.land/std@0.181.0/path.ts",
"export class Path {}",
)
.add_local_file("/mod.test.ts", "import * as deps from './deps.ts';");
Expand All @@ -1585,22 +1585,22 @@ async fn test_entry_points_same_module_multiple_places() {
(
"mod.ts",
concat!(
"export * from './deps/deno.land/std@0.182.0/path.js';\n",
"export * from './deps/deno.land/std@0.181.0/path.js';\n",
"import * as deps from './deps.js';",
)
),
(
"deps.ts",
concat!(
"export * from './deps/deno.land/std@0.182.0/path.js';\n",
"export * from './deps/deno.land/std@0.182.0/flags.js';",
"export * from './deps/deno.land/std@0.181.0/path.js';\n",
"export * from './deps/deno.land/std@0.181.0/flags.js';",
)
),
(
"deps/deno.land/std@0.182.0/flags.ts",
"deps/deno.land/std@0.181.0/flags.ts",
"export class Flags {}"
),
("deps/deno.land/std@0.182.0/path.ts", "export class Path {}")
("deps/deno.land/std@0.181.0/path.ts", "export class Path {}")
]
);
assert_eq!(result.main.entry_points, &[PathBuf::from("mod.ts")]);
Expand Down
Loading

0 comments on commit 9be930c

Please sign in to comment.