Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Also check non-test files in isolation #286

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jablko
Copy link
Contributor

@jablko jablko commented Apr 26, 2020

Somewhat related to microsoft/types-publisher#708, the inclusion of test files in tsconfig.json means that dtslint might miss a library that errors on import, if a test file contains a /// <reference types="..." /> that the library errors without.

DefinitelyTyped/DefinitelyTyped#44178 corrects some examples of this.

The test files aren't normally part of users' builds, when users consume the declarations (the test files aren't even distributed in DefinitelyTyped @types packages). This change is an attempt to confirm that, as well as the tests passing, the declarations are importable by themselves.

The fileNames.filter(fileName => fileName.endsWith(".d.ts") logic, to exclude the test files from the source files, comes from https://github.com/microsoft/types-publisher/blob/dd69e3b816be1600d7bec25919c4fe07826573c8/src/lib/module-info.ts#L165-L169

I confirmed that this change does catch at least each of the cases addressed in DefinitelyTyped/DefinitelyTyped#44178, e.g.

$ node ../dtslint/bin/index.js types jsforce
Error: api/chatter.d.ts(3,24): error TS2307: Cannot find module 'stream' or its 
corresponding type declarations.                                                
api/metadata.d.ts(3,24): error TS2307: Cannot find module 'stream' or its corres
ponding type declarations.                                                      
api/metadata.d.ts(4,24): error TS2307: Cannot find module 'buffer' or its corres
ponding type declarations.                                                      
batch.d.ts(1,34): error TS2307: Cannot find module 'stream' or its corresponding
 type declarations.                                                             
bulk.d.ts(1,24): error TS2307: Cannot find module 'stream' or its corresponding 
type declarations.                                                              
query.d.ts(2,26): error TS2307: Cannot find module 'stream' or its corresponding
 type declarations.                                                             
record.d.ts(1,24): error TS2307: Cannot find module 'stream' or its correspondin
g type declarations.                                                            
salesforce-object.d.ts(1,25): error TS2307: Cannot find module 'stream' or its c
orresponding type declarations.                                                 

@sandersn
Copy link
Member

One question about the PRs that need to be fixed before this ships: you ended up closing most of them. Why?

@jablko
Copy link
Contributor Author

jablko commented May 20, 2020

One question about the PRs that need to be fixed before this ships: you ended up closing most of them. Why?

Sorry, those were a mistake. I think all of the PRs that need to be merged before this one now have been.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants