Skip to content

Commit

Permalink
feat: TypeScript 5.3 (denoland#21480)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Dec 6, 2023
1 parent a931a47 commit 68d356e
Show file tree
Hide file tree
Showing 46 changed files with 25,677 additions and 7,286 deletions.
2 changes: 1 addition & 1 deletion cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ fn main() {
);

let ts_version = ts::version();
debug_assert_eq!(ts_version, "5.2.2"); // bump this assertion when it changes
debug_assert_eq!(ts_version, "5.3.3"); // bump this assertion when it changes
println!("cargo:rustc-env=TS_VERSION={}", ts_version);
println!("cargo:rerun-if-env-changed=TS_VERSION");

Expand Down
4 changes: 2 additions & 2 deletions cli/tests/integration/lsp_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9109,11 +9109,11 @@ fn lsp_workspace_symbol() {
"uri": "deno:/asset/lib.decorators.d.ts",
"range": {
"start": {
"line": 346,
"line": 343,
"character": 0,
},
"end": {
"line": 388,
"line": 385,
"character": 1,
},
},
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/unit/version_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Deno.test(function version() {
const pattern = /^\d+\.\d+\.\d+/;
assert(pattern.test(Deno.version.deno));
assert(pattern.test(Deno.version.v8));
assertEquals(Deno.version.typescript, "5.2.2");
assertEquals(Deno.version.typescript, "5.3.3");
});
27,262 changes: 20,798 additions & 6,464 deletions cli/tsc/00_typescript.js

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions cli/tsc/99_main_compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ delete Object.prototype.__proto__;
impliedNodeFormat: isCjsCache.has(fileName)
? ts.ModuleKind.CommonJS
: ts.ModuleKind.ESNext,
// in the lsp we want to be able to show documentation
jsDocParsingMode: ts.JSDocParsingMode.ParseAll,
},
version,
true,
Expand Down Expand Up @@ -537,11 +539,12 @@ delete Object.prototype.__proto__;
_onError,
_shouldCreateNewSourceFile,
) {
const createOptions = getCreateSourceFileOptions(languageVersion);
if (logDebug) {
debug(
`host.getSourceFile("${specifier}", ${
ts.ScriptTarget[createOptions.languageVersion]
ts.ScriptTarget[
getCreateSourceFileOptions(languageVersion).languageVersion
]
})`,
);
}
Expand All @@ -568,10 +571,12 @@ delete Object.prototype.__proto__;
specifier,
data,
{
...createOptions,
...getCreateSourceFileOptions(languageVersion),
impliedNodeFormat: isCjsCache.has(specifier)
? ts.ModuleKind.CommonJS
: ts.ModuleKind.ESNext,
// no need to parse docs for `deno check`
jsDocParsingMode: ts.JSDocParsingMode.ParseForTypeErrors,
},
false,
scriptKind,
Expand Down
9 changes: 3 additions & 6 deletions cli/tsc/dts/lib.decorators.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,18 @@ type ClassMemberDecoratorContext =
| ClassGetterDecoratorContext
| ClassSetterDecoratorContext
| ClassFieldDecoratorContext
| ClassAccessorDecoratorContext
;
| ClassAccessorDecoratorContext;

/**
* The decorator context types provided to any decorator.
*/
type DecoratorContext =
| ClassDecoratorContext
| ClassMemberDecoratorContext
;
| ClassMemberDecoratorContext;

type DecoratorMetadataObject = Record<PropertyKey, unknown> & object;

type DecoratorMetadata =
typeof globalThis extends { Symbol: { readonly metadata: symbol } } ? DecoratorMetadataObject : DecoratorMetadataObject | undefined;
type DecoratorMetadata = typeof globalThis extends { Symbol: { readonly metadata: symbol; }; } ? DecoratorMetadataObject : DecoratorMetadataObject | undefined;

/**
* Context provided to a class decorator.
Expand Down
8 changes: 6 additions & 2 deletions cli/tsc/dts/lib.dom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,7 @@ interface RTCInboundRtpStreamStats extends RTCReceivedRtpStreamStats {
keyFramesDecoded?: number;
kind: string;
lastPacketReceivedTimestamp?: DOMHighResTimeStamp;
mid?: string;
nackCount?: number;
packetsDiscarded?: number;
pliCount?: number;
Expand All @@ -1450,6 +1451,7 @@ interface RTCInboundRtpStreamStats extends RTCReceivedRtpStreamStats {
totalSamplesDuration?: number;
totalSamplesReceived?: number;
totalSquaredInterFrameDelay?: number;
trackIdentifier: string;
}

interface RTCLocalSessionDescriptionInit {
Expand Down Expand Up @@ -8209,7 +8211,7 @@ interface EventTarget {
*/
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): void;
/**
* Dispatches a synthetic event to event target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
* Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
*/
Expand Down Expand Up @@ -21844,7 +21846,9 @@ interface SubtleCrypto {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey) */
exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
exportKey(format: Exclude<KeyFormat, "jwk">, key: CryptoKey): Promise<ArrayBuffer>;
exportKey(format: KeyFormat, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey) */
generateKey(algorithm: "Ed25519", extractable: boolean, keyUsages: ReadonlyArray<"sign" | "verify">): Promise<CryptoKeyPair>;
generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKeyPair>;
generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: ReadonlyArray<KeyUsage>): Promise<CryptoKey>;
generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKeyPair | CryptoKey>;
Expand Down Expand Up @@ -27428,7 +27432,7 @@ declare function scrollTo(x: number, y: number): void;
declare function stop(): void;
declare function toString(): string;
/**
* Dispatches a synthetic event to event target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
* Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
*/
Expand Down
3 changes: 1 addition & 2 deletions cli/tsc/dts/lib.es2015.collection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ and limitations under the License.
/// <reference no-default-lib="true"/>

interface Map<K, V> {

clear(): void;
/**
* @returns true if an element in the Map existed and has been removed, or false if the element does not exist.
Expand Down Expand Up @@ -47,7 +46,7 @@ interface Map<K, V> {
}

interface MapConstructor {
new(): Map<any, any>;
new (): Map<any, any>;
new <K, V>(entries?: readonly (readonly [K, V])[] | null): Map<K, V>;
readonly prototype: Map<any, any>;
}
Expand Down
2 changes: 1 addition & 1 deletion cli/tsc/dts/lib.es2015.core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,5 +553,5 @@ interface StringConstructor {
* @param template A well-formed template string call site representation.
* @param substitutions A set of substitution values.
*/
raw(template: { raw: readonly string[] | ArrayLike<string>}, ...substitutions: any[]): string;
raw(template: { raw: readonly string[] | ArrayLike<string>; }, ...substitutions: any[]): string;
}
9 changes: 4 additions & 5 deletions cli/tsc/dts/lib.es2015.iterable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ interface ReadonlyMap<K, V> {
}

interface MapConstructor {
new(): Map<any, any>;
new (): Map<any, any>;
new <K, V>(iterable?: Iterable<readonly [K, V]> | null): Map<K, V>;
}

interface WeakMap<K extends WeakKey, V> { }
interface WeakMap<K extends WeakKey, V> {}

interface WeakMapConstructor {
new <K extends WeakKey, V>(iterable: Iterable<readonly [K, V]>): WeakMap<K, V>;
Expand Down Expand Up @@ -207,13 +207,13 @@ interface SetConstructor {
new <T>(iterable?: Iterable<T> | null): Set<T>;
}

interface WeakSet<T extends WeakKey> { }
interface WeakSet<T extends WeakKey> {}

interface WeakSetConstructor {
new <T extends WeakKey = WeakKey>(iterable: Iterable<T>): WeakSet<T>;
}

interface Promise<T> { }
interface Promise<T> {}

interface PromiseConstructor {
/**
Expand Down Expand Up @@ -315,7 +315,6 @@ interface Uint8ClampedArray {
interface Uint8ClampedArrayConstructor {
new (elements: Iterable<number>): Uint8ClampedArray;


/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
Expand Down
2 changes: 1 addition & 1 deletion cli/tsc/dts/lib.es2015.promise.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
all<T extends readonly unknown[] | []>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]> }>;
all<T extends readonly unknown[] | []>(values: T): Promise<{ -readonly [P in keyof T]: Awaited<T[P]>; }>;

// see: lib.es2015.iterable.d.ts
// all<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>;
Expand Down
2 changes: 1 addition & 1 deletion cli/tsc/dts/lib.es2015.symbol.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ interface SymbolConstructor {
keyFor(sym: symbol): string | undefined;
}

declare var Symbol: SymbolConstructor;
declare var Symbol: SymbolConstructor;
2 changes: 1 addition & 1 deletion cli/tsc/dts/lib.es2016.array.include.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ interface Float64Array {
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: number, fromIndex?: number): boolean;
}
}
2 changes: 1 addition & 1 deletion cli/tsc/dts/lib.es2016.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ and limitations under the License.
/// <reference no-default-lib="true"/>

/// <reference lib="es2015" />
/// <reference lib="es2016.array.include" />
/// <reference lib="es2016.array.include" />
2 changes: 1 addition & 1 deletion cli/tsc/dts/lib.es2016.full.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ and limitations under the License.
/// <reference lib="dom" />
/// <reference lib="webworker.importscripts" />
/// <reference lib="scripthost" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.iterable" />
2 changes: 1 addition & 1 deletion cli/tsc/dts/lib.es2017.full.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ and limitations under the License.
/// <reference lib="dom" />
/// <reference lib="webworker.importscripts" />
/// <reference lib="scripthost" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.iterable" />
23 changes: 11 additions & 12 deletions cli/tsc/dts/lib.es2017.intl.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@ and limitations under the License.
/// <reference no-default-lib="true"/>

declare namespace Intl {

interface DateTimeFormatPartTypesRegistry {
day: any
dayPeriod: any
era: any
hour: any
literal: any
minute: any
month: any
second: any
timeZoneName: any
weekday: any
year: any
day: any;
dayPeriod: any;
era: any;
hour: any;
literal: any;
minute: any;
month: any;
second: any;
timeZoneName: any;
weekday: any;
year: any;
}

type DateTimeFormatPartTypes = keyof DateTimeFormatPartTypesRegistry;
Expand Down
6 changes: 3 additions & 3 deletions cli/tsc/dts/lib.es2017.object.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface ObjectConstructor {
* Returns an array of values of the enumerable properties of an object
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
values<T>(o: { [s: string]: T } | ArrayLike<T>): T[];
values<T>(o: { [s: string]: T; } | ArrayLike<T>): T[];

/**
* Returns an array of values of the enumerable properties of an object
Expand All @@ -33,7 +33,7 @@ interface ObjectConstructor {
* Returns an array of key/values of the enumerable properties of an object
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
entries<T>(o: { [s: string]: T } | ArrayLike<T>): [string, T][];
entries<T>(o: { [s: string]: T; } | ArrayLike<T>): [string, T][];

/**
* Returns an array of key/values of the enumerable properties of an object
Expand All @@ -45,5 +45,5 @@ interface ObjectConstructor {
* Returns an object containing all own property descriptors of an object
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
*/
getOwnPropertyDescriptors<T>(o: T): {[P in keyof T]: TypedPropertyDescriptor<T[P]>} & { [x: string]: PropertyDescriptor };
getOwnPropertyDescriptors<T>(o: T): { [P in keyof T]: TypedPropertyDescriptor<T[P]>; } & { [x: string]: PropertyDescriptor; };
}
2 changes: 1 addition & 1 deletion cli/tsc/dts/lib.es2018.asynciterable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ interface AsyncIterable<T> {

interface AsyncIterableIterator<T> extends AsyncIterator<T> {
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
}
}
2 changes: 1 addition & 1 deletion cli/tsc/dts/lib.es2018.full.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ and limitations under the License.
/// <reference lib="dom" />
/// <reference lib="webworker.importscripts" />
/// <reference lib="scripthost" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.iterable" />
3 changes: 1 addition & 2 deletions cli/tsc/dts/lib.es2018.intl.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ and limitations under the License.
/// <reference no-default-lib="true"/>

declare namespace Intl {

// http:https://cldr.unicode.org/index/cldr-spec/plural-rules#TOC-Determining-Plural-Categories
type LDMLPluralRule = "zero" | "one" | "two" | "few" | "many" | "other";
type PluralRuleType = "cardinal" | "ordinal";
Expand Down Expand Up @@ -52,7 +51,7 @@ declare namespace Intl {
new (locales?: string | string[], options?: PluralRulesOptions): PluralRules;
(locales?: string | string[], options?: PluralRulesOptions): PluralRules;

supportedLocalesOf(locales: string | string[], options?: { localeMatcher?: "lookup" | "best fit" }): string[];
supportedLocalesOf(locales: string | string[], options?: { localeMatcher?: "lookup" | "best fit"; }): string[];
};

// We can only have one definition for 'type' in TypeScript, and so you can learn where the keys come from here:
Expand Down
2 changes: 1 addition & 1 deletion cli/tsc/dts/lib.es2018.promise.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ interface Promise<T> {
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
* @returns A Promise for the completion of the callback.
*/
finally(onfinally?: (() => void) | undefined | null): Promise<T>
finally(onfinally?: (() => void) | undefined | null): Promise<T>;
}
10 changes: 5 additions & 5 deletions cli/tsc/dts/lib.es2018.regexp.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ and limitations under the License.

interface RegExpMatchArray {
groups?: {
[key: string]: string
}
[key: string]: string;
};
}

interface RegExpExecArray {
groups?: {
[key: string]: string
}
[key: string]: string;
};
}

interface RegExp {
Expand All @@ -34,4 +34,4 @@ interface RegExp {
* Default is false. Read-only.
*/
readonly dotAll: boolean;
}
}
Loading

0 comments on commit 68d356e

Please sign in to comment.