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

Suggestion: #error directive #3575

Closed
zpdDG4gta8XKpMCd opened this issue Jun 19, 2015 · 9 comments
Closed

Suggestion: #error directive #3575

zpdDG4gta8XKpMCd opened this issue Jun 19, 2015 · 9 comments
Labels
Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript

Comments

@zpdDG4gta8XKpMCd
Copy link

C# and C++ have a handy #error directive that results to a compiler error. It would not hurt to have something similar in TypeScript:

@mhegazy
Copy link
Contributor

mhegazy commented Jun 19, 2015

Can you share a scenario where this is useful in the absence of conditional compilation using preprocessor directives (i.e. #ifdef)

@zpdDG4gta8XKpMCd
Copy link
Author

Any block of code that is left unfinished during refactoring and requiring
my attention. An alternative would be to leave it unfinished without a
trace attracting attention and thus prone to being forgotten.
On Jun 19, 2015 5:33 PM, "Mohamed Hegazy" [email protected] wrote:

Can you share a scenario where this is useful in the absence of
conditional compilation using preprocessor directives (i.e. #ifdef)


Reply to this email directly or view it on GitHub
#3575 (comment)
.

@zpdDG4gta8XKpMCd
Copy link
Author

A error raised should not be an early one like those of syntax, should be raised while doing senatic checking.

@danquirk
Copy link
Member

Is // TODO (and an editor supporting task lists) and "throw new Error('not yet implemented')" that much worse? You lose a little compile time checking but little else. You could also use a linter to catch this kind of thing at compile time with some custom tag (// #error).

@zpdDG4gta8XKpMCd
Copy link
Author

True. Anything can be done with extra syntax served in comments and a
little patience. With a bit more patience a pen and a piece of paper one
can get a hard copy of their todo list. Low tech shoots and scores.
On Jun 19, 2015 7:26 PM, "Dan Quirk" [email protected] wrote:

Is // TODO (and an editor supporting task lists) and "throw new Error('not
yet implemented')" that much worse? You lose a little compile time checking
but little else. You could also use a linter to catch this kind of thing at
compile time with some custom tag (// #error).


Reply to this email directly or view it on GitHub
#3575 (comment)
.

@zpdDG4gta8XKpMCd
Copy link
Author

Btw are there any plans to marry TypeScript with the Task list in Visual
Studio, so that // TODO's are seen there?
On Jun 19, 2015 8:14 PM, "Aleksey Bykov" [email protected] wrote:

True. Anything can be done with extra syntax served in comments and a
little patience. With a bit more patience a pen and a piece of paper one
can get a hard copy of their todo list. Low tech shoots and scores.
On Jun 19, 2015 7:26 PM, "Dan Quirk" [email protected] wrote:

Is // TODO (and an editor supporting task lists) and "throw new
Error('not yet implemented')" that much worse? You lose a little compile
time checking but little else. You could also use a linter to catch this
kind of thing at compile time with some custom tag (// #error).


Reply to this email directly or view it on GitHub
#3575 (comment)
.

@danquirk
Copy link
Member

Yep, VS2015 already has the Task List wired up like that.

@mhegazy
Copy link
Contributor

mhegazy commented Jun 20, 2015

Any block of code that is left unfinished during refactoring and requiring
my attention.

you can just use unknownFunction("not done"), or var n: number = "still needs some work"; to achieve the same result.

@mhegazy mhegazy added Suggestion An idea for TypeScript Declined The issue was declined as something which matches the TypeScript vision labels Jun 20, 2015
@mhegazy mhegazy closed this as completed Jun 20, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Jun 20, 2015

possibly reconsider if an applicable form of conditional compilation (#3538) is supported.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants