diff --git a/build/logic/ReplacementMap.ts b/build/logic/ReplacementMap.ts index e59d92e..e0a865b 100644 --- a/build/logic/ReplacementMap.ts +++ b/build/logic/ReplacementMap.ts @@ -22,7 +22,6 @@ export type ReplacementTarget = ( statement: ts.Statement; } ) & { - optional: boolean; sourceFile: ts.SourceFile; }; diff --git a/build/logic/generate.ts b/build/logic/generate.ts index fe38dc2..7213077 100644 --- a/build/logic/generate.ts +++ b/build/logic/generate.ts @@ -138,14 +138,8 @@ function generateStatements( } let lineInserted = false; - for (const target of replacementTargets.values()) { - for (const statement of target) { - if (statement.optional) { - // Since target from aliases may not be present in the original file, - // aliases that have not been consumed are skipped. - continue; - } - + for (const [name, targets] of replacementTargets.entries()) { + for (const statement of targets) { if (!lineInserted) { result += "// --------------------\n"; lineInserted = true; diff --git a/build/logic/scanBetterFile.ts b/build/logic/scanBetterFile.ts index 2401d39..eb63794 100644 --- a/build/logic/scanBetterFile.ts +++ b/build/logic/scanBetterFile.ts @@ -42,24 +42,19 @@ export function loadAliasFile( const name = getStatementDeclName(statement) ?? ""; const aliases = alias.get(name); if (!aliases) { + console.warn(`Warning: No alias found for ${name}`); return [statement]; } - return aliases.map((aliasDetails) => { + return aliases.flatMap((aliasDetails) => { if (aliasDetails.file !== targetFileName) { - return statement; + return []; } - return replaceAliases(statement, aliasDetails.replacement); + return [replaceAliases(statement, aliasDetails.replacement)]; }); }); // Scan the target file const replacementMap = scanStatements(printer, statements, aliasFile); - // mark everything as optional - for (const targets of replacementMap.values()) { - for (const target of targets) { - target.optional = true; - } - } return { replacementMap, @@ -122,7 +117,6 @@ function scanStatements( type: "interface", members, originalStatement: transformedStatement, - optional: false, sourceFile: sourceFile, }); return targets; @@ -146,7 +140,6 @@ function scanStatements( sourceFile, ) : new Map(), - optional: false, sourceFile: sourceFile, }); return targets; @@ -156,7 +149,6 @@ function scanStatements( statements.push({ type: "non-interface", statement: transformedStatement, - optional: false, sourceFile: sourceFile, }); return statements; diff --git a/build/util/alias.ts b/build/util/alias.ts index 40c364d..ab48b55 100644 --- a/build/util/alias.ts +++ b/build/util/alias.ts @@ -19,7 +19,6 @@ const es5TypedArrays = [ "Uint32Array", "Float32Array", "Float64Array", - "Float16Array", ]; const es2020TypedBigIntArrays = ["BigInt64Array", "BigUint64Array"];