const im = document.querySelector('.im')
im.onclick = () => {
if (im.src.endsWith('img/sunny.png')) {
im.src = 'img/moon.png';
console.log(im.src)
} else {
im.src = 'img/sunny.png';
}
}
Ну а вообще лучше просто в отдельную переменную завести состояние и проверять его export const TypographyType = {
[TypographyTypeStyle.h1]: 'h1',
[TypographyTypeStyle.h2]: 'h2',
[TypographyTypeStyle.h3]: 'h3',
[TypographyTypeStyle.h4]: 'h4',
[TypographyTypeStyle.p1]: 'p',
[TypographyTypeStyle.p2]: 'p',
} as const;
type TestResult<T extends string[] | CustomClass[]> = T extends CustomClass[] ? T : void;
function test<T extends string[] | CustomClass[]>(data: T): TestResult<T> {
if (data[0] instanceof CustomClass) {
return data as TestResult<T>;
}
return undefined as TestResult<T>;
}
const m = matchMedia('(min-width: 1000px)');
m.addListener(() => {
// Ваш скрипт тут
});
Ctrl+Shift+P
или Cmd+Shift+P
на маке)workbench.action.editor.changeLanguageMode
и по умолчанию к ней уже привязано сочетание Ctrl+K M
(сначала нажимаете Ctrl+K
и потом сразу M
), но Вы конечно же можете его сменить 'get' | 'set'
), методы (функциональный тип на инстансе) и static методы (функциональный тип на самом классе).declare class ViewHack {
getPosOnScale(currentPos: number): number;
}
describe('some method', () => {
test('should return smth', () => {
const view = new View('range-slider', settings);
jest.spyOn(view as unknown as ViewHack, 'getPosOnScale').mockReturnValue(100);
});
});