Comparing version
# typechain | ||
## 6.0.3 | ||
### Patch Changes | ||
- a0fba00: Ethers V5 target doesn't emit unused imports anymore. | ||
## 6.0.2 | ||
@@ -4,0 +10,0 @@ |
export interface IOptions { | ||
files: string[]; | ||
target: string; | ||
outDir?: string; | ||
outDir?: string | undefined; | ||
flags: { | ||
@@ -6,0 +6,0 @@ alwaysGenerateOverloads: boolean; |
@@ -9,1 +9,16 @@ /** | ||
export declare function createPositionalIdentifier(identifierName: string): string; | ||
/** | ||
* @internal | ||
*/ | ||
export declare function getUsedIdentifiers(identifiers: string[], sourceFile: string): string[]; | ||
/** | ||
* @internal | ||
*/ | ||
export declare function createImportTypeDeclaration(identifiers: string[], moduleSpecifier: string): string; | ||
declare type ModuleSpecifier = string; | ||
declare type Identifier = string; | ||
/** | ||
* @internal | ||
*/ | ||
export declare function createImportsForUsedIdentifiers(possibleImports: Record<ModuleSpecifier, Identifier[]>, sourceFile: string): string; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createPositionalIdentifier = void 0; | ||
exports.createImportsForUsedIdentifiers = exports.createImportTypeDeclaration = exports.getUsedIdentifiers = exports.createPositionalIdentifier = void 0; | ||
/** | ||
@@ -38,2 +38,36 @@ * A set of reserved words in EcmaScript 2021 | ||
exports.createPositionalIdentifier = createPositionalIdentifier; | ||
/** | ||
* @internal | ||
*/ | ||
function getUsedIdentifiers(identifiers, sourceFile) { | ||
const usedIdentifiers = new Set(); | ||
identifiers.forEach((identifier) => { | ||
if (new RegExp(`\\W${identifier}(\\W|$)`).test(sourceFile)) | ||
usedIdentifiers.add(identifier); | ||
}); | ||
return Array.from(usedIdentifiers); | ||
} | ||
exports.getUsedIdentifiers = getUsedIdentifiers; | ||
/** | ||
* @internal | ||
*/ | ||
function createImportDeclaration(identifiers, moduleSpecifier) { | ||
return identifiers.length > 0 ? `import { ${identifiers.join(', ')} } from "${moduleSpecifier}"` : ''; | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
function createImportTypeDeclaration(identifiers, moduleSpecifier) { | ||
return identifiers.length > 0 ? `import { ${identifiers.join(', ')} } from "${moduleSpecifier}"` : ''; | ||
} | ||
exports.createImportTypeDeclaration = createImportTypeDeclaration; | ||
/** | ||
* @internal | ||
*/ | ||
function createImportsForUsedIdentifiers(possibleImports, sourceFile) { | ||
return Object.entries(possibleImports) | ||
.map(([moduleSpecifier, identifiers]) => createImportDeclaration(getUsedIdentifiers(identifiers, sourceFile), moduleSpecifier)) | ||
.join('\n'); | ||
} | ||
exports.createImportsForUsedIdentifiers = createImportsForUsedIdentifiers; | ||
//# sourceMappingURL=syntax.js.map |
@@ -30,3 +30,3 @@ import { Dictionary } from 'ts-essentials'; | ||
outputs: AbiOutputParameter[]; | ||
documentation?: FunctionDocumentation; | ||
documentation?: FunctionDocumentation | undefined; | ||
} | ||
@@ -42,3 +42,3 @@ export interface FunctionWithoutOutputDeclaration extends FunctionDeclaration { | ||
rawName: string; | ||
fallback?: FunctionWithoutInputDeclaration; | ||
fallback?: FunctionWithoutInputDeclaration | undefined; | ||
constructor: FunctionWithoutOutputDeclaration[]; | ||
@@ -52,3 +52,3 @@ functions: Dictionary<FunctionDeclaration[]>; | ||
notice?: string; | ||
}; | ||
} | undefined; | ||
} | ||
@@ -77,3 +77,3 @@ export interface RawAbiParameter { | ||
isIndexed: boolean; | ||
name?: string; | ||
name?: string | undefined; | ||
type: EvmType; | ||
@@ -80,0 +80,0 @@ } |
@@ -9,4 +9,4 @@ /// <reference types="node" /> | ||
target: string; | ||
outDir?: string; | ||
prettier?: object; | ||
outDir?: string | undefined; | ||
prettier?: object | undefined; | ||
filesToProcess: string[]; | ||
@@ -13,0 +13,0 @@ allFiles: string[]; |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "6.0.2", | ||
"version": "6.0.3", | ||
"license": "MIT", | ||
@@ -14,0 +14,0 @@ "repository": "https://github.com/ethereum-ts/Typechain", |
@@ -10,3 +10,3 @@ <p align="center"> | ||
<a href="/package.json"><img alt="Software License" src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square"></a> | ||
<a href="https://discord.gg/cpbj5BDq"><img alt="Join our discord!" src="https://img.shields.io/discord/895381864922091630.svg?color=7289da&label=deth&logo=discord&style=flat-square"></a> | ||
<a href="https://discord.gg/wQDkeDgzgv"><img alt="Join our discord!" src="https://img.shields.io/discord/895381864922091630.svg?color=7289da&label=deth&logo=discord&style=flat-square"></a> | ||
</p> | ||
@@ -13,0 +13,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
92934
3.31%1211
4.22%