Skip to content

Figure out how to ship a generated .d.ts with dist files #434

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

Closed
dcodeIO opened this issue Jan 24, 2019 · 6 comments
Closed

Figure out how to ship a generated .d.ts with dist files #434

dcodeIO opened this issue Jan 24, 2019 · 6 comments

Comments

@dcodeIO
Copy link
Member

dcodeIO commented Jan 24, 2019

Files in dist are just build artifacts with a source map currently but don't come with pre-generated type definitions, which would eliminate the need to ship the full sources with an eventual npm package. Challenge here is that while tsc is able to generate definitions along a compile step, it splits these up into multiple files so these need to be combined somehow, and possibly wrapped with something commonjs to "just work".

@Jack-Works
Copy link

What about adding a default auto-generated file index.d.ts?

index.d.ts

/// <reference path="node_modules/assemblyscript/std/types/assembly/index.d.ts" />
export * from './assembly/index'

Result as:

image

@deepsweet
Copy link

it seems like --outFile + --declaration will produce a single .d.ts file.

Concatenate and emit output to single file. The order of concatenation is determined by the list of files passed to the compiler on the command line along with triple-slash references and imports.

@dcodeIO
Copy link
Member Author

dcodeIO commented May 27, 2019

Unfortunately this doesn't just work with outDir, which we are using. Generates multiple declaration files that must be merged somehow. Gave dts-generator a try now (see commit above), modifying it slightly to fit our needs and fix an issue with --main emitting an invalid alias. Let me know if something appears off.

@dcodeIO dcodeIO unpinned this issue Jun 6, 2019
@webmaster128
Copy link

Is single file a requirement? If you have an index.ts like this in the source you get an definition index like that using outDir, which pulls in all the other declaration file. The user then only imports the folder and get access to all exports listed in index.ts.

By the way, you can have a separate directory for the declaration output files, from where you can easily move them around as an entire folder.

@dcodeIO
Copy link
Member Author

dcodeIO commented May 27, 2020

Closing this issue as part of 2020 vacuum because it has been solved, at least to the extend possible without pulling in additional dependencies, and seems to work well enough.

@dcodeIO dcodeIO closed this as completed May 27, 2020
@taxilian
Copy link

For others who get here without having found the solution elsewhere:

https://www.assemblyscript.org/compiler.html#command-line-options

Either use the -d <filename.d.ts> option or in asconfig.json add tsdFile: "filename.d.ts" as a sibling to e.g. "binaryFile" and/or "textFile", etc.

Hope that saves someone else some time =] Awesome project, kudos to those involved

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

No branches or pull requests

6 participants