-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Need an option for ignore error when emit declaration #54305
Comments
This seems pretty niche. Declaration emitting in the presence of semantic errors can be wrong in arbitrary and unexpected ways, so it just doesn't seem like a good idea to even be possible to do this. You can always run |
@RyanCavanaugh In this case, I don't think we need complicated ways. Just untouch the type name (unable resolve types) when emitting a declaration file (without any change). function fn(): Coordinate;
function newOrder(): Trade.Order;
|
Just ran into this. Are there situations where the output of the .d.ts is dependent on module/target? My case is that that I'm trying to separate generation of the declaration files from whether or not you're generating esm of commonjs modules |
i.e. should types/typesVersions from https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#including-declarations-in-your-npm-package need to support "import"/"require" type logic from https://nodejs.org/docs/latest/api/packages.html#conditional-exports. If that is not the case, then it seems to make sense to have a mode where things like --downLeverIteration/failures based on the value of target don't stop the creation of declaration files |
This would also be helpful when using disableSourceOfProjectReferenceRedirect in a mono repo for performance reasons. Currently, if I have multiple inter-project errors, They only stop showing in VSCode when the project has no more errors. |
I find it odd that The use case is pretty simple: in any monorepo of any size, you need to build+check in two passes in order to so correctly. The first build necessarily needs to ignore type errors since other packages aren't built because the package manager can only correctly link these together once the assets are all in place. Composite / references / etc do not fix the two pass issue: they are solutions that build overtop of the first build-pass only once it has occurred and only work for monorepo setups that do not properly isolate their packages. Ignoring |
I ran into this when looking to share some types between packages in a monorepo. Adding |
Suggestion
π noEmitOnErrorDeclaration, noEmitOnError for declaration
noEmitOnError do not ignore error when generating declaration files (d.ts)
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
I wonder if this should be a bug or a suggestion.
tsconfig.json
has an optionnoEmitOnError
, when set tofalse
compiler generates javascript files and sourcemaps even if some types are missing.tsconfig.json
also has adeclaration
option for generating d.ts files, when set totrue
we get errors while generating output files even whennoEmitOnError
equalsfalse
.π Motivating Example
Let's look at the simplest example. A website project that contains only 2 files
file.ts
andtsconfig.json
The
Coordinate
is missing type. We can't generate output files.If we turn off (declaration = false), we can generate output files.
π» Use Cases
We already have an option to emitOnError for JavaScript files, we should have emitOnError for declaration.
Why did I code and build typescript missing types?
π‘ What workarounds am I using in the meantime?
program.emit()
. With that trick I can get output in a quick way.That works fine but it requires more work.
The text was updated successfully, but these errors were encountered: