mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-02 14:31:31 +01:00
Emmet strict mode move, part 2 (#37840)
Continue moving emmet extension to strict mode. This change does the following: - Remove jsdoc types. These are unused in ts files and can easily get out of date - Annotate when something can return undefined - Add null checks for when something can be undefined - Add explicit types when something can be any
This commit is contained in:
@@ -15,9 +15,8 @@ const reAbsolute = /^\/+/;
|
||||
/**
|
||||
* Locates given `filePath` on user’s file system and returns absolute path to it.
|
||||
* This method expects either URL, or relative/absolute path to resource
|
||||
* @param {String} basePath Base path to use if filePath is not absoulte
|
||||
* @param {String} filePath File to locate.
|
||||
* @return {Promise}
|
||||
* @param basePath Base path to use if filePath is not absoulte
|
||||
* @param filePath File to locate.
|
||||
*/
|
||||
export function locateFile(base: string, filePath: string): Promise<string> {
|
||||
if (/^\w+:/.test(filePath)) {
|
||||
@@ -34,26 +33,20 @@ export function locateFile(base: string, filePath: string): Promise<string> {
|
||||
|
||||
/**
|
||||
* Resolves relative file path
|
||||
* @param {TextEditor|String} base
|
||||
* @param {String} filePath
|
||||
* @return {Promise}
|
||||
*/
|
||||
function resolveRelative(basePath, filePath): Promise<string> {
|
||||
function resolveRelative(basePath: string, filePath: string): Promise<string> {
|
||||
return tryFile(path.resolve(basePath, filePath));
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves absolute file path agaist given editor: tries to find file in every
|
||||
* parent of editor’s file
|
||||
* @param {TextEditor|String} base
|
||||
* @param {String} filePath
|
||||
* @return {Promise}
|
||||
*/
|
||||
function resolveAbsolute(basePath, filePath): Promise<string> {
|
||||
function resolveAbsolute(basePath: string, filePath: string): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
filePath = filePath.replace(reAbsolute, '');
|
||||
|
||||
const next = ctx => {
|
||||
const next = (ctx: string) => {
|
||||
tryFile(path.resolve(ctx, filePath))
|
||||
.then(resolve, err => {
|
||||
const dir = path.dirname(ctx);
|
||||
@@ -71,10 +64,8 @@ function resolveAbsolute(basePath, filePath): Promise<string> {
|
||||
|
||||
/**
|
||||
* Check if given file exists and it’s a file, not directory
|
||||
* @param {String} file
|
||||
* @return {Promise}
|
||||
*/
|
||||
function tryFile(file): Promise<string> {
|
||||
function tryFile(file: string): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.stat(file, (err, stat) => {
|
||||
if (err) {
|
||||
|
||||
Reference in New Issue
Block a user