Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally resolved external types #7056

Closed
saschanaz opened this issue Feb 12, 2016 · 5 comments
Closed

Optionally resolved external types #7056

saschanaz opened this issue Feb 12, 2016 · 5 comments
Labels
Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript

Comments

@saschanaz
Copy link
Contributor

let stream: MSStream;
const inputStream = stream.msDetachStream(); // any in lib.d.ts

// const inputStream = stream.msDetachStream() as Windows.Storage.Streams.IInputStream; from winrt.d.ts

Can we have a potential-any type information that resolves only when we have correct d.ts file? Some small type definitions in DefinitelyTyped refers much bigger ones e.g. node.d.ts that is not always required. (Imagine a library that supports standard types and Node.js types together.) I hope I can just include a small file without node.d.ts or any other unneeded large files.

Maybe somewhat related to old #1402.

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. labels Feb 12, 2016
@RyanCavanaugh
Copy link
Member

If people are using just a very small portion of another library, would they be better served by using structural typing to stub out the useful portion of the consumed type? Just thinking out loud.

@saschanaz
Copy link
Contributor Author

@RyanCavanaugh I'm not sure I understand. Can you give me an example?

@RyanCavanaugh
Copy link
Member

Like instead of

function fn(): SomeOtherLibrary.Point;

you could write

function fn(): { x: number; y: number; }

Assuming that the type is small enough to do this reasonably, of course.

@saschanaz
Copy link
Contributor Author

That will be great, but the type of IInputStream in my example has a reference to Buffer, Buffer has one to MemoryBuffer, MemoryBuffer has one to IMemoryBufferReference, etc... Maybe one will not need all of them but maybe others will.

@RyanCavanaugh
Copy link
Member

Tracking at #31894 now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants