A
A
Alexey Nikolaev2019-10-23 09:39:19
typescript
Alexey Nikolaev, 2019-10-23 09:39:19

Why doesn't Typescript linter see types in global.d.ts?

Good morning.
There is global.d.ts, where a couple of types are declared.

declare type KeyObject = { ... };
declare type AddressedKeyObject = { ... };

The goal is to use these types in other declaration files. It is logical to assume that since global.d.ts declares everything in the global scope, as it follows from the documentation, these types will be available everywhere. However, the tsc utility does not see them during operation, and fails with the message "Cannot find name KeyObject". An example of a declaration file that fails:
declare module "@vendor/something" {
    export function getKeyObject(): KeyObject;
}

How to fix? What have I done wrong?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Robur, 2019-10-23
@Heian

tsc is not a linter, but the globals.d.ts compiler
must be connected to the project in one way or another. in tsconfig.json or ///
did you do that?
for ease of verification, add /// to some file with an error

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question