Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Support for optional prefix #11

Closed
urish opened this issue Feb 7, 2018 · 0 comments
Closed

Support for optional prefix #11

urish opened this issue Feb 7, 2018 · 0 comments

Comments

@urish
Copy link
Collaborator

urish commented Feb 7, 2018

Allow specifying a prefix that will be added in front of every type automatically discovered. For example, if the given prefix is /*auto*/, and the input source file is as follows:

function f(n) { return n + 1; }; 
f(5);

the result would be:

function f(n: /*auto*/number) { return n + 1; }; 
f(5);

This can also be useful for toggling errors about the discovered types all at once. First, define a new type with a distinct name that maps to void. Then use this type name, followed by the pipe character (|) as a prefix. for instance, if you chose the name the type AutoDiscovered, then you declaration would look like:

type AutoDiscovered = void;

and you will use the value AutoDiscovered| for your prefix. Then, you will be able to silence all TypeScript errors introduced by the discovered types by simply changing the declaration above to read:

type AutoDiscovered = any;

Then you can toggle these errors on/off by simply switching the declaration of the type between any and void. Thanks @benland for this idea.

@urish urish closed this as completed in a75c533 Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant