mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 03:45:33 -05:00
Improve TupleBase docs and backward compatibility
This commit is contained in:
@@ -4997,7 +4997,7 @@ namespace ts {
|
||||
function getBaseTypes(type: InterfaceType): BaseType[] {
|
||||
if (!type.resolvedBaseTypes) {
|
||||
if (type.objectFlags & ObjectFlags.Tuple) {
|
||||
type.resolvedBaseTypes = [createTypeFromGenericGlobalType(globalTupleBaseType, [getUnionType(type.typeParameters)])];
|
||||
type.resolvedBaseTypes = [createTypeFromGenericGlobalType(globalTupleBaseType || globalArrayType, [getUnionType(type.typeParameters)])];
|
||||
}
|
||||
else if (type.symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) {
|
||||
if (type.symbol.flags & SymbolFlags.Class) {
|
||||
@@ -24511,8 +24511,8 @@ namespace ts {
|
||||
autoArrayType = createArrayType(autoType);
|
||||
|
||||
// TODO: ReadonlyArray and TupleBase should always be available, but haven't been required previously
|
||||
globalReadonlyArrayType = <GenericType>getGlobalType("ReadonlyArray" as __String, /*arity*/ 1, /*reportErrors*/ true);
|
||||
globalTupleBaseType = <GenericType>getGlobalType("TupleBase" as __String, /*arity*/ 1, /*reportErrors*/ true);
|
||||
globalReadonlyArrayType = <GenericType>getGlobalTypeOrUndefined("ReadonlyArray" as __String, /*arity*/ 1);
|
||||
globalTupleBaseType = <GenericType>getGlobalTypeOrUndefined("TupleBase" as __String, /*arity*/ 1);
|
||||
anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType;
|
||||
globalThisType = <GenericType>getGlobalTypeOrUndefined("ThisType" as __String, /*arity*/ 1);
|
||||
}
|
||||
|
||||
23
src/lib/es5.d.ts
vendored
23
src/lib/es5.d.ts
vendored
@@ -1241,15 +1241,20 @@ interface ArrayConstructor {
|
||||
declare const Array: ArrayConstructor;
|
||||
|
||||
interface TupleBase<T> extends Array<T> {
|
||||
// TODO: Add jsdoc here warning not to call this
|
||||
push(...items: never[]): never;
|
||||
pop(): never | undefined;
|
||||
reverse(): never[];
|
||||
sort(compareFn?: (a: never, b: never) => number): never;
|
||||
shift(): never | undefined;
|
||||
unshift(...items: never[]): never;
|
||||
splice(start: number, deleteCount?: number): never[];
|
||||
splice(start: number, deleteCount: number, ...items: never[]): never[];
|
||||
/** Mutation is not allowed on tuples. Do not use this method. */
|
||||
push: never;
|
||||
/** Mutation is not allowed on tuples. Do not use this method. */
|
||||
pop: never;
|
||||
/** Mutation is not allowed on tuples. Do not use this method. */
|
||||
reverse: never;
|
||||
/** Mutation is not allowed on tuples. Do not use this method. */
|
||||
sort: never;
|
||||
/** Mutation is not allowed on tuples. Do not use this method. */
|
||||
shift: never;
|
||||
/** Mutation is not allowed on tuples. Do not use this method. */
|
||||
unshift: never;
|
||||
/** Mutation is not allowed on tuples. Do not use this method. */
|
||||
splice: never;
|
||||
}
|
||||
|
||||
interface TypedPropertyDescriptor<T> {
|
||||
|
||||
Reference in New Issue
Block a user