mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
Fix strict null errors in api
This commit is contained in:
+2
-2
@@ -115,7 +115,7 @@ function getAllTopLevelDeclarations(sourceFile) {
|
||||
function getTopLevelDeclaration(sourceFile, typeName) {
|
||||
var result = null;
|
||||
visitTopLevelDeclarations(sourceFile, function (node) {
|
||||
if (isDeclaration(node)) {
|
||||
if (isDeclaration(node) && node.name) {
|
||||
if (node.name.text === typeName) {
|
||||
result = node;
|
||||
return true /*stop*/;
|
||||
@@ -308,7 +308,7 @@ function generateDeclarationFile(out, inputFiles, recipe) {
|
||||
typesToExcludeArr_1.push(typeName);
|
||||
});
|
||||
getAllTopLevelDeclarations(sourceFile_2).forEach(function (declaration) {
|
||||
if (isDeclaration(declaration)) {
|
||||
if (isDeclaration(declaration) && declaration.name) {
|
||||
if (typesToExcludeMap_1[declaration.name.text]) {
|
||||
return;
|
||||
}
|
||||
|
||||
+11
-11
@@ -32,7 +32,7 @@ function moduleIdToPath(out: string, moduleId: string): string {
|
||||
}
|
||||
|
||||
let SOURCE_FILE_MAP: { [moduleId: string]: ts.SourceFile; } = {};
|
||||
function getSourceFile(out: string, inputFiles: { [file: string]: string; }, moduleId: string): ts.SourceFile {
|
||||
function getSourceFile(out: string, inputFiles: { [file: string]: string; }, moduleId: string): ts.SourceFile | null {
|
||||
if (!SOURCE_FILE_MAP[moduleId]) {
|
||||
let filePath = path.normalize(moduleIdToPath(out, moduleId));
|
||||
|
||||
@@ -128,10 +128,10 @@ function getAllTopLevelDeclarations(sourceFile: ts.SourceFile): TSTopLevelDeclar
|
||||
}
|
||||
|
||||
|
||||
function getTopLevelDeclaration(sourceFile: ts.SourceFile, typeName: string): TSTopLevelDeclare {
|
||||
let result: TSTopLevelDeclare = null;
|
||||
function getTopLevelDeclaration(sourceFile: ts.SourceFile, typeName: string): TSTopLevelDeclare | null {
|
||||
let result: TSTopLevelDeclare | null = null;
|
||||
visitTopLevelDeclarations(sourceFile, (node) => {
|
||||
if (isDeclaration(node)) {
|
||||
if (isDeclaration(node) && node.name) {
|
||||
if (node.name.text === typeName) {
|
||||
result = node;
|
||||
return true /*stop*/;
|
||||
@@ -153,7 +153,7 @@ function getNodeText(sourceFile: ts.SourceFile, node: { pos: number; end: number
|
||||
return sourceFile.getFullText().substring(node.pos, node.end);
|
||||
}
|
||||
|
||||
function hasModifier(modifiers: ts.NodeArray<ts.Modifier>, kind: ts.SyntaxKind): boolean {
|
||||
function hasModifier(modifiers: ts.NodeArray<ts.Modifier> | undefined, kind: ts.SyntaxKind): boolean {
|
||||
if (modifiers) {
|
||||
for (let i = 0; i < modifiers.length; i++) {
|
||||
let mod = modifiers[i];
|
||||
@@ -188,7 +188,7 @@ function getMassagedTopLevelDeclarationText(sourceFile: ts.SourceFile, declarati
|
||||
const staticTypeName = (
|
||||
isDefaultExport(interfaceDeclaration)
|
||||
? `${importName}.default`
|
||||
: `${importName}.${declaration.name.text}`
|
||||
: `${importName}.${declaration.name!.text}`
|
||||
);
|
||||
|
||||
let instanceTypeName = staticTypeName;
|
||||
@@ -307,7 +307,7 @@ function generateDeclarationFile(out: string, inputFiles: { [file: string]: stri
|
||||
if (m1) {
|
||||
CURRENT_PROCESSING_RULE = line;
|
||||
let moduleId = m1[1];
|
||||
let sourceFile = getSourceFile(out, inputFiles, moduleId);
|
||||
const sourceFile = getSourceFile(out, inputFiles, moduleId);
|
||||
if (!sourceFile) {
|
||||
return;
|
||||
}
|
||||
@@ -336,7 +336,7 @@ function generateDeclarationFile(out: string, inputFiles: { [file: string]: stri
|
||||
if (m2) {
|
||||
CURRENT_PROCESSING_RULE = line;
|
||||
let moduleId = m2[1];
|
||||
let sourceFile = getSourceFile(out, inputFiles, moduleId);
|
||||
const sourceFile = getSourceFile(out, inputFiles, moduleId);
|
||||
if (!sourceFile) {
|
||||
return;
|
||||
}
|
||||
@@ -358,7 +358,7 @@ function generateDeclarationFile(out: string, inputFiles: { [file: string]: stri
|
||||
});
|
||||
|
||||
getAllTopLevelDeclarations(sourceFile).forEach((declaration) => {
|
||||
if (isDeclaration(declaration)) {
|
||||
if (isDeclaration(declaration) && declaration.name) {
|
||||
if (typesToExcludeMap[declaration.name.text]) {
|
||||
return;
|
||||
}
|
||||
@@ -395,7 +395,7 @@ function generateDeclarationFile(out: string, inputFiles: { [file: string]: stri
|
||||
function getIncludesInRecipe(): string[] {
|
||||
let recipe = fs.readFileSync(RECIPE_PATH).toString();
|
||||
let lines = recipe.split(/\r\n|\n|\r/);
|
||||
let result = [];
|
||||
let result: string[] = [];
|
||||
|
||||
lines.forEach(line => {
|
||||
|
||||
@@ -478,7 +478,7 @@ class TypeScriptLanguageServiceHost implements ts.LanguageServiceHost {
|
||||
}
|
||||
getScriptFileNames(): string[] {
|
||||
return (
|
||||
[]
|
||||
([] as string[])
|
||||
.concat(Object.keys(this._libs))
|
||||
.concat(Object.keys(this._files))
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user