mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-03 15:01:57 +01:00
Start moving emmet extension to strict mode (#37740)
* Start moving emmet to strict mode First part of moving the emmet extension to strict mode TypeScript. This change focuses on adding annotations when things can be undefined and removing jsdoc type comments * Fix a few more errors * Fix compile errors * Tiny updates
This commit is contained in:
@@ -19,20 +19,16 @@ const reUrl = /^https?:/;
|
||||
/**
|
||||
* Get size of given image file. Supports files from local filesystem,
|
||||
* as well as URLs
|
||||
* @param {String} file Path to local file or URL
|
||||
* @return {Promise}
|
||||
*/
|
||||
export function getImageSize(file) {
|
||||
export function getImageSize(file: string) {
|
||||
file = file.replace(/^file:\/\//, '');
|
||||
return reUrl.test(file) ? getImageSizeFromURL(file) : getImageSizeFromFile(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image size from file on local file system
|
||||
* @param {String} file
|
||||
* @return {Promise}
|
||||
*/
|
||||
function getImageSizeFromFile(file) {
|
||||
function getImageSizeFromFile(file: string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const isDataUrl = file.match(/^data:.+?;base64,/);
|
||||
|
||||
@@ -46,7 +42,7 @@ function getImageSizeFromFile(file) {
|
||||
}
|
||||
}
|
||||
|
||||
sizeOf(file, (err, size) => {
|
||||
sizeOf(file, (err: any, size: any) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
@@ -58,15 +54,13 @@ function getImageSizeFromFile(file) {
|
||||
|
||||
/**
|
||||
* Get image size from given remove URL
|
||||
* @param {String} url
|
||||
* @return {Promise}
|
||||
*/
|
||||
function getImageSizeFromURL(url) {
|
||||
function getImageSizeFromURL(urlStr: string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
url = parseUrl(url);
|
||||
const url = parseUrl(urlStr);
|
||||
const getTransport = url.protocol === 'https:' ? https.get : http.get;
|
||||
|
||||
getTransport(url, resp => {
|
||||
getTransport(url as any, resp => {
|
||||
const chunks = [];
|
||||
let bufSize = 0;
|
||||
|
||||
@@ -102,11 +96,8 @@ function getImageSizeFromURL(url) {
|
||||
/**
|
||||
* Returns size object for given file name. If file name contains `@Nx` token,
|
||||
* the final dimentions will be downscaled by N
|
||||
* @param {String} fileName
|
||||
* @param {Object} size
|
||||
* @return {Object}
|
||||
*/
|
||||
function sizeForFileName(fileName, size) {
|
||||
function sizeForFileName(fileName: string, size: any) {
|
||||
const m = fileName.match(/@(\d+)x\./);
|
||||
const scale = m ? +m[1] : 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user