Closed mf-karim closed 10 months ago
Do you have a repo? Is it the only log message the tool generates?
It's for a work related repo. But I can give you a gist. Basically I have a Type definition using sinclair and I am using that type definition in the index.ts. So when I try to generate the prebuilt files using dts-bundle-generator it regenerates the type in the output file (index.d.ts) as a const and I see the output error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.
Basically this error message and Error: Command failed
A minimal repro would be appreciated. Without it it would be hard to investigate the failure.
it regenerates the type in the output file (index.d.ts) as a const
Is it possible to share the line to code that it fails at? You can provide a --no-check
flag to write output to the disk so you can analyse it later.
Basically this error message and Error: Command failed
Can you provide the full output? I understand that you don't want to share any private data (and I really don't need it), but I doubt the output contains anything private, and even if it does you can redact just that data without "rephrasing what you see".
The reasons why I'm asking the full log are:
Basically my script runs this
execSync(
`yarn dts-bundle-generator ${src} --out-file ${replaceFileExtension(
out,
'.d.ts',
)} --silent --no-banner`,
{
stdio: 'inherit',
},
)
$ node_modules/.bin/dts-bundle-generator src/index.ts --out-file prebuilt/index.d.ts --silent --no-banner
prebuilt/index.d.ts(3,30): error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.
prebuilt/index.d.ts(12,30): error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.
Error: Compiled with errors
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
node:internal/errors:865
const err = new Error(message);
^
Error: Command failed: yarn dts-bundle-generator src/index.ts --out-file prebuilt/index.d.ts --silent --no-banner
at __node_internal_genericNodeError (node:internal/errors:865:15)
at checkExecSyncError (node:child_process:885:11)
at execSync (node:child_process:957:15)
at emitDeclarations (scripts/build.ts:16:3)
at <anonymous> (scripts/build.ts:33:11)
at node_modules/esbuild/lib/main.js:1453:19
at runOnEndCallbacks (node_modules/esbuild/lib/main.js:1458:9)
at buildResponseToResult (node_modules/esbuild/lib/main.js:1031:7)
at node_modules/esbuild/lib/main.js:1143:14
at responseCallbacks.<computed> (node_modules/esbuild/lib/main.js:680:9) {
status: 1,
signal: null,
output: [ null, null, null ],
pid: 53908,
stdout: null,
stderr: null
}
Do you have any updates on the minimal repro?
@mf-karim can you provide index.ts
content? I just tried to use build a bundle with @sinclair/typebox
library and I didn't see any issues. It looks like it is related to your code rather than a library you mentioned.
I'm going to close the issue. If you'll have any question or updates - feel free to ping me.
I am trying to use dts-bundle-generator to create prebuilt files for my tool, namely index.js and index.d.ts. The main index.ts contains references to Type definitions which are defined using @sinclair/typebox. The index.js output file gets created successfully but the index.d.ts gives the following error
error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.