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

"Format Code" causes tslint failure with type assertions #10296

Closed
egamma opened this issue Aug 8, 2016 · 18 comments
Closed

"Format Code" causes tslint failure with type assertions #10296

egamma opened this issue Aug 8, 2016 · 18 comments
Assignees
Labels
formatting Source formatter issues typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code) verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@egamma
Copy link
Member

egamma commented Aug 8, 2016

From @LOZORD on August 5, 2016 3:14

If I have code like this:

const bar = <Bar> Thing.getFoo();

and then "Format Code" (alt-shift-F on Mac), I get this:

const bar = <Bar>Thing.getFoo();

The missing space after the closing angled bracket causes a spacing failure with tslint. I removed the settings in my .vscode/settings.json that have to do with JS/TS spacing, and the error still occurred. Is there something else I can configure to solve this?

Copied from original issue: Microsoft/vscode-tslint#69

@egamma
Copy link
Member Author

egamma commented Aug 8, 2016

Format Code is provided by vscode. Moving the issue to vscode.

@egamma egamma added the typescript Typescript support issues label Aug 8, 2016
@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Aug 8, 2016
@dbaeumer
Copy link
Member

dbaeumer commented Aug 8, 2016

@egamma the error @LOZORD complains about comes from tslint. I am not sure what VS Code should do about this expect filing a feature request to TS to support an option to have a space after a cast operator.

@LOZORD
Copy link

LOZORD commented Aug 8, 2016

I guess the easiest fix might just be to not include the check-typecast rule under whitespace in tslint.json 😕

@egamma
Copy link
Member Author

egamma commented Aug 11, 2016

@dbaeumer agreed, this is really a feature request for the TS formatter to support an option to have a space after a cast operator.

@LOZORD
Copy link

LOZORD commented Aug 14, 2016

So how should I/we proceed?

@dbaeumer
Copy link
Member

@LOZORD best is to open a feature request for the formatter here: https://github.com/Microsoft/typescript

@csentis
Copy link

csentis commented Feb 28, 2017

Could someone please let me know how to activate this in vscode? I do not get the expected results when putting this into my settings:

"typescript.format.insertSpaceAfterTypeAssertion": true

@dbaeumer
Copy link
Member

@mjbvz is this support already. Looks like TS merged a PR for this but we don't have a setting for this yet in VS Code.

@mjbvz
Copy link
Collaborator

mjbvz commented Mar 14, 2017

This formatting option doesn't seem to be in the TSServer protocol yet. Adding it is being tracked by microsoft/TypeScript#14661

@mjbvz mjbvz added the upstream Issue identified as 'upstream' component related (exists outside of VS Code) label Mar 23, 2017
@lucap86
Copy link

lucap86 commented Mar 23, 2017

@csentis
a quickFix as we wait for this feature is added

clone typescript repo in ad folder (i will call it FOLDER)
link -> https://github.com/Microsoft/TypeScript/archive/master.zip
than add

insertSpaceAfterTypeAssertion: true,

in FOLDER/lib/tsserver.js at line 68794
than in vscode settings

"typescript.format.insertSpaceAfterTypeAssertion": true,
"typescript.tsdk": "PATH_TO_FOLDER/lib/",

restart vscode

Note: recall to restore typescript.tsdk rule when tsserver will be updated

@mjbvz
Copy link
Collaborator

mjbvz commented Jun 7, 2017

This should be in TS 2.4: microsoft/TypeScript#14661

Added to the June plan

@csentis
Copy link

csentis commented Jun 28, 2017

@mjbvz if I read the June Iteration Plan properly, this has been deferred. Can you correct me?

@mjbvz mjbvz closed this as completed in 19decf7 Jun 28, 2017
@mjbvz
Copy link
Collaborator

mjbvz commented Jun 28, 2017

@csentis Thanks for the reminder. This should be in for June with TS 2.4

@mjbvz mjbvz added the verification-needed Verification of issue is requested label Jun 28, 2017
@csentis
Copy link

csentis commented Jun 28, 2017

@mjbvz Thank YOU

@roblourens
Copy link
Member

roblourens commented Jun 28, 2017

@mjbvz with TS 2.4.1, "typescript.format.insertSpaceAfterTypeAssertion": true is an "unknown config setting" and it still removes the space when formatting. Am I doing something wrong?

@mjbvz
Copy link
Collaborator

mjbvz commented Jun 28, 2017

@roblourens The change went in pretty recently and isn't in the current insiders build. Can you try a build from master? The next insiders should also have this change

@roblourens
Copy link
Member

Oops, didn't notice the timestamp

@chrmarti
Copy link
Contributor

Verified the setting exists and works as expected.

@chrmarti chrmarti added the verified Verification succeeded label Jun 30, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
formatting Source formatter issues typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code) verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

8 participants