-
Notifications
You must be signed in to change notification settings - Fork 149
nodeBuiltins depend on @types/node #765
base: master
Are you sure you want to change the base?
Conversation
It's been a while since I looked at this code. Can you give a larger example of a project whose publish is wrong before this change and would be fixed by it? |
I think @types/standard-engine$ npm install @types/standard-engine
$ > index.ts
$ tsc index.ts
node_modules/@types/standard-engine/index.d.ts:7:22 - error TS2307: Cannot find module 'os'.
7 import { type } from 'os';
~~~~ ❌ $ npm install @types/node
$ tsc index.ts ✔️ @types/undertaker$ npm install @types/undertaker
$ > index.ts
$ tsc index.ts
node_modules/@types/undertaker/index.d.ts:9:24 - error TS2307: Cannot find module 'stream'.
9 import { Duplex } from "stream";
~~~~~~~~
node_modules/@types/undertaker/index.d.ts:10:30 - error TS2307: Cannot find module 'events'.
10 import { EventEmitter } from "events";
~~~~~~~~
node_modules/@types/undertaker/index.d.ts:25:56 - error TS2503: Cannot find namespace 'NodeJS'.
25 (done: (error?: any) => void): void | Duplex | NodeJS.Process | Promise<never> | any;
~~~~~~ ❌ $ npm install @types/node
$ tsc index.ts ✔️ |
On second thought, while a dependency on $ npm install @types/standard-engine
$ > index.ts
$ tsc --types standard-engine index.ts
node_modules/@types/standard-engine/index.d.ts:7:22 - error TS2307: Cannot find module 'os'.
7 import { type } from 'os';
~~~~
The types must also I've updated this change to throw an error where before it just added the missing dependency. Linting all files in a package, not just the tests, would also catch these deficiancies? |
fyi: fixing |
I opened microsoft/dtslint#286, which is an attempt to address this PR in a more general way: Instead of catching libraries that import a |
I've updated this PR again, this time to add dependencies on |
The present state of this is an interesting idea, but it depends on DefinitelyTyped/DefinitelyTyped#44429 to split up Since this PR isn't ready to go yet, and has changed substantially since its creation anyway, can you re-create it at https://github.com/microsoft/DefinitelyTyped-tools? It's the new monorepo that contains all of DT's publishing infrastructure. I'm going to look at your other PRs and merge+port those that are simple enough and ready to go. I'll comment on any others that I'd like you to recreate the PR at DefinitelyTyped-tools. |
Like non-built-in modules, add a dependency (on
@types/node
in this case) given the following (unless there's already a dependency, on@types/node
or on the specified module):Otherwise it errors: