Skip to content

Ambient declarations (.d.ts) not being discovered anymore #28373

@atrauzzi

Description

@atrauzzi

Suddenly this morning, a particular ambient declaration has started causing errors, preventing anything from working.

This is the project & branch I'm working in: https://github.com/atrauzzi/gerty/tree/hashi-gerty

I think it's a fairly straightforward webpack & ts-node setup. Again, it's been working up until this morning...

$ cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --port 5174 --inline --disable-host-check --config=webpack.debug.ts

/Users/atrauzzi/Development/atrauzzi/gerty/node_modules/ts-node/src/index.ts:261
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
src/Util.ts(2,24): error TS7016: Could not find a declaration file for module 'sudo-prompt'. '/Users/atrauzzi/Development/atrauzzi/gerty/node_modules/sudo-prompt/index.js' implicitly has an 'any' type.
  Try `npm install @types/sudo-prompt` if it exists or add a new declaration (.d.ts) file containing `declare module 'sudo-prompt';`

    at createTSError (/Users/atrauzzi/Development/atrauzzi/gerty/node_modules/ts-node/src/index.ts:261:12)
    at getOutput (/Users/atrauzzi/Development/atrauzzi/gerty/node_modules/ts-node/src/index.ts:367:40)
    at Object.compile (/Users/atrauzzi/Development/atrauzzi/gerty/node_modules/ts-node/src/index.ts:558:11)
    at Module.m._compile (/Users/atrauzzi/Development/atrauzzi/gerty/node_modules/ts-node/src/index.ts:439:43)
    at Module._extensions..js (internal/modules/cjs/loader.js:718:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/Users/atrauzzi/Development/atrauzzi/gerty/node_modules/ts-node/src/index.ts:442:12)
    at Module.load (internal/modules/cjs/loader.js:605:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
    at Function.Module._load (internal/modules/cjs/loader.js:536:3)
    at Module.require (internal/modules/cjs/loader.js:643:17)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I know that's a common error message, but I had already done what's necessary to mitigate it. Here is my ambient.d.ts at the root of the project:

declare module "*.jpg" {
    const path: string;
    export default path;
}

declare module "hostile" {
    const hostile: any;
    export default hostile;
}

declare module "sudo-prompt" {

	export function exec(cmd: string, options: { name?: string, icns?: string }, callback: (error: string, stdout: string, stderr: string) => void): any;
}

declare module "webpack-shell-plugin";

declare module "ps-tree";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions