Skip to content

Start of a recommended base - #15

Closed
orta wants to merge 3 commits into
masterfrom
recommended
Closed

orta wants to merge 3 commits into
masterfrom
recommended

Conversation

@orta

@orta orta commented May 29, 2020

Copy link
Copy Markdown
Member

Opening this PR ahead a the TS design meeting for feedback

Comment thread bases/recommended.json Resolved

@robpalme robpalme left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestions on nice defaults to propagate here:

  • declaration: true has the (possibly undocumented?) side-effect of catching more errors (increased strictness is good)
  • noEmitOnError: true helps prevent accidents (speaking from embarrassing bitter experience)
  • target: "esnext" & module: "esnext" will help steer codebases towards less transpilation (good for everyone)
  • useDefineForClassFields: true ensures checking & emit compatibility with engines

Comment thread bases/recommended.json Resolved
@styfle

styfle commented Jul 1, 2020

Copy link
Copy Markdown
Contributor

@robpalme Agreed! I think noEmitOnError: true is crucial for anyone starting a new TS project.

However, useDefineForClassFields: true doesn't seem to do anything when target: esnext.

It only seems relevant when target: es2020 or older, right?

@robpalme

robpalme commented Jul 1, 2020

Copy link
Copy Markdown
Contributor

@styfle not quite.

useDefineForClassFields: true is still needed even with target: esnext. You can use the TypeScript playground to see the impact.

@orta

orta commented Jul 3, 2020

Copy link
Copy Markdown
Member Author

There's also microsoft/TypeScript#39354

@orta

orta commented Jul 3, 2020

Copy link
Copy Markdown
Member Author

We keep punting on this in design meetings, I'll get it seen soon enough

I agree with all of the feedback, updated the PR.

I'm not 100% enough on the target/module recommendation to put that in yet, will bring it up - I think I prefer it though, better to start at the top and let people choose to go back to earlier then the other way around.

Comment thread bases/recommended.json
"allowSyntheticDefaultImports": true,

/** Improves `tsc` launch speed in favour of some accuracy in your @types **/
"skipLibCheck": true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs for skipLibCheck seem to be different than what your comment says here.

The docs say that this property will "Skip type checking of all declaration files (*.d.ts)."

https://www.typescriptlang.org/docs/handbook/compiler-options.html

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I can confirm this option turns off type checking of hand-written DTS files in your project, unfortunately. As a result I find it difficult to recommend.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's a good point - I was thinking of types at the same time. We opted to recommend it for speed and that most dts files come from @types where we have tonnes of testing infra (and that most folks won't go fix these things upstream) - we'd probably fix the issues, others would get stuck

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like the common case - where the declarations files are for dependencies as opposed to defining types for files inside your project.

I know this isn't the right place to suggest it, but maybe the implementation of skipLibCheck could be updated to make this distinction.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a bad call IMO

@orta

orta commented Jul 10, 2020 •

Copy link
Copy Markdown
Member Author

Managed to get this into a design review (we only do one a week, but given everyone is remote they're really filled, so might be switching to two a week) - general gist for this is that we think --init is basically the recommendation and any improvements I want there should happen there.

What that means for this PR is that I'm going to replace this with a @tsconfig/init which will always be permanently up to date (by extracting it from typescript in a nightly job and seeing if it's changed )

Then people know there is only 1 recommended by TS tsconfig. This probably means dropping some of the existing flags which I think are recommended.

I also wonder if something like tsconfig/node12 should be extending from @tsconfig/init and might need to build that infra too.

@orta

orta commented Aug 6, 2020

Copy link
Copy Markdown
Member Author

Alright, I've got this in with #25

It's bit kludgy with me manually editing all the other json files but otherwise I'll need to create the JSON files by string concatenation and I've already punted on this since May

@orta orta closed this Aug 6, 2020
@jakebailey
jakebailey deleted the recommended branch September 24, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants