@databases/shared-print-types
Advanced tools
Comparing version 1.0.0 to 1.1.0-canary-1685
@@ -8,2 +8,3 @@ import PrintOptions from './PrintOptions'; | ||
export interface FileExport { | ||
mode: 'type' | 'value'; | ||
file: FileName; | ||
@@ -19,2 +20,3 @@ isDefaultExport: () => boolean; | ||
pushTypeDeclaration(id: TypeID, declaration: (identifier: IdentifierName, imp: FileContext) => string[]): FileExport; | ||
pushReExport(id: TypeID, from: FileExport): void; | ||
pushValueDeclaration(id: TypeID, declaration: (identifier: IdentifierName, imp: FileContext) => string[]): FileExport; | ||
@@ -21,0 +23,0 @@ getFiles(): { |
@@ -35,2 +35,3 @@ "use strict"; | ||
this._declarations = []; | ||
this._reExports = { type: [], value: [] }; | ||
this.file = file; | ||
@@ -92,2 +93,3 @@ this._options = options; | ||
return { | ||
mode, | ||
file: this.file, | ||
@@ -98,2 +100,14 @@ isDefaultExport: () => this.getDefaultName() === identifierName, | ||
} | ||
pushReExport(dest, source) { | ||
const identifierName = (0, PrintOptions_1.resolveExportName)(dest, this._options); | ||
if (this._declarationNames.has(identifierName)) { | ||
return; | ||
} | ||
const importedName = this._getImportState(source.file).getImport(source); | ||
this._declarationNames.add(identifierName); | ||
this._reExports[source.mode].push({ | ||
source: importedName, | ||
dest: identifierName, | ||
}); | ||
} | ||
getContent() { | ||
@@ -113,2 +127,20 @@ return ([ | ||
...this._declarations.map((v) => v().join('\n')), | ||
...(this._reExports.type.length | ||
? [ | ||
`export type {\n${this._reExports.type | ||
.map((t) => t.source === t.dest | ||
? ` ${t.source},` | ||
: ` ${t.source} as ${t.dest},`) | ||
.join(`\n`)}\n}`, | ||
] | ||
: []), | ||
...(this._reExports.value.length | ||
? [ | ||
`export {\n${this._reExports.value | ||
.map((t) => t.source === t.dest | ||
? ` ${t.source},` | ||
: ` ${t.source} as ${t.dest},`) | ||
.join(`\n`)}\n}`, | ||
] | ||
: []), | ||
].join('\n\n') + '\n'); | ||
@@ -130,2 +162,7 @@ } | ||
} | ||
pushReExport(id, from) { | ||
const file = (0, PrintOptions_1.resolveFilename)(id, this.options); | ||
const fileContent = mapGetOrSet(this._files, file, () => new FileContent(file, this.options)); | ||
fileContent.pushReExport(id, from); | ||
} | ||
pushValueDeclaration(id, declaration) { | ||
@@ -132,0 +169,0 @@ return this._pushDeclaration(id, 'value', declaration); |
{ | ||
"name": "@databases/shared-print-types", | ||
"version": "1.0.0", | ||
"version": "1.1.0-canary-1685", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
70096
379
2