Skip to content

Type Declaration Files Not Found When Out of Sub-Project Directory #15650

@sam-s4s

Description

@sam-s4s

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ X ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Not that I know of

Description

When specifying a custom d.ts file anywhere other than within a project sub-directory, the declaration isn't found.

🔬 Minimal Reproduction

ng new
npm install uuid
create file "./typings/uuid.d.ts" (in the workspace root)

declare module "uuid" {
    export function v4(): string;
    export default v4;
}

then in a sub project inside the workspace...
app.component.ts -> import { v4 } from 'uuid';

🔥 Exception or Error




error TS2688: Cannot find type definition file for 'uuid'.
./app.component.ts:2:20 - error TS7016: Could not find a declaration file for module 'uuid'.

🌍 Your Environment




Angular CLI: 8.3.2
Node: 10.15.1
OS: win32 x64
Angular: 8.2.4
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.2
@angular-devkit/build-angular     0.803.2
@angular-devkit/build-optimizer   0.803.2
@angular-devkit/build-webpack     0.803.2
@angular-devkit/core              8.3.2
@angular-devkit/schematics        8.3.2
@angular/cli                      8.3.2
@ngtools/webpack                  8.3.2
@schematics/angular               8.3.2
@schematics/update                0.803.2
rxjs                              6.5.2
typescript                        3.5.3
webpack                           4.39.2

Anything else relevant?

Interestingly enough, even though this error shows up in the build process, the runtime code actually works correctly! It's just the compiler that thinks there's an error.

I have 4-5 projects inside my workspace, and I want this type declaration file to be above them all, so it can be shared between them. How is this intended to work?

I've tried specifying types and typeRoots in my tsconfig to no avail.

Note that intellisense in VS2017 works fine for my uuid.d.ts file no matter where I put it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions