-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Cannot find type definition file for ambient declaration module #34749
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
Comments
I'm repro'ing this too. I was updating from 3.3 to 3.6 and hit this issue. Now I'm falling back to 3.5 which doesn't repro this issue |
IIRC |
Our source tree is not with a
And the base config referenced in the previous config is this:
|
Scrap a little bit of that. The failure is happening in the project I mentioned above, but the incorrect definition file is being created in a project it depends on. The project where the incorrect dependency is being generated has this configuration:
The base config file is the same as what i pasted in my previous comment. |
It's the |
In short: The |
@jdom would you be able to move your |
Yes, I use baseUrl and if I don't, the triple slash reference is left alone. Here's my tsconfig.json.
Does this mean baseUrl cannot be used when the project uses triple slash reference paths? |
I'm a little hesitant to do this change, as we have tons of legacy external tooling that works with the current structure, and we also generate different definitions and bundles for different SDKs. If there is a way to get the previous behavior (ie: since my source code is explicitly using a relative reference, keep it relative in the emitter), then I'd certainly prefer that. Do you think it can be achieved with the current release? |
We just ran into something similar to this; I'm unclear on whether it's exactly the same issue or just related on the surface. We have a handful of internal packages that declare types for public ones that don't have their own declarations (essentially like a miniature internal DT). Consumers of these typings include an import '@our-org/types~some-package';
import { Something } from 'some-package';
export const foo = {
something: new Something()
}; Up to TS 3.5, when emitting declarations in this scenario, we'd get output like this: export declare const foo: {
something: import('some-package').Something
} As of 3.6, we instead see: /// <reference types="node_modules/@our-org/types~some-package" />
export declare const foo: {
something: import('some-package').Something
} While it definitely seems like a good thing to have that reference included instead of relying on the downstream consumer to have imported the declarations themselves, the path emitted doesn't seem to resolve correctly. I think the leading We do have a Edit: I just realized this behavior is different based on the |
I'm running into this problem too, in a umd common project that's included on the server (which is a commonjs node project) and the client (which is an amd web-browser project). This causes compilation of both the server and the client to fail. |
TypeScript Version: 3.6 to 3.8.0-dev.20191025
Search Terms: ambient module triple slash reference path declaration
Code
Typescript 3.5.3 works as expected, anything at or above 3.6 has the same issue..
When running tsc -d, for a manually created declaration file, the triple slash reference path file should be preserved in the output declaration file. This particular declaration file acts as a shim for an existing library whose type definitions are incomplete and is to be included as-is and without transpiler manipulation in the output declaration file. This provides accurate intellisense for package consumers and ensures build errors do not occur.
Expected behavior:
Maintain the same triple-slash reference path in the .d.ts file as was in the .ts file.
Actual behavior:
The reference path is changed to reference types and the relative path is also broken:
This causes consuming applications of the package to receive the following build error:
Cannot find type definition file for 'typings/somemodule'.
I have been unsuccessful in manipulating the consuming application to build correctly or provide correct intellisense with the updated directive. The original directive must be preserved.
Playground Link:
Related Issues: I believe this is where the issue was introduced: #32878
The text was updated successfully, but these errors were encountered: