Skip to content

Commit 17a15a1

Browse files
authored
Merge branch 'main' into fix-enum-computed-property
2 parents 3298a5e + 6cf8170 commit 17a15a1

File tree

8 files changed

+203
-172
lines changed

8 files changed

+203
-172
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ jobs:
118118
- name: Tests
119119
id: test
120120
# run tests, but lint separately
121-
run: npm run test -- --no-lint --bundle=${{ matrix.config.bundle }}
121+
env:
122+
BUNDLE: ${{ matrix.config.bundle }}
123+
run: npm run test -- --no-lint --bundle="$BUNDLE"
122124

123125
- name: Print baseline diff on failure
124126
if: ${{ failure() && steps.test.conclusion == 'failure' }}
@@ -264,10 +266,12 @@ jobs:
264266
id: pack
265267
266268
- name: Smoke test
269+
env:
270+
PACKAGE: ${{ steps.pack.outputs.package }}
267271
run: |
268272
cd "$(mktemp -d)"
269273
npm init --yes
270-
npm install ${{ steps.pack.outputs.package }}
274+
npm install "$PACKAGE"
271275
272276
echo "Testing tsc..."
273277
npx tsc --version

.github/workflows/close-issues.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ jobs:
2626
- name: Close issues
2727
env:
2828
GH_TOKEN: ${{ secrets.TS_BOT_GITHUB_TOKEN }}
29+
REPO: ${{ github.repository }}
2930
run: |
3031
DATE=$(date --date='2 days ago' --iso-8601)
3132
3233
close_issues() {
3334
echo "Closing issues marked as '$1'."
34-
for issue in $(gh issue list --limit 100 --label "$1" --repo ${{ github.repository }} --state open --search "updated:<$DATE" --json number --jq '.[].number'); do
35-
echo "Closing https://github.com/${{ github.repository }}/issues/$issue"
36-
gh issue close $issue --repo ${{ github.repository }} --reason "not planned" --comment "This issue has been marked as \"$1\" and has seen no recent activity. It has been automatically closed for house-keeping purposes."
35+
for issue in $(gh issue list --limit 100 --label "$1" --repo "$REPO" --state open --search "updated:<$DATE" --json number --jq '.[].number'); do
36+
echo "Closing https://github.com/$REPO/issues/$issue"
37+
gh issue close $issue --repo "$REPO" --reason "not planned" --comment "This issue has been marked as \"$1\" and has seen no recent activity. It has been automatically closed for house-keeping purposes."
3738
done
3839
}
3940

.github/workflows/lkg.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ jobs:
2121
build:
2222
runs-on: ubuntu-latest
2323
steps:
24-
- run: |
25-
if [[ ! "${{ inputs.branch_name }}" =~ ^release- ]]; then
24+
- env:
25+
BRANCH_NAME: ${{ inputs.branch_name }}
26+
run: |
27+
if [[ ! "$BRANCH_NAME" =~ ^release- ]]; then
2628
echo "Branch name must start with 'release-'"
2729
exit 1
2830
fi

.github/workflows/new-release-branch.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,16 @@ jobs:
6363
# corepack enable npm
6464
npm install -g $(jq -r '.packageManager' < package.json)
6565
npm --version
66-
- run: |
67-
git checkout -b ${{ inputs.branch_name }}
68-
sed -i -e 's/"version": ".*"/"version": "${{ inputs.package_version }}"/g' package.json
69-
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ inputs.core_major_minor }}"/g' src/compiler/corePublic.ts
70-
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ inputs.core_major_minor }}"/g' tests/baselines/reference/api/typescript.d.ts
71-
sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "${{ inputs.package_version }}" as string;/g' src/compiler/corePublic.ts
66+
- env:
67+
BRANCH_NAME: ${{ inputs.branch_name }}
68+
PACKAGE_VERSION: ${{ inputs.package_version }}
69+
CORE_MAJOR_MINOR: ${{ inputs.core_major_minor }}
70+
run: |
71+
git checkout -b "$BRANCH_NAME"
72+
sed -i -e 's/"version": ".*"/"version": "'"$PACKAGE_VERSION"'"/g' package.json
73+
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "'"$CORE_MAJOR_MINOR"'"/g' src/compiler/corePublic.ts
74+
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "'"$CORE_MAJOR_MINOR"'"/g' tests/baselines/reference/api/typescript.d.ts
75+
sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "'"$PACKAGE_VERSION"'" as string;/g' src/compiler/corePublic.ts
7276
npm ci
7377
npm install # update package-lock.json to ensure the version bump is included
7478
npx hereby LKG
@@ -80,8 +84,8 @@ jobs:
8084
git add --force ./lib
8185
git config user.email "typescriptbot@microsoft.com"
8286
git config user.name "TypeScript Bot"
83-
git commit -m 'Bump version to ${{ inputs.package_version }} and LKG'
84-
git push --set-upstream origin ${{ inputs.branch_name }}
87+
git commit -m "Bump version to $PACKAGE_VERSION and LKG"
88+
git push --set-upstream origin "$BRANCH_NAME"
8589
8690
- uses: microsoft/typescript-bot-test-triggerer/.github/actions/post-workflow-result@master
8791
if: ${{ !cancelled() && inputs.distinct_id }}

.github/workflows/pr-modified-files.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@ jobs:
3333

3434
env:
3535
GH_TOKEN: ${{ secrets.TS_BOT_GITHUB_TOKEN }}
36+
PR_NUMBER: ${{ github.event.pull_request.number }}
37+
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
38+
REPO: ${{ github.repository }}
3639

3740
steps:
3841
- name: Check if PR author is in pr_owners.txt
3942
id: pr_owner
4043
run: |
4144
curl -s https://raw.githubusercontent.com/microsoft/TypeScript/main/.github/pr_owners.txt > pr_owners.txt
42-
if grep -Fxq -m1 "${{ github.event.pull_request.user.login }}" pr_owners.txt; then
45+
if grep -Fxq -m1 "$PR_AUTHOR" pr_owners.txt; then
4346
echo "pr_owner=true" >> "$GITHUB_OUTPUT"
4447
else
4548
echo "pr_owner=false" >> "$GITHUB_OUTPUT"
@@ -57,7 +60,7 @@ jobs:
5760
gh api graphql -f query='
5861
query($endCursor: String) {
5962
repository(owner: "microsoft", name: "TypeScript") {
60-
pullRequest(number: ${{ github.event.pull_request.number }}) {
63+
pullRequest(number: '"$PR_NUMBER"') {
6164
files(first: 100, after: $endCursor) {
6265
pageInfo{ hasNextPage, endCursor }
6366
nodes {
@@ -79,7 +82,7 @@ jobs:
7982
#!/bin/bash
8083
FILENAME=bot_comments.txt
8184
if [ ! -f $FILENAME ]; then
82-
gh pr view ${{ github.event.pull_request.number }} --repo ${{ github.repository }} \
85+
gh pr view $PR_NUMBER --repo $REPO \
8386
--json 'comments' --jq '.comments[] | select(.author.login == "typescript-bot") | .body' > $FILENAME
8487
fi
8588
exec grep -Fq -m1 "$1" $FILENAME
@@ -99,7 +102,7 @@ jobs:
99102
MESSAGE+=" You can [read more here](https://github.com/microsoft/TypeScript/blob/main/CONTRIBUTING.md#contributing-libdts-fixes)."
100103
MESSAGE+=" For house-keeping purposes, this pull request will be closed."
101104
102-
gh pr close ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --comment "$MESSAGE"
105+
gh pr close "$PR_NUMBER" --repo "$REPO" --comment "$MESSAGE"
103106
exit 1 # Stop the pipeline; we just closed the PR.
104107
fi
105108
@@ -114,7 +117,7 @@ jobs:
114117
if ./already_commented.sh "It looks like you've changed the TSServer protocol in some way."; then
115118
echo "Already commented."
116119
else
117-
gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body "$MESSAGE"
120+
gh pr comment "$PR_NUMBER" --repo "$REPO" --body "$MESSAGE"
118121
fi
119122
fi
120123
@@ -130,6 +133,6 @@ jobs:
130133
if ./already_commented.sh "Looks like you're introducing a change to the public API surface area."; then
131134
echo "Already commented."
132135
else
133-
gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body "$MESSAGE"
136+
gh pr comment "$PR_NUMBER" --repo "$REPO" --body "$MESSAGE"
134137
fi
135138
fi

.github/workflows/set-version.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,14 @@ jobs:
6868
# branch_name - the target branch
6969
# package_version - the full version string (eg, `3.9.1-rc` or `3.9.2`)
7070
# core_major_minor - the major.minor pair associated with the desired package_version (eg, `3.9` for `3.9.3`)
71-
- run: |
72-
sed -i -e 's/"version": ".*"/"version": "${{ inputs.package_version }}"/g' package.json
73-
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ inputs.core_major_minor }}"/g' src/compiler/corePublic.ts
74-
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ inputs.core_major_minor }}"/g' tests/baselines/reference/api/typescript.d.ts
75-
sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "${{ inputs.package_version }}" as string;/g' src/compiler/corePublic.ts
71+
- env:
72+
PACKAGE_VERSION: ${{ inputs.package_version }}
73+
CORE_MAJOR_MINOR: ${{ inputs.core_major_minor }}
74+
run: |
75+
sed -i -e 's/"version": ".*"/"version": "'"$PACKAGE_VERSION"'"/g' package.json
76+
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "'"$CORE_MAJOR_MINOR"'"/g' src/compiler/corePublic.ts
77+
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "'"$CORE_MAJOR_MINOR"'"/g' tests/baselines/reference/api/typescript.d.ts
78+
sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "'"$PACKAGE_VERSION"'" as string;/g' src/compiler/corePublic.ts
7679
npm ci
7780
npm install # update package-lock.json to ensure the version bump is included
7881
npx hereby LKG
@@ -84,7 +87,7 @@ jobs:
8487
git add --force ./lib
8588
git config user.email "typescriptbot@microsoft.com"
8689
git config user.name "TypeScript Bot"
87-
git commit -m 'Bump version to ${{ inputs.package_version }} and LKG'
90+
git commit -m "Bump version to $PACKAGE_VERSION and LKG"
8891
git push
8992
9093
- uses: microsoft/typescript-bot-test-triggerer/.github/actions/post-workflow-result@master

src/lib/esnext.temporal.d.ts

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,22 @@ declare namespace Temporal {
5959
offset?: string | undefined;
6060
}
6161

62-
type DateUnit = "year" | "month" | "week" | "day" | "years" | "months" | "weeks" | "days";
63-
type TimeUnit = "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond" | "hours" | "minutes" | "seconds" | "milliseconds" | "microseconds" | "nanoseconds";
62+
type DateUnit = "year" | "month" | "week" | "day";
63+
type TimeUnit = "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond";
64+
type PluralizeUnit<T extends DateUnit | TimeUnit> =
65+
| T
66+
| {
67+
year: "years";
68+
month: "months";
69+
week: "weeks";
70+
day: "days";
71+
hour: "hours";
72+
minute: "minutes";
73+
second: "seconds";
74+
millisecond: "milliseconds";
75+
microsecond: "microseconds";
76+
nanosecond: "nanoseconds";
77+
}[T];
6478

6579
interface DisambiguationOptions {
6680
disambiguation?: "compatible" | "earlier" | "later" | "reject" | undefined;
@@ -75,13 +89,13 @@ declare namespace Temporal {
7589
}
7690

7791
interface RoundingOptions<Units extends DateUnit | TimeUnit> {
78-
smallestUnit?: Units | undefined;
92+
smallestUnit?: PluralizeUnit<Units> | undefined;
7993
roundingIncrement?: number | undefined;
8094
roundingMode?: "ceil" | "floor" | "expand" | "trunc" | "halfCeil" | "halfFloor" | "halfExpand" | "halfTrunc" | "halfEven" | undefined;
8195
}
8296

8397
interface RoundingOptionsWithLargestUnit<Units extends DateUnit | TimeUnit> extends RoundingOptions<Units> {
84-
largestUnit?: "auto" | Units | undefined;
98+
largestUnit?: "auto" | PluralizeUnit<Units> | undefined;
8599
}
86100

87101
interface ToStringRoundingOptions<Units extends DateUnit | TimeUnit> extends Pick<RoundingOptions<Units>, "smallestUnit" | "roundingMode"> {}
@@ -152,7 +166,7 @@ declare namespace Temporal {
152166
}
153167
var PlainDate: PlainDateConstructor;
154168

155-
interface PlainTimeToStringOptions extends ToStringRoundingOptionsWithFractionalSeconds<Exclude<TimeUnit, "hour" | "hours">> {}
169+
interface PlainTimeToStringOptions extends ToStringRoundingOptionsWithFractionalSeconds<Exclude<TimeUnit, "hour">> {}
156170

157171
interface PlainTime {
158172
readonly hour: number;
@@ -167,7 +181,7 @@ declare namespace Temporal {
167181
until(other: PlainTimeLike, options?: RoundingOptionsWithLargestUnit<TimeUnit>): Duration;
168182
since(other: PlainTimeLike, options?: RoundingOptionsWithLargestUnit<TimeUnit>): Duration;
169183
equals(other: PlainTimeLike): boolean;
170-
round(roundTo: TimeUnit): PlainTime;
184+
round(roundTo: PluralizeUnit<TimeUnit>): PlainTime;
171185
round(roundTo: RoundingOptions<TimeUnit>): PlainTime;
172186
toString(options?: PlainTimeToStringOptions): string;
173187
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
@@ -216,8 +230,8 @@ declare namespace Temporal {
216230
subtract(duration: DurationLike, options?: OverflowOptions): PlainDateTime;
217231
until(other: PlainDateTimeLike, options?: RoundingOptionsWithLargestUnit<DateUnit | TimeUnit>): Duration;
218232
since(other: PlainDateTimeLike, options?: RoundingOptionsWithLargestUnit<DateUnit | TimeUnit>): Duration;
219-
round(roundTo: "day" | "days" | TimeUnit): PlainDateTime;
220-
round(roundTo: RoundingOptions<"day" | "days" | TimeUnit>): PlainDateTime;
233+
round(roundTo: PluralizeUnit<"day" | TimeUnit>): PlainDateTime;
234+
round(roundTo: RoundingOptions<"day" | TimeUnit>): PlainDateTime;
221235
equals(other: PlainDateTimeLike): boolean;
222236
toString(options?: PlainDateTimeToStringOptions): string;
223237
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
@@ -283,8 +297,8 @@ declare namespace Temporal {
283297
subtract(duration: DurationLike, options?: OverflowOptions): ZonedDateTime;
284298
until(other: ZonedDateTimeLike, options?: RoundingOptionsWithLargestUnit<DateUnit | TimeUnit>): Duration;
285299
since(other: ZonedDateTimeLike, options?: RoundingOptionsWithLargestUnit<DateUnit | TimeUnit>): Duration;
286-
round(roundTo: "day" | "days" | TimeUnit): ZonedDateTime;
287-
round(roundTo: RoundingOptions<"day" | "days" | TimeUnit>): ZonedDateTime;
300+
round(roundTo: PluralizeUnit<"day" | TimeUnit>): ZonedDateTime;
301+
round(roundTo: RoundingOptions<"day" | TimeUnit>): ZonedDateTime;
288302
equals(other: ZonedDateTimeLike): boolean;
289303
toString(options?: ZonedDateTimeToStringOptions): string;
290304
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;
@@ -314,10 +328,10 @@ declare namespace Temporal {
314328

315329
interface DurationRoundingOptions extends DurationRelativeToOptions, RoundingOptionsWithLargestUnit<DateUnit | TimeUnit> {}
316330

317-
interface DurationToStringOptions extends ToStringRoundingOptionsWithFractionalSeconds<Exclude<TimeUnit, "hour" | "minute" | "hours" | "minutes">> {}
331+
interface DurationToStringOptions extends ToStringRoundingOptionsWithFractionalSeconds<Exclude<TimeUnit, "hour" | "minute">> {}
318332

319333
interface DurationTotalOptions extends DurationRelativeToOptions {
320-
unit: DateUnit | TimeUnit;
334+
unit: PluralizeUnit<DateUnit | TimeUnit>;
321335
}
322336

323337
interface Duration {
@@ -338,9 +352,9 @@ declare namespace Temporal {
338352
abs(): Duration;
339353
add(other: DurationLike): Duration;
340354
subtract(other: DurationLike): Duration;
341-
round(roundTo: "day" | "days" | TimeUnit): Duration;
355+
round(roundTo: PluralizeUnit<"day" | TimeUnit>): Duration;
342356
round(roundTo: DurationRoundingOptions): Duration;
343-
total(totalOf: "day" | "days" | TimeUnit): number;
357+
total(totalOf: PluralizeUnit<"day" | TimeUnit>): number;
344358
total(totalOf: DurationTotalOptions): number;
345359
toString(options?: DurationToStringOptions): string;
346360
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DurationFormatOptions): string;
@@ -368,7 +382,7 @@ declare namespace Temporal {
368382
subtract(duration: DurationLike): Instant;
369383
until(other: InstantLike, options?: RoundingOptionsWithLargestUnit<TimeUnit>): Duration;
370384
since(other: InstantLike, options?: RoundingOptionsWithLargestUnit<TimeUnit>): Duration;
371-
round(roundTo: TimeUnit): Instant;
385+
round(roundTo: PluralizeUnit<TimeUnit>): Instant;
372386
round(roundTo: RoundingOptions<TimeUnit>): Instant;
373387
equals(other: InstantLike): boolean;
374388
toString(options?: InstantToStringOptions): string;
@@ -407,8 +421,8 @@ declare namespace Temporal {
407421
with(yearMonthLike: PartialTemporalLike<YearMonthLikeObject>, options?: OverflowOptions): PlainYearMonth;
408422
add(duration: DurationLike, options?: OverflowOptions): PlainYearMonth;
409423
subtract(duration: DurationLike, options?: OverflowOptions): PlainYearMonth;
410-
until(other: PlainYearMonthLike, options?: RoundingOptionsWithLargestUnit<"year" | "month" | "years" | "months">): Duration;
411-
since(other: PlainYearMonthLike, options?: RoundingOptionsWithLargestUnit<"year" | "month" | "years" | "months">): Duration;
424+
until(other: PlainYearMonthLike, options?: RoundingOptionsWithLargestUnit<"year" | "month">): Duration;
425+
since(other: PlainYearMonthLike, options?: RoundingOptionsWithLargestUnit<"year" | "month">): Duration;
412426
equals(other: PlainYearMonthLike): boolean;
413427
toString(options?: PlainDateToStringOptions): string;
414428
toLocaleString(locales?: Intl.LocalesArgument, options?: Intl.DateTimeFormatOptions): string;

0 commit comments

Comments
 (0)