Skip to content

Commit 6e9f1d7

Browse files
committed
Merge branch 'main' into gabritto/hover
2 parents 98772e1 + eef7c14 commit 6e9f1d7

12 files changed

Lines changed: 314 additions & 9 deletions

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646

4747
# Initializes the CodeQL tools for scanning.
4848
- name: Initialize CodeQL
49-
uses: github/codeql-action/init@5f8171a638ada777af81d42b55959a643bb29017 # v3.28.12
49+
uses: github/codeql-action/init@1b549b9259bda1cb5ddde3b41741a82a2d15a841 # v3.28.13
5050
with:
5151
config-file: ./.github/codeql/codeql-configuration.yml
5252
# Override language selection by uncommenting this and choosing your languages
@@ -56,7 +56,7 @@ jobs:
5656
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5757
# If this step fails, then you should remove it and run the build manually (see below).
5858
- name: Autobuild
59-
uses: github/codeql-action/autobuild@5f8171a638ada777af81d42b55959a643bb29017 # v3.28.12
59+
uses: github/codeql-action/autobuild@1b549b9259bda1cb5ddde3b41741a82a2d15a841 # v3.28.13
6060

6161
# ℹ️ Command-line programs to run using the OS shell.
6262
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -70,4 +70,4 @@ jobs:
7070
# make release
7171

7272
- name: Perform CodeQL Analysis
73-
uses: github/codeql-action/analyze@5f8171a638ada777af81d42b55959a643bb29017 # v3.28.12
73+
uses: github/codeql-action/analyze@1b549b9259bda1cb5ddde3b41741a82a2d15a841 # v3.28.13

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ jobs:
5555

5656
# Upload the results to GitHub's code scanning dashboard.
5757
- name: 'Upload to code-scanning'
58-
uses: github/codeql-action/upload-sarif@5f8171a638ada777af81d42b55959a643bb29017 # v3.28.12
58+
uses: github/codeql-action/upload-sarif@1b549b9259bda1cb5ddde3b41741a82a2d15a841 # v3.28.13
5959
with:
6060
sarif_file: results.sarif
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
trigger: none
2+
pr: none
3+
4+
parameters:
5+
- name: _REMINDER
6+
default: Review & undraft the release at https://github.com/microsoft/TypeScript/releases once it appears!
7+
- name: PUBLISH_TAG
8+
default: dev
9+
- name: RELEASE_TITLE_NAME
10+
default: 0.0.0 Test
11+
- name: TAG_NAME
12+
default: v0.0.0-SetMe
13+
14+
variables:
15+
- name: _REMINDER
16+
value: ${{ parameters._REMINDER }}
17+
- name: PUBLISH_TAG
18+
value: ${{ parameters.PUBLISH_TAG }}
19+
- name: RELEASE_TITLE_NAME
20+
value: ${{ parameters.RELEASE_TITLE_NAME }}
21+
- name: TAG_NAME
22+
value: ${{ parameters.TAG_NAME }}
23+
24+
resources:
25+
pipelines:
26+
- pipeline: 'tgz'
27+
project: 'TypeScript'
28+
source: 'Release\TypeScript Release'
29+
repositories:
30+
- repository: 1esPipelines
31+
type: git
32+
name: 1ESPipelineTemplates/1ESPipelineTemplates
33+
ref: refs/tags/release
34+
35+
extends:
36+
template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines
37+
parameters:
38+
pool:
39+
name: TypeScript-AzurePipelines-EO
40+
image: 1ESPT-Mariner2.0
41+
os: linux
42+
43+
sdl:
44+
sourceAnalysisPool:
45+
name: TypeScript-AzurePipelines-EO
46+
image: 1ESPT-Windows2022
47+
os: windows
48+
49+
stages:
50+
- stage: Stage_1
51+
displayName: Publish tarball
52+
jobs:
53+
- job: Job_1
54+
displayName: Agent job
55+
condition: succeeded()
56+
timeoutInMinutes: 0
57+
templateContext:
58+
templateContext:
59+
type: releaseJob
60+
isProduction: true
61+
inputs:
62+
- input: pipelineArtifact
63+
pipeline: 'tgz'
64+
artifactName: 'tgz'
65+
targetPath: '$(Pipeline.Workspace)/tgz'
66+
steps:
67+
- checkout: none
68+
- task: CmdLine@2
69+
displayName: Rename versioned drop to typescript.tgz
70+
inputs:
71+
script: |
72+
pushd $(Pipeline.Workspace)/tgz
73+
ls -lhR
74+
mv typescript-*.tgz typescript.tgz
75+
- task: Npm@1
76+
displayName: npm publish tarball
77+
inputs:
78+
command: custom
79+
workingDir: $(Pipeline.Workspace)/tgz
80+
verbose: false
81+
customCommand: publish $(Pipeline.Workspace)/tgz/typescript.tgz --tag $(PUBLISH_TAG)
82+
# This must match the service connection.
83+
customEndpoint: Typescript NPM
84+
publishEndpoint: Typescript NPM
85+
86+
- stage: Stage_2
87+
displayName: Publish git tag
88+
dependsOn: Stage_1
89+
jobs:
90+
- job: Job_1
91+
displayName: Agent job
92+
condition: succeeded()
93+
timeoutInMinutes: 0
94+
templateContext:
95+
type: releaseJob
96+
isProduction: true
97+
inputs:
98+
- input: pipelineArtifact
99+
pipeline: 'tgz'
100+
artifactName: 'tgz'
101+
targetPath: '$(Pipeline.Workspace)/tgz'
102+
steps:
103+
- checkout: none
104+
- task: GitHubRelease@1
105+
displayName: GitHub release (create)
106+
inputs:
107+
# This must match the service connection.
108+
gitHubConnection: typescript-bot connection
109+
repositoryName: microsoft/TypeScript
110+
tagSource: userSpecifiedTag
111+
tag: $(TAG_NAME)
112+
title: TypeScript $(RELEASE_TITLE_NAME)
113+
releaseNotesSource: inline
114+
releaseNotesInline: |
115+
For release notes, check out the [release announcement]().
116+
For new features, check out the [What's new in TypeScript $(TAG_NAME)]().
117+
For the complete list of fixed issues, check out the
118+
* [fixed issues query for TypeScript $(TAG_NAME)](https://github.com/microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue+milestone%3A%22TypeScript+3.3%22+is%3Aclosed+).
119+
Downloads are available on:
120+
* [npm](https://www.npmjs.com/package/typescript)
121+
assets: $(Pipeline.Workspace)/tgz/**/typescript-*.tgz
122+
isDraft: true
123+
addChangeLog: false

src/compiler/checker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15941,6 +15941,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1594115941
isInJSFile(declaration) &&
1594215942
isValueSignatureDeclaration(declaration) &&
1594315943
!hasJSDocParameterTags(declaration) &&
15944+
!some(declaration.parameters, p => !!getJSDocType(p)) &&
1594415945
!getJSDocType(declaration) &&
1594515946
!getContextualSignatureForFunctionLikeDeclaration(declaration);
1594615947
if (isUntypedSignatureInJSFile) {

src/services/completions.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2745,8 +2745,14 @@ export function getCompletionEntriesFromSymbols(
27452745
}
27462746
// Filter out variables from their own initializers
27472747
// `const a = /* no 'a' here */`
2748-
if (tryCast(closestSymbolDeclaration, isVariableDeclaration) && symbol.valueDeclaration === closestSymbolDeclaration) {
2749-
return false;
2748+
if (closestSymbolDeclaration && tryCast(closestSymbolDeclaration, isVariableDeclaration)) {
2749+
if (symbol.valueDeclaration === closestSymbolDeclaration) {
2750+
return false;
2751+
}
2752+
// const { a } = /* no 'a' here */;
2753+
if (isBindingPattern(closestSymbolDeclaration.name) && closestSymbolDeclaration.name.elements.some(e => e === symbol.valueDeclaration)) {
2754+
return false;
2755+
}
27502756
}
27512757

27522758
// Filter out current and latter parameters from defaults

src/services/symbolDisplay.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
AccessorDeclaration,
23
addRange,
34
arrayFrom,
45
BinaryExpression,
@@ -16,7 +17,6 @@ import {
1617
first,
1718
firstDefined,
1819
forEach,
19-
GetAccessorDeclaration,
2020
getCombinedLocalAndExportSymbolFlags,
2121
getDeclarationOfKind,
2222
getExternalModuleImportEqualsDeclarationExpression,
@@ -83,7 +83,6 @@ import {
8383
ScriptElementKind,
8484
ScriptElementKindModifier,
8585
SemanticMeaning,
86-
SetAccessorDeclaration,
8786
Signature,
8887
SignatureDeclaration,
8988
SignatureFlags,
@@ -290,7 +289,14 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
290289
if (symbolKind !== ScriptElementKind.unknown || symbolFlags & SymbolFlags.Class || symbolFlags & SymbolFlags.Alias) {
291290
// If symbol is accessor, they are allowed only if location is at declaration identifier of the accessor
292291
if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) {
293-
const declaration = find(symbol.declarations as ((GetAccessorDeclaration | SetAccessorDeclaration | PropertyDeclaration)[]), declaration => declaration.name === location);
292+
const declaration = find(
293+
symbol.declarations as (AccessorDeclaration | PropertyDeclaration | PropertyAccessExpression)[],
294+
(declaration): declaration is AccessorDeclaration | PropertyDeclaration =>
295+
declaration.name === location
296+
// an expando member could have been added to an object with a set accessor
297+
// we need to ignore such write location as it shouldn't be displayed as `(setter)` anyway
298+
&& declaration.kind !== SyntaxKind.PropertyAccessExpression,
299+
);
294300
if (declaration) {
295301
switch (declaration.kind) {
296302
case SyntaxKind.GetAccessor:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//// [tests/cases/conformance/jsdoc/jsdocTypeTagOnParameter1.ts] ////
2+
3+
=== /index.js ===
4+
function repeat(
5+
>repeat : Symbol(repeat, Decl(index.js, 0, 0))
6+
7+
/** @type {string} */ message,
8+
>message : Symbol(message, Decl(index.js, 0, 16))
9+
10+
/** @type {number} */ times,
11+
>times : Symbol(times, Decl(index.js, 1, 31))
12+
13+
) {
14+
return Array(times).fill(message).join(` `);
15+
>Array(times).fill(message).join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --))
16+
>Array(times).fill : Symbol(Array.fill, Decl(lib.es2015.core.d.ts, --, --))
17+
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more)
18+
>times : Symbol(times, Decl(index.js, 1, 31))
19+
>fill : Symbol(Array.fill, Decl(lib.es2015.core.d.ts, --, --))
20+
>message : Symbol(message, Decl(index.js, 0, 16))
21+
>join : Symbol(Array.join, Decl(lib.es5.d.ts, --, --))
22+
}
23+
24+
/** @type {Parameters<typeof repeat>[0]} */
25+
const message = `hello`;
26+
>message : Symbol(message, Decl(index.js, 8, 5))
27+
28+
/** @type {Parameters<typeof repeat>[1]} */
29+
const times = 3;
30+
>times : Symbol(times, Decl(index.js, 11, 5))
31+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//// [tests/cases/conformance/jsdoc/jsdocTypeTagOnParameter1.ts] ////
2+
3+
=== /index.js ===
4+
function repeat(
5+
>repeat : (message: string, times: number) => string
6+
> : ^ ^^ ^^ ^^ ^^^^^^^^^^^
7+
8+
/** @type {string} */ message,
9+
>message : string
10+
> : ^^^^^^
11+
12+
/** @type {number} */ times,
13+
>times : number
14+
> : ^^^^^^
15+
16+
) {
17+
return Array(times).fill(message).join(` `);
18+
>Array(times).fill(message).join(` `) : string
19+
> : ^^^^^^
20+
>Array(times).fill(message).join : (separator?: string) => string
21+
> : ^ ^^^ ^^^^^
22+
>Array(times).fill(message) : any[]
23+
> : ^^^^^
24+
>Array(times).fill : (value: any, start?: number, end?: number) => any[]
25+
> : ^ ^^^^^^^ ^^^ ^^ ^^^ ^^^^^^^^^^
26+
>Array(times) : any[]
27+
> : ^^^^^
28+
>Array : ArrayConstructor
29+
> : ^^^^^^^^^^^^^^^^
30+
>times : number
31+
> : ^^^^^^
32+
>fill : (value: any, start?: number, end?: number) => any[]
33+
> : ^ ^^^^^^^ ^^^ ^^ ^^^ ^^^^^^^^^^
34+
>message : string
35+
> : ^^^^^^
36+
>join : (separator?: string) => string
37+
> : ^ ^^^ ^^^^^
38+
>` ` : " "
39+
> : ^^^
40+
}
41+
42+
/** @type {Parameters<typeof repeat>[0]} */
43+
const message = `hello`;
44+
>message : string
45+
> : ^^^^^^
46+
>`hello` : "hello"
47+
> : ^^^^^^^
48+
49+
/** @type {Parameters<typeof repeat>[1]} */
50+
const times = 3;
51+
>times : number
52+
> : ^^^^^^
53+
>3 : 3
54+
> : ^
55+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// @strict: true
2+
// @lib: esnext
3+
// @allowJS: true
4+
// @checkJs: true
5+
// @noEmit: true
6+
7+
// https://github.com/microsoft/TypeScript/issues/61172
8+
9+
// @filename: /index.js
10+
function repeat(
11+
/** @type {string} */ message,
12+
/** @type {number} */ times,
13+
) {
14+
return Array(times).fill(message).join(` `);
15+
}
16+
17+
/** @type {Parameters<typeof repeat>[0]} */
18+
const message = `hello`;
19+
20+
/** @type {Parameters<typeof repeat>[1]} */
21+
const times = 3;

tests/cases/fourslash/completionListWithoutVariableinitializer.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
//// const fn = (p = /*7*/) => {}
1010
//// const { g, h = /*8*/ } = { ... }
1111
//// const [ g1, h1 = /*9*/ ] = [ ... ]
12+
//// const { a1 } = a/*10*/;
13+
//// const { a2 } = fn({a: a/*11*/});
14+
//// const [ a3 ] = a/*12*/;
15+
//// const [ a4 ] = fn([a/*13*/]);
1216

1317
verify.completions({
1418
marker: ["1"],
@@ -58,3 +62,26 @@ verify.completions({
5862
marker: ["9"],
5963
includes: ["a", "b", "c", "d", "e", "fn"],
6064
});
65+
66+
verify.completions({
67+
marker: ["10"],
68+
excludes: ["a1"],
69+
isNewIdentifierLocation: true,
70+
});
71+
72+
verify.completions({
73+
marker: ["11"],
74+
excludes: ["a2"],
75+
});
76+
77+
verify.completions({
78+
marker: ["12"],
79+
excludes: ["a3"],
80+
isNewIdentifierLocation: true,
81+
});
82+
83+
verify.completions({
84+
marker: ["13"],
85+
excludes: ["a4"],
86+
isNewIdentifierLocation: true,
87+
});

0 commit comments

Comments
 (0)