Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for TS 3.7 upgrade #47683

Merged
merged 1 commit into from
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/code/model/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { DetailSymbolInformation } from '@elastic/lsp-extension';
import { IRange } from 'monaco-editor';

import { DiffKind } from '../common/git_diff';
import { Repository, SourceHit } from '../model';
import { Repository } from '../model';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ There was a bug in TS that you could import something and have a different export with the same name, which has been fixed in 3.7, why this wouldn't work anymore. In this specific case we can simply remove SourceHit since it was not used in that file at all (but actually just declared later in this file).

import { RepositoryUri } from './repository';

export interface Document {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/code/public/reducers/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const search = handleActions<SearchState, SearchPayload>(
{
[String(changeSearchScope)]: (state: SearchState, action: Action<SearchScope>) =>
produce<SearchState>(state, draft => {
if (Object.values(SearchScope).includes(action.payload)) {
if (action.payload && Object.values(SearchScope).includes(action.payload)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ I have honestly no idea why this didn't already fail earlier. Since action.payload can also be undefined, you need to check that it's not undefined before calling includes (at least in 3.7 it's failing now).

draft.scope = action.payload!;
} else {
draft.scope = SearchScope.DEFAULT;
Expand Down