Description
TypeScript Version: 3.6.0-dev.20190810
Search Terms:
- semicolon
- format
- auto import
Repo
For a very simple project:
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es2016",
"jsx": "preserve"
},
"exclude": [
"node_modules",
]
}
constants.ts
export const a = 1
export const b = 1
export const c = 1
export const d = 1
export const e = 1
export const f = 1
main.ts
console.log(a)
- Trigger auto import quick fix in
main.ts
ona
Expected behavior:
Since constants.js
does not use semicolons, the import should not have a semi colon
Actual behavior:
The added import has a semi colon
I believe this is because the current semicolon detection logic (#31801) requires some number of examples in the current file to learn from. For new files, this means we always default to using semicolons even if the rest of the project is semicolonless
I can understand why we do this, but as a user I found it frustrating that TS would still insert semicolons until I added a certain number of imports (or other statements that are also used by the detection code). I don't know if looking at the rest of your project code is feasible or not for semicolon detection but we should discuss if we can improve the experience for new files
/cc @andrewbranch
Related Issues: