mirror of
https://github.com/optilude/xlsx-template.git
synced 2026-07-02 00:17:39 +08:00
fix(types): narrow generate return type by output type (#220)
This commit is contained in:
committed by
GitHub
parent
ab52ae20d7
commit
8757308c9a
Vendored
+5
-3
@@ -27,8 +27,10 @@ interface OutputByType {
|
||||
nodebuffer: Buffer;
|
||||
}
|
||||
|
||||
export type GenerateOptions = {
|
||||
type: keyof OutputByType
|
||||
type GenerateType = keyof OutputByType;
|
||||
|
||||
export type GenerateOptions<T extends GenerateType = GenerateType> = {
|
||||
type: T;
|
||||
};
|
||||
|
||||
interface RangeSplit
|
||||
@@ -60,7 +62,7 @@ class XlsxTemplate
|
||||
public copySheet(sheetName : string, copyName : string, binary? : boolean) : this;
|
||||
public loadTemplate(data : Buffer) : void;
|
||||
public substitute(sheetName : string | number, substitutions : Object) : void;
|
||||
public generate<T extends GenerateOptions>(options : T) : OutputByType[OutputByType];
|
||||
public generate<T extends GenerateType>(options: GenerateOptions<T>): OutputByType[T];
|
||||
public generate() : any;
|
||||
|
||||
public replaceString(oldString : string, newString : string) : number; // returns idx
|
||||
|
||||
Reference in New Issue
Block a user