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

Inherit core-tracing tsconfig.json from root #5320

Merged
merged 11 commits into from
Nov 20, 2019
Merged

Conversation

xirzec
Copy link
Member

@xirzec xirzec commented Sep 30, 2019

Per #5276 , let's start migrating to common tsconfig.json settings rather than having a different set of checks enabled for each package.

@xirzec xirzec added the Client This issue points to a problem in the data-plane of the library. label Sep 30, 2019
@xirzec xirzec requested review from a user, ramya-rao-a and chradek September 30, 2019 22:51
@xirzec xirzec self-assigned this Sep 30, 2019
@xirzec xirzec requested a review from bterlson as a code owner November 12, 2019 20:40
@xirzec xirzec requested a review from willmtemple November 18, 2019 23:01
Copy link
Contributor

@willmtemple willmtemple left a comment

Choose a reason for hiding this comment

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

nice!

one nitpick: comments in JSON cause a lot of editors to turn extremely red because they aren't part of the true JSON spec. Is it possible for us to either configure the repo with workspace settings that will ignore that, or alternatively just remove the comments from the JSON? Since tsconfig/rush/etc. are all schematized we should have good enough IntelliSense to not need every option documented inline when we come back to change these files.

tsconfig.json Outdated
"target": "ES2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"target": "ES2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": ["es2017"], /* Specify library files to be included in the compilation. */
Copy link
Contributor

Choose a reason for hiding this comment

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

I think our guidelines say not to include anything in lib because it will require downstream users to also include it. The eslint plugin at least checks that it is present and set to []

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm let me try it!

@@ -0,0 +1,4 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to have both this and tsconfig.json next to each other? What's the behavior of just folding tsconfig.json and this together? Do we even need a tsconfig.json in the repo root or could we stash the base config away in /common?

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that we have CI checks that do npm install on the root (I think for the management libs) and they use gulp... which breaks if we don't use commonjs as the target because ts-gulp doesn't support this right. It always needs a tsconfig.json in the root.

Maybe this is something we can take up with eng sys at some point.

@xirzec
Copy link
Member Author

xirzec commented Nov 18, 2019

one nitpick: comments in JSON cause a lot of editors to turn extremely red because they aren't part of the true JSON spec. Is it possible for us to either configure the repo with workspace settings that will ignore that, or alternatively just remove the comments from the JSON? Since tsconfig/rush/etc. are all schematized we should have good enough IntelliSense to not need every option documented inline when we come back to change these files.

Yeah I don't like JSON+Comments either. I believe @bterlson said he was fine with removing them.

@xirzec
Copy link
Member Author

xirzec commented Nov 19, 2019

@willmtemple can you take another look? Thanks 👍

@bterlson
Copy link
Member

Yep feel free to remove any and all syntactic extensions to JSON. It's just and proper to do so.

@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

/// <reference lib="dom"/>
Copy link
Member

Choose a reason for hiding this comment

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

Avoid this if at all possible. /// reference directives have the effect of opting our users in to that complete set of types as if they had specified the lib entry themselves. Sometimes, this is what you want. For us, more often we just want TypeScript not to complain, and don't want to augment our users' types any more than necessary for correctness reasons.

Better to declare stub interfaces up front until we get placeholder types. Could do something like this in a d.ts file:

interface Window {};
declare var self: Window & typeof globalThis;

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you update the guidance?

https://azure.github.io/azure-sdk/typescript_design.html#ts-config-lib

DO NOT use the compilerOptions.lib field. Built in typescript libraries (for example, esnext.asynciterable) should be included via reference directives.

The above also links to the following PR which introduced a /// reference:

https://github.com/Azure/azure-cosmos-js/pull/161/files

Copy link
Member Author

Choose a reason for hiding this comment

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

Lib reference removed in latest commit, @bterlson please take another look

@xirzec xirzec requested a review from bterlson November 20, 2019 01:31
@xirzec xirzec merged commit d196438 into Azure:master Nov 20, 2019
@xirzec xirzec deleted the tracingConfig branch November 20, 2019 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants