Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types not considered? #8

Open
fwilhe2 opened this issue Oct 8, 2022 · 2 comments
Open

types not considered? #8

fwilhe2 opened this issue Oct 8, 2022 · 2 comments

Comments

@fwilhe2
Copy link

fwilhe2 commented Oct 8, 2022

Hi @LinusU

very cool project, I'm considering using it on my library kalkulationsbogen.

When trying it out I noticed a few things that don't seem to work for my use-case as of now.

Given this type definitions file

export declare type spreadsheetInput = row[];
export declare type row = cell[];
export declare type cell = complexCell | formulaCell | string;
export declare type complexCell = cellWithValue & cellWithRange;
export declare type formulaCell = cellWithFunction & cellWithRange;
declare type cellWithValue = {
    value: string;
    valueType?: valueType;
};
declare type cellWithFunction = {
    functionName: string;
    arguments: string[] | string;
};
declare type cellWithRange = {
    range?: string;
};
export declare type valueType = "string" | "float" | "date" | "time" | "currency" | "percentage";
export declare type spreadsheetOutput = string;
/**
 * Build a spreadsheet from data
 * @param spreadsheet list of lists of cells
 * @returns string Flat OpenDocument Spreadsheet document
 */
export declare function buildSpreadsheet(spreadsheet: spreadsheetInput): Promise<string>;
declare type addressAbsolute = "none" | "column" | "row" | "columnAndRow";
/**
 * Return "A1" style cell address given one-indexed column and row number
 * @param column one-indexed column number
 * @param row one-indexed row number
 * @param absolute specify if column, row, both or none are prefixed with '$' to indicate they are absolute
 * @returns String like 'A1' or 'C7'
 */
export declare function A1(column: number, row: number, absolute?: addressAbsolute): string;
export declare function columnIndex(i: number): string;
export {};

I get this api description

### `buildSpreadsheet(spreadsheet)`

- `spreadsheet` (`spreadsheetInput`, required) - list of lists of cells
- returns `Promise<string>` - string Flat OpenDocument Spreadsheet document

Build a spreadsheet from data

### `A1(column, row[, absolute])`

- `column` (`number`, required) - one-indexed column number
- `row` (`number`, required) - one-indexed row number
- `absolute` (`addressAbsolute`, optional) - specify if column, row, both or none are prefixed with '$' to indicate they are absolute
- returns `string` - String like 'A1' or 'C7'

Return "A1" style cell address given one-indexed column and row number

### `columnIndex(i)`

- `i` (`number`, required)
- returns `string`

Question: Are the types omitted on purpose or is this not yet implemented?

Also I'd appreciate if the name/path of the readme.md file and index.d.ts could be configured on the command line so they don't need to be in the root dir.

I might be able to contribute parts of those features if that's ok and I find the time to do that.

Best,
Florian

@LinusU
Copy link
Owner

LinusU commented Nov 10, 2022

Hey @fwilhe2 👋

Sorry for not answering earlier, I kept pushing it "just a day or two" so that I could actually go thru your code, but sadly I haven't had the time yet. It's definitively something I want to support, do you have an example on how you would like the output to look?

I'm also doing some work which I think is overlapping in order to support the uuid package here: uuidjs/uuid#654

@fwilhe2
Copy link
Author

fwilhe2 commented Nov 10, 2022

Hi @LinusU

without a lot of design I'd imagine something similar to this for my example dts file:

## Types

- `spreadsheetInput = row[]`
- `row = cell[]`
- `cell = complexCell | formulaCell | string`
- `complexCell = cellWithValue & cellWithRange`
- `formulaCell = cellWithFunction & cellWithRange`
- `valueType = "string" | "float" | "date" | "time" | "currency" | "percentage"`
- `spreadsheetOutput = string`

## Functions

### `buildSpreadsheet(spreadsheet)`

- `spreadsheet` (`spreadsheetInput`, required) - list of lists of cells
- returns `Promise<string>` - string Flat OpenDocument Spreadsheet document

Build a spreadsheet from data

### `A1(column, row[, absolute])`

- `column` (`number`, required) - one-indexed column number
- `row` (`number`, required) - one-indexed row number
- `absolute` (`addressAbsolute`, optional) - specify if column, row, both or none are prefixed with '$' to indicate they are absolute
- returns `string` - String like 'A1' or 'C7'

Return "A1" style cell address given one-indexed column and row number

### `columnIndex(i)`

- `i` (`number`, required)
- returns `string`

where I was coming from is that I noticed my functions use exported types from my library which were not included in the api docs. As a user of a library, I'd expect custom types to be defined/explained. It would also be nice if ts doc comments would be added to the type definitions.

Does that make sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants