mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 05:17:43 -05:00
Update more return types to include undefined (#15903)
* Update more return types * Update types of forEachChild callbacks * fix line endings
This commit is contained in:
committed by
Mohamed Hegazy
parent
73ee2feb51
commit
f8aae89157
@@ -44,7 +44,7 @@ namespace ts.JsDoc {
|
||||
let jsDocTagNameCompletionEntries: CompletionEntry[];
|
||||
let jsDocTagCompletionEntries: CompletionEntry[];
|
||||
|
||||
export function getJsDocCommentsFromDeclarations(declarations: Declaration[]) {
|
||||
export function getJsDocCommentsFromDeclarations(declarations?: Declaration[]) {
|
||||
// Only collect doc comments from duplicate declarations once:
|
||||
// In case of a union property there might be same declaration multiple times
|
||||
// which only varies in type parameter
|
||||
@@ -69,7 +69,7 @@ namespace ts.JsDoc {
|
||||
return documentationComment;
|
||||
}
|
||||
|
||||
export function getJsDocTagsFromDeclarations(declarations: Declaration[]) {
|
||||
export function getJsDocTagsFromDeclarations(declarations?: Declaration[]) {
|
||||
// Only collect doc comments from duplicate declarations once.
|
||||
const tags: JSDocTagInfo[] = [];
|
||||
forEachUnique(declarations, declaration => {
|
||||
|
||||
@@ -309,15 +309,15 @@ namespace ts {
|
||||
class SymbolObject implements Symbol {
|
||||
flags: SymbolFlags;
|
||||
name: string;
|
||||
declarations: Declaration[];
|
||||
declarations?: Declaration[];
|
||||
|
||||
// Undefined is used to indicate the value has not been computed. If, after computing, the
|
||||
// symbol has no doc comment, then the empty string will be returned.
|
||||
documentationComment: SymbolDisplayPart[];
|
||||
// symbol has no doc comment, then the empty array will be returned.
|
||||
documentationComment?: SymbolDisplayPart[];
|
||||
|
||||
// Undefined is used to indicate the value has not been computed. If, after computing, the
|
||||
// symbol has no JSDoc tags, then the empty array will be returned.
|
||||
tags: JSDocTagInfo[];
|
||||
tags?: JSDocTagInfo[];
|
||||
|
||||
constructor(flags: SymbolFlags, name: string) {
|
||||
this.flags = flags;
|
||||
@@ -332,7 +332,7 @@ namespace ts {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
getDeclarations(): Declaration[] {
|
||||
getDeclarations(): Declaration[] | undefined {
|
||||
return this.declarations;
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ namespace ts {
|
||||
flags: TypeFlags;
|
||||
objectFlags?: ObjectFlags;
|
||||
id: number;
|
||||
symbol: Symbol;
|
||||
symbol?: Symbol;
|
||||
constructor(checker: TypeChecker, flags: TypeFlags) {
|
||||
this.checker = checker;
|
||||
this.flags = flags;
|
||||
@@ -391,13 +391,13 @@ namespace ts {
|
||||
getFlags(): TypeFlags {
|
||||
return this.flags;
|
||||
}
|
||||
getSymbol(): Symbol {
|
||||
getSymbol(): Symbol | undefined {
|
||||
return this.symbol;
|
||||
}
|
||||
getProperties(): Symbol[] {
|
||||
return this.checker.getPropertiesOfType(this);
|
||||
}
|
||||
getProperty(propertyName: string): Symbol {
|
||||
getProperty(propertyName: string): Symbol | undefined {
|
||||
return this.checker.getPropertyOfType(this, propertyName);
|
||||
}
|
||||
getApparentProperties(): Symbol[] {
|
||||
@@ -409,13 +409,13 @@ namespace ts {
|
||||
getConstructSignatures(): Signature[] {
|
||||
return this.checker.getSignaturesOfType(this, SignatureKind.Construct);
|
||||
}
|
||||
getStringIndexType(): Type {
|
||||
getStringIndexType(): Type | undefined {
|
||||
return this.checker.getIndexTypeOfType(this, IndexKind.String);
|
||||
}
|
||||
getNumberIndexType(): Type {
|
||||
getNumberIndexType(): Type | undefined {
|
||||
return this.checker.getIndexTypeOfType(this, IndexKind.Number);
|
||||
}
|
||||
getBaseTypes(): BaseType[] {
|
||||
getBaseTypes(): BaseType[] | undefined {
|
||||
return this.flags & TypeFlags.Object && this.objectFlags & (ObjectFlags.Class | ObjectFlags.Interface)
|
||||
? this.checker.getBaseTypes(<InterfaceType><Type>this)
|
||||
: undefined;
|
||||
@@ -428,7 +428,7 @@ namespace ts {
|
||||
class SignatureObject implements Signature {
|
||||
checker: TypeChecker;
|
||||
declaration: SignatureDeclaration;
|
||||
typeParameters: TypeParameter[];
|
||||
typeParameters?: TypeParameter[];
|
||||
parameters: Symbol[];
|
||||
thisParameter: Symbol;
|
||||
resolvedReturnType: Type;
|
||||
@@ -438,12 +438,12 @@ namespace ts {
|
||||
hasLiteralTypes: boolean;
|
||||
|
||||
// Undefined is used to indicate the value has not been computed. If, after computing, the
|
||||
// symbol has no doc comment, then the empty string will be returned.
|
||||
documentationComment: SymbolDisplayPart[];
|
||||
// symbol has no doc comment, then the empty array will be returned.
|
||||
documentationComment?: SymbolDisplayPart[];
|
||||
|
||||
// Undefined is used to indicate the value has not been computed. If, after computing, the
|
||||
// symbol has no doc comment, then the empty array will be returned.
|
||||
jsDocTags: JSDocTagInfo[];
|
||||
jsDocTags?: JSDocTagInfo[];
|
||||
|
||||
constructor(checker: TypeChecker) {
|
||||
this.checker = checker;
|
||||
@@ -451,7 +451,7 @@ namespace ts {
|
||||
getDeclaration(): SignatureDeclaration {
|
||||
return this.declaration;
|
||||
}
|
||||
getTypeParameters(): TypeParameter[] {
|
||||
getTypeParameters(): TypeParameter[] | undefined {
|
||||
return this.typeParameters;
|
||||
}
|
||||
getParameters(): Symbol[] {
|
||||
|
||||
@@ -19,34 +19,34 @@ namespace ts {
|
||||
getFirstToken(sourceFile?: SourceFile): Node;
|
||||
getLastToken(sourceFile?: SourceFile): Node;
|
||||
// See ts.forEachChild for documentation.
|
||||
forEachChild<T>(cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
|
||||
forEachChild<T>(cbNode: (node: Node) => T | undefined, cbNodeArray?: (nodes: NodeArray<Node>) => T | undefined): T | undefined;
|
||||
}
|
||||
|
||||
export interface Symbol {
|
||||
getFlags(): SymbolFlags;
|
||||
getName(): string;
|
||||
getDeclarations(): Declaration[];
|
||||
getDeclarations(): Declaration[] | undefined;
|
||||
getDocumentationComment(): SymbolDisplayPart[];
|
||||
getJsDocTags(): JSDocTagInfo[];
|
||||
}
|
||||
|
||||
export interface Type {
|
||||
getFlags(): TypeFlags;
|
||||
getSymbol(): Symbol;
|
||||
getSymbol(): Symbol | undefined;
|
||||
getProperties(): Symbol[];
|
||||
getProperty(propertyName: string): Symbol;
|
||||
getProperty(propertyName: string): Symbol | undefined;
|
||||
getApparentProperties(): Symbol[];
|
||||
getCallSignatures(): Signature[];
|
||||
getConstructSignatures(): Signature[];
|
||||
getStringIndexType(): Type;
|
||||
getNumberIndexType(): Type;
|
||||
getBaseTypes(): BaseType[];
|
||||
getStringIndexType(): Type | undefined;
|
||||
getNumberIndexType(): Type | undefined;
|
||||
getBaseTypes(): BaseType[] | undefined;
|
||||
getNonNullableType(): Type;
|
||||
}
|
||||
|
||||
export interface Signature {
|
||||
getDeclaration(): SignatureDeclaration;
|
||||
getTypeParameters(): TypeParameter[];
|
||||
getTypeParameters(): TypeParameter[] | undefined;
|
||||
getParameters(): Symbol[];
|
||||
getReturnType(): Type;
|
||||
getDocumentationComment(): SymbolDisplayPart[];
|
||||
|
||||
Reference in New Issue
Block a user