Skip to content

Apply the safe list to projects which didn't specify an upfront include#20048

Merged
RyanCavanaugh merged 1 commit into
microsoft:masterfrom
RyanCavanaugh:fixSafeList
Nov 16, 2017
Merged

Apply the safe list to projects which didn't specify an upfront include#20048
RyanCavanaugh merged 1 commit into
microsoft:masterfrom
RyanCavanaugh:fixSafeList

Conversation

@RyanCavanaugh

Copy link
Copy Markdown
Member

Comment thread src/server/project.ts
return counts.ts === 0 && counts.tsx === 0;
}

/* @internal */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Really this function should be called hasNoTypeScriptSource.

Comment thread src/server/project.ts
Debug.assert(!!newTypeAcquisition, "newTypeAcquisition may not be null/undefined");
Debug.assert(!!newTypeAcquisition.include, "newTypeAcquisition.include may not be null/undefined");
Debug.assert(!!newTypeAcquisition.exclude, "newTypeAcquisition.exclude may not be null/undefined");
Debug.assert(typeof newTypeAcquisition.enable === "boolean", "newTypeAcquisition.enable may not be null/undefined");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If only we had a type system that could check these kind of things... 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you check this holds if the tsconfig.json just has "typeAcquistion": {"enable": true} (i..e include & exclude are still set to defaults).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isn't this code specific to external projects? It looks like configured projects have their own setTypeAcquisition.

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.

Right, this is in ExternalProject so there can't (?) be a tsconfig.json

@billti billti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've yet to validate it empirically, but theoretically it looks good 👍

this.sendResponse(this.createSetTypings(req, discoverTypingsResult.cachedTypingPaths));
// respond with whatever cached typings we have now if there are no other types left to install
if (discoverTypingsResult.newTypingNames.length === 0) {
this.sendResponse(this.createSetTypings(req, discoverTypingsResult.cachedTypingPaths));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this.sendResponse(this.createSetTypings(req, discoverTypingsResult.cachedTypingPaths)); [](start = 16, length = 87)

Maybe move this into the else at the end of this method?

Comment thread src/server/editorServices.ts Outdated
for (const t of types) {
proj.typeAcquisition.include.push(t);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Whitespace

@amcasey

amcasey commented Nov 16, 2017

Copy link
Copy Markdown
Member
                Debug.assert(!!typeAcquisition, "typeAcquisition should be non-null");

If it can be null, do you have to check that before accessing .enable?


Refers to: src/server/editorServices.ts:2271 in 744511c. [](commit_id = 744511c, deletion_comment = True)

for (const type of rule.types) {
if (types.indexOf(type) < 0) {
types.push(type);
if (typeAcqInclude.indexOf(type) < 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if (typeAcqInclude.indexOf(type) < 0) { [](start = 32, length = 39)

We don't otherwise dedup the include or exclude lists, do we?

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 if they're user-specified

@billti

billti commented Nov 16, 2017

Copy link
Copy Markdown
Member

👍 . Please port to release-2.6 also.

@RyanCavanaugh

Copy link
Copy Markdown
Member Author

Test fix incoming

…te project contexts when installer reqs finish
@RyanCavanaugh RyanCavanaugh merged commit 1ea1ad4 into microsoft:master Nov 16, 2017
RyanCavanaugh added a commit to RyanCavanaugh/TypeScript that referenced this pull request Nov 16, 2017
RyanCavanaugh added a commit to RyanCavanaugh/TypeScript that referenced this pull request Nov 17, 2017
@RyanCavanaugh RyanCavanaugh mentioned this pull request Nov 17, 2017
RyanCavanaugh added a commit that referenced this pull request Nov 17, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants