Skip to content

Commit 66e0e13

Browse files
committed
use isolatedDeclarations
1 parent 9181c22 commit 66e0e13

File tree

10 files changed

+15
-12
lines changed

10 files changed

+15
-12
lines changed

src/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export const supportedExtensions = [ `.js`, `.ts` ]
2-
export const validDBMethods = [ `i`, `r`, `f`, `u`, `u1`, `us`, `ObjectId` ]
1+
export const supportedExtensions: string[] = [ `.js`, `.ts` ]
2+
export const validDBMethods: string[] = [ `i`, `r`, `f`, `u`, `u1`, `us`, `ObjectId` ]

src/generateTypeDeclaration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { readDirectoryWithStats } from "@samual/lib/readDirectoryWithStats"
22
import { basename as getBaseName, resolve as resolvePath } from "path"
33
import * as PathPosix from "path/posix"
44

5-
export async function generateTypeDeclaration(sourceDirectory: string, hackmudPath?: string) {
5+
export async function generateTypeDeclaration(sourceDirectory: string, hackmudPath?: string): Promise<string> {
66
const users = new Set<string>()
77

88
if (hackmudPath) {

src/processScript/minify.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const minifyNumber = async (number: number) => /\$\((?<number>.+)\)/
4242
export async function minify(
4343
file: File,
4444
{ uniqueId = `00000000000`, mangleNames = false, forceQuineCheats, autocomplete }: MinifyOptions = {}
45-
) {
45+
): Promise<string> {
4646
assert(/^\w{11}$/.exec(uniqueId), HERE)
4747

4848
let program!: NodePath<Program>

src/processScript/postprocess.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const postprocess = (code: string, uniqueId: string) => code
1+
export const postprocess = (code: string, uniqueId: string): string => code
22
.replace(/^function\s*[\w$]+\(/, `function(`)
33
.replace(new RegExp(`\\$${uniqueId}\\$\\\\(?:\\\\)?\\$SC_DOLLAR\\$`, `g`), `S\\C$`)
44
.replace(new RegExp(`\\$${uniqueId}\\$\\\\(?:\\\\)?\\$DB_DOLLAR\\$`, `g`), `D\\B$`)

src/processScript/preprocess.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export type PreprocessOptions = LaxPartial<{ /** 11 a-z 0-9 characters */ unique
1818

1919
/** @param code source code for preprocessing
2020
* @param options {@link PreprocessOptions details} */
21-
export async function preprocess(code: string, { uniqueId = `00000000000` }: PreprocessOptions = {}) {
21+
export async function preprocess(code: string, { uniqueId = `00000000000` }: PreprocessOptions = {})
22+
: Promise<{ code: string }> {
2223
assert(/^\w{11}$/.test(uniqueId), HERE)
2324

2425
const sourceCode = code

src/processScript/shared.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ export function getReferencePathsToGlobal(name: string, program: NodePath<Progra
1616
return binding.referencePaths as NodePath<Identifier>[]
1717
}
1818

19-
export const includesIllegalString = (toCheck: string) => toCheck.includes(`SC$`) || toCheck.includes(`DB$`) ||
19+
export const includesIllegalString = (toCheck: string): boolean => toCheck.includes(`SC$`) || toCheck.includes(`DB$`) ||
2020
toCheck.includes(`__D_S`) || toCheck.includes(`__FMCL_`) || toCheck.includes(`__G_`)
2121

22-
export const replaceUnsafeStrings = (uniqueId: string, toReplace: string) => toReplace
22+
export const replaceUnsafeStrings = (uniqueId: string, toReplace: string): string => toReplace
2323
.replaceAll(`SC$`, `$${uniqueId}$\\$SC_DOLLAR$`)
2424
.replaceAll(`DB$`, `$${uniqueId}$\\$DB_DOLLAR$`)
2525
.replaceAll(`__D_S`, `$${uniqueId}$\\$D$`)

src/pull.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { resolve as resolvePath } from "path"
55
* @param sourceFolderPath path to folder containing source files
66
* @param hackmudPath path to hackmud directory
77
* @param script to pull in `user.name` format */
8-
export async function pull(sourceFolderPath: string, hackmudPath: string, script: string) {
8+
export async function pull(sourceFolderPath: string, hackmudPath: string, script: string): Promise<void> {
99
const [ user, name ] = script.split(`.`)
1010

1111
if (!user || !name)

src/syncMacros.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { readDirectoryWithStats } from "@samual/lib/readDirectoryWithStats"
22
import { stat as getFileStatus, readFile, writeFile } from "fs/promises"
33
import { basename as getBaseName, extname as getFileExtension, resolve as resolvePath } from "path"
44

5-
export async function syncMacros(hackmudPath: string) {
5+
export async function syncMacros(hackmudPath: string): Promise<{ macrosSynced: number, usersSynced: number }> {
66
const files = await readDirectoryWithStats(hackmudPath)
77
const macros = new Map<string, { macro: string, date: Date }>()
88
const users: string[] = []

src/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"types": [ "node", "@total-typescript/ts-reset", "babel-plugin-here/env" ],
77
"rootDir": ".",
88
"module": "es2022",
9-
"moduleResolution": "bundler"
9+
"moduleResolution": "bundler",
10+
"isolatedDeclarations": true,
11+
"checkJs": false
1012
},
1113
"include": [ "**/*" ]
1214
}

src/watch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export async function watch(sourceDirectory: string, hackmudDirectory: string, {
3333
typeDeclarationPath: typeDeclarationPath_,
3434
onReady,
3535
forceQuineCheats
36-
}: WatchOptions = {}) {
36+
}: WatchOptions = {}): Promise<void> {
3737
if (!scripts.length)
3838
throw new Error(`scripts option was an empty array`)
3939

0 commit comments

Comments
 (0)