-
Notifications
You must be signed in to change notification settings - Fork 9
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
- I have checked that the SDK documentation doesn't solve my issue.
- I have checked that the API documentation doesn't solve my issue.
- I have searched the Box Developer Forums and my issue isn't already reported (or if it has been reported, I have attached a link to it, for reference).
- I have searched Issues in this repo and my issue isn't already reported.
Description of the Issue
Typescript definition files for an application which uses this library are generated with invalid import references with files ending in .js.js
. Eg:
// some-file.d.ts
...
export declare function someFunction(): {
pathCollection: {
entries: import("box-typescript-sdk-gen/lib/schemas/folderMini.generated.js.js").FolderMini[];
};
};
...
This seems to specifically happen when tsconfig moduleResolution
is set to bundler
. Which is necessary for our use case.
Steps to Reproduce
The files below comprise a very simple example of an app with this issue:
package.json
:
{
"name": "box_typing_issue",
"version": "1.0.0",
"scripts": {
"prebuild": "npm install",
"build": "tsc -p tsconfig.json"
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"box-typescript-sdk-gen": "^1.17.1"
},
"devDependencies": {
"typescript": "^5.4.4"
}
}
tsconfig.json
:
{
"compilerOptions": {
"outDir": "./dist",
"moduleResolution": "bundler",
"importHelpers": true,
"target": "ES2022",
"module": "es2020",
"lib": [
"es2020",
"dom"
],
"strict": true,
"esModuleInterop": true,
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"sourceMap": true,
"skipLibCheck": true,
"types": []
},
"include": [
"src/**/*.ts"
]
}
src/index.ts
:
import { FolderFull } from "box-typescript-sdk-gen/lib/schemas/folderFull.generated";
// Note, same issue if you use (without /lib/):
// import { FolderFull } from "box-typescript-sdk-gen/schemas/folderFull.generated";
export type SnakeToCamel<S extends string> = S extends `${infer T}_${infer U}`
? `${T}${Capitalize<SnakeToCamel<U>>}`
: S;
const PARENT_FIELDS = [
"id",
] as const;
export interface ParentFolder
extends Pick<FolderFull, SnakeToCamel<(typeof PARENT_FIELDS)[number]>> {
id: NonNullable<FolderFull["id"]>;
name: NonNullable<FolderFull["name"]>;
type: NonNullable<FolderFull["type"]>;
pathCollection: NonNullable<FolderFull["pathCollection"]>;
}
export function systemFileToMinimalItem(
file: File,
parentFolder: ParentFolder
) {
return {
name: file.name,
type: "file",
size: file.size,
pathCollection: {
entries: parentFolder.pathCollection.entries.concat(parentFolder),
},
};
}
Run npm run build
and look at dist/index.d.ts
Expected Behavior
Types should be generated correctly with no extension.
Error Message, Including Stack Trace
n/a
Screenshots

Versions Used
Typescript SDK: 5.4.4
Platform: Browser
Node.js (if applicable): n/a
michaelhays and zaru
Metadata
Metadata
Labels
bugSomething isn't workingSomething isn't working