mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[enhanced-resolve] update signature of synchronous calls (#16429)
* [enhanced-resolve] update signature of synchronous calls, return string and not ResolveResult * [enhanced-resolve] Add my name to the definition * Fix recommended changes * onlyModule is optional Fixed following recommendation of @e-cloud
This commit is contained in:
parent
887a4e87b0
commit
f7636dec13
35
types/enhanced-resolve/index.d.ts
vendored
35
types/enhanced-resolve/index.d.ts
vendored
@ -1,6 +1,6 @@
|
||||
// Type definitions for enhanced-resolve v3.0.0
|
||||
// Project: http://github.com/webpack/enhanced-resolve.git
|
||||
// Definitions by: e-cloud <https://github.com/e-cloud>
|
||||
// Definitions by: e-cloud <https://github.com/e-cloud>, Onigoetz <https://github.com/onigoetz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
@ -8,7 +8,6 @@
|
||||
|
||||
import fs = require('fs');
|
||||
import {
|
||||
ResolveResult,
|
||||
LoggingCallbackWrapper,
|
||||
ResolverRequest,
|
||||
ResolveContext,
|
||||
@ -19,31 +18,35 @@ import Resolver = require('./lib/Resolver');
|
||||
import Tapable = require('tapable');
|
||||
|
||||
declare namespace Resolve {
|
||||
function sync(path: string, request: string): ResolveResult;
|
||||
function sync(context: ResolveContext, path: string, request: string): ResolveResult;
|
||||
function sync(path: string, request: string): string;
|
||||
function sync(context: ResolveContext, path: string, request: string): string;
|
||||
|
||||
function context(path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
function context(context: ResolveContext, path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
|
||||
namespace context {
|
||||
function sync(path: string, request: string): ResolveResult;
|
||||
function sync(context: ResolveContext, path: string, request: string): ResolveResult;
|
||||
function sync(path: string, request: string): string;
|
||||
function sync(context: ResolveContext, path: string, request: string): string;
|
||||
}
|
||||
|
||||
function loader(path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
function loader(context: ResolveContext, path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
|
||||
namespace context {
|
||||
function sync(path: string, request: string): ResolveResult;
|
||||
function sync(context: ResolveContext, path: string, request: string): ResolveResult;
|
||||
namespace loader {
|
||||
function sync(path: string, request: string): string;
|
||||
function sync(context: ResolveContext, path: string, request: string): string;
|
||||
}
|
||||
|
||||
function create(path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
function create(context: ResolveContext, path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
function create(options: ResolverFactory.ResolverOption): {
|
||||
(path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
(context: ResolveContext, path: string, request: string, callback: LoggingCallbackWrapper): void;
|
||||
}
|
||||
|
||||
export namespace create {
|
||||
function sync(path: string, request: string): ResolveResult;
|
||||
function sync(context: ResolveContext, path: string, request: string): ResolveResult;
|
||||
function sync(options: ResolverFactory.ResolverOption): {
|
||||
(path: string, request: string): string;
|
||||
(context: ResolveContext, path: string, request: string): string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace ResolverFactory {
|
||||
@ -54,8 +57,8 @@ declare namespace Resolve {
|
||||
descriptionFiles?: string[];
|
||||
enforceExtension?: boolean;
|
||||
enforceModuleExtension?: boolean;
|
||||
extensions: string[];
|
||||
fileSystem: AbstractInputFileSystem;
|
||||
extensions?: string[];
|
||||
fileSystem?: AbstractInputFileSystem;
|
||||
mainFields?: string[];
|
||||
mainFiles?: string[];
|
||||
moduleExtensions?: string[];
|
||||
@ -70,7 +73,7 @@ declare namespace Resolve {
|
||||
interface AliasItem {
|
||||
alias: string;
|
||||
name: string;
|
||||
onlyModule: boolean;
|
||||
onlyModule?: boolean;
|
||||
}
|
||||
function createResolver(options: ResolverOption): Resolver;
|
||||
}
|
||||
|
||||
3
types/enhanced-resolve/lib/Resolver.d.ts
vendored
3
types/enhanced-resolve/lib/Resolver.d.ts
vendored
@ -2,7 +2,6 @@
|
||||
import Tapable = require('tapable');
|
||||
import {
|
||||
ResolveParseResult,
|
||||
ResolveResult,
|
||||
ResolverRequest,
|
||||
LoggingCallbackWrapper,
|
||||
AbstractInputFileSystem,
|
||||
@ -14,7 +13,7 @@ declare class Resolver extends Tapable {
|
||||
|
||||
constructor(fileSystem: AbstractInputFileSystem);
|
||||
|
||||
resolveSync(context: ResolveContext, path: string, request: string): ResolveResult;
|
||||
resolveSync(context: ResolveContext, path: string, request: string): string;
|
||||
|
||||
resolve(context: ResolveContext, path: string, request: string, callback: LoggingCallbackWrapper): any;
|
||||
|
||||
|
||||
5
types/enhanced-resolve/lib/common-types.d.ts
vendored
5
types/enhanced-resolve/lib/common-types.d.ts
vendored
@ -23,11 +23,6 @@ export interface ResolveContext {
|
||||
issuer?: string;
|
||||
}
|
||||
|
||||
export interface ResolveResult {
|
||||
path: boolean | string;
|
||||
query: string;
|
||||
}
|
||||
|
||||
export interface ResolverRequest {
|
||||
context: ResolveContext;
|
||||
descriptionFileData?: DescriptionFileData;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import resolve = require('enhanced-resolve');
|
||||
import { ResolveResult, AbstractInputFileSystem } from 'enhanced-resolve/lib/common-types'
|
||||
import { AbstractInputFileSystem } from 'enhanced-resolve/lib/common-types'
|
||||
import Resolver = require('enhanced-resolve/lib/Resolver')
|
||||
|
||||
resolve('lib', 'string', function (err) { });
|
||||
@ -20,19 +20,30 @@ const nfs = new resolve.NodeJsInputFileSystem();
|
||||
|
||||
const cfs = new resolve.CachedInputFileSystem(nfs, 4);
|
||||
|
||||
let result: ResolveResult
|
||||
let result: string
|
||||
|
||||
result = resolve.sync(context, 'path', 'string');
|
||||
result = resolve.sync('path', 'string');
|
||||
|
||||
|
||||
// Context
|
||||
|
||||
resolve.context('lib', 'string', function (err) { });
|
||||
resolve.context(context, 'path', 'string', function () { });
|
||||
|
||||
result = resolve.context.sync(context, 'path', 'string');
|
||||
result = resolve.context.sync('path', 'string');
|
||||
|
||||
resolve.create('lib', 'string', function (err) { });
|
||||
resolve.create(context, 'path', 'string', function () { });
|
||||
// Loader
|
||||
|
||||
result = resolve.create.sync(context, 'path', 'string');
|
||||
result = resolve.create.sync('path', 'string');
|
||||
resolve.loader('lib', 'string', function (err) { });
|
||||
resolve.loader(context, 'path', 'string', function () { });
|
||||
|
||||
result = resolve.loader.sync(context, 'path', 'string');
|
||||
result = resolve.loader.sync('path', 'string');
|
||||
|
||||
// Create
|
||||
|
||||
resolve.create({extensions: [".js", ".json", ".node"]})(context, 'path', 'string', function () { });
|
||||
|
||||
result = resolve.create.sync({mainFields: ["loader", "main"]})(context, 'path', 'string');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user