Improve TupleBase docs and backward compatibility

This commit is contained in:
Nathan Shively-Sanders
2017-11-06 10:50:57 -08:00
parent 4385444c44
commit 2399d58266
2 changed files with 17 additions and 12 deletions

View File

@@ -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
View File

@@ -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> {