Add more to strict nulls (#11871)

* add more to strict nulls

* maintain error handling properly

* fix lint
This commit is contained in:
Anthony Dresser
2020-08-19 18:38:34 -07:00
committed by GitHub
parent 69a96a7d5d
commit 9327624930
22 changed files with 393 additions and 369 deletions

View File

@@ -13,15 +13,17 @@ const languageRegistry = Registry.as<ILanguageAssociationRegistry>(ILanguageAsso
export function doHandleUpgrade(editor?: EditorInput): EditorInput | undefined {
if (editor instanceof UntitledTextEditorInput || editor instanceof FileEditorInput) {
let language: string;
let language: string | undefined;
if (editor instanceof UntitledTextEditorInput) {
language = editor.getMode();
} else {
editor.getPreferredMode();
language = editor.getPreferredMode();
}
const association = languageRegistry.getAssociationForLanguage(language);
if (association && association.syncConvertinput) {
return association.syncConvertinput(editor);
if (language) {
const association = languageRegistry.getAssociationForLanguage(language);
if (association && association.syncConvertinput) {
return association.syncConvertinput(editor);
}
}
}
return editor;

View File

@@ -25,8 +25,8 @@ type ILanguageAssociationSignature<Services extends BrandedService[]> = new (...
export interface ILanguageAssociationRegistry {
registerLanguageAssociation<Services extends BrandedService[]>(languages: string[], contribution: ILanguageAssociationSignature<Services>, isDefault?: boolean): IDisposable;
getAssociationForLanguage(language: string): ILanguageAssociation;
readonly defaultAssociation: [string, ILanguageAssociation];
getAssociationForLanguage(language: string): ILanguageAssociation | undefined;
readonly defaultAssociation: [string, ILanguageAssociation] | undefined;
/**
* Starts the registry by providing the required services.