forked from benthemonkey/source-map
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add types for path imports #13
Merged
+101
−84
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,115 @@ | ||
export interface StartOfSourceMap { | ||
file?: string; | ||
sourceRoot?: string; | ||
} | ||
declare module 'source-map-js' { | ||
export interface StartOfSourceMap { | ||
file?: string; | ||
sourceRoot?: string; | ||
} | ||
|
||
export interface RawSourceMap extends StartOfSourceMap { | ||
version: string; | ||
sources: string[]; | ||
names: string[]; | ||
sourcesContent?: string[]; | ||
mappings: string; | ||
} | ||
export interface RawSourceMap extends StartOfSourceMap { | ||
version: string; | ||
sources: string[]; | ||
names: string[]; | ||
sourcesContent?: string[]; | ||
mappings: string; | ||
} | ||
|
||
export interface Position { | ||
line: number; | ||
column: number; | ||
} | ||
export interface Position { | ||
line: number; | ||
column: number; | ||
} | ||
|
||
export interface LineRange extends Position { | ||
lastColumn: number; | ||
} | ||
export interface LineRange extends Position { | ||
lastColumn: number; | ||
} | ||
|
||
export interface FindPosition extends Position { | ||
// SourceMapConsumer.GREATEST_LOWER_BOUND or SourceMapConsumer.LEAST_UPPER_BOUND | ||
bias?: number; | ||
} | ||
export interface FindPosition extends Position { | ||
// SourceMapConsumer.GREATEST_LOWER_BOUND or SourceMapConsumer.LEAST_UPPER_BOUND | ||
bias?: number; | ||
} | ||
|
||
export interface SourceFindPosition extends FindPosition { | ||
source: string; | ||
} | ||
export interface SourceFindPosition extends FindPosition { | ||
source: string; | ||
} | ||
|
||
export interface MappedPosition extends Position { | ||
source: string; | ||
name?: string; | ||
} | ||
export interface MappedPosition extends Position { | ||
source: string; | ||
name?: string; | ||
} | ||
|
||
export interface MappingItem { | ||
source: string; | ||
generatedLine: number; | ||
generatedColumn: number; | ||
originalLine: number; | ||
originalColumn: number; | ||
name: string; | ||
} | ||
export interface MappingItem { | ||
source: string; | ||
generatedLine: number; | ||
generatedColumn: number; | ||
originalLine: number; | ||
originalColumn: number; | ||
name: string; | ||
} | ||
|
||
export class SourceMapConsumer { | ||
static GENERATED_ORDER: number; | ||
static ORIGINAL_ORDER: number; | ||
|
||
static GREATEST_LOWER_BOUND: number; | ||
static LEAST_UPPER_BOUND: number; | ||
|
||
constructor(rawSourceMap: RawSourceMap); | ||
computeColumnSpans(): void; | ||
originalPositionFor(generatedPosition: FindPosition): MappedPosition; | ||
generatedPositionFor(originalPosition: SourceFindPosition): LineRange; | ||
allGeneratedPositionsFor(originalPosition: MappedPosition): Position[]; | ||
hasContentsOfAllSources(): boolean; | ||
sourceContentFor(source: string, returnNullOnMissing?: boolean): string; | ||
eachMapping(callback: (mapping: MappingItem) => void, context?: any, order?: number): void; | ||
} | ||
export class SourceMapConsumer { | ||
static GENERATED_ORDER: number; | ||
static ORIGINAL_ORDER: number; | ||
|
||
static GREATEST_LOWER_BOUND: number; | ||
static LEAST_UPPER_BOUND: number; | ||
|
||
constructor(rawSourceMap: RawSourceMap); | ||
computeColumnSpans(): void; | ||
originalPositionFor(generatedPosition: FindPosition): MappedPosition; | ||
generatedPositionFor(originalPosition: SourceFindPosition): LineRange; | ||
allGeneratedPositionsFor(originalPosition: MappedPosition): Position[]; | ||
hasContentsOfAllSources(): boolean; | ||
sourceContentFor(source: string, returnNullOnMissing?: boolean): string; | ||
eachMapping(callback: (mapping: MappingItem) => void, context?: any, order?: number): void; | ||
} | ||
|
||
export interface Mapping { | ||
generated: Position; | ||
original: Position; | ||
source: string; | ||
name?: string; | ||
} | ||
|
||
export class SourceMapGenerator { | ||
constructor(startOfSourceMap?: StartOfSourceMap); | ||
static fromSourceMap(sourceMapConsumer: SourceMapConsumer): SourceMapGenerator; | ||
addMapping(mapping: Mapping): void; | ||
setSourceContent(sourceFile: string, sourceContent: string): void; | ||
applySourceMap(sourceMapConsumer: SourceMapConsumer, sourceFile?: string, sourceMapPath?: string): void; | ||
toString(): string; | ||
} | ||
|
||
export interface CodeWithSourceMap { | ||
code: string; | ||
map: SourceMapGenerator; | ||
} | ||
|
||
export interface Mapping { | ||
generated: Position; | ||
original: Position; | ||
source: string; | ||
name?: string; | ||
export class SourceNode { | ||
constructor(); | ||
constructor(line: number, column: number, source: string); | ||
constructor(line: number, column: number, source: string, chunk?: string, name?: string); | ||
static fromStringWithSourceMap(code: string, sourceMapConsumer: SourceMapConsumer, relativePath?: string): SourceNode; | ||
add(chunk: string): void; | ||
prepend(chunk: string): void; | ||
setSourceContent(sourceFile: string, sourceContent: string): void; | ||
walk(fn: (chunk: string, mapping: MappedPosition) => void): void; | ||
walkSourceContents(fn: (file: string, content: string) => void): void; | ||
join(sep: string): SourceNode; | ||
replaceRight(pattern: string, replacement: string): SourceNode; | ||
toString(): string; | ||
toStringWithSourceMap(startOfSourceMap?: StartOfSourceMap): CodeWithSourceMap; | ||
} | ||
} | ||
|
||
export class SourceMapGenerator { | ||
constructor(startOfSourceMap?: StartOfSourceMap); | ||
static fromSourceMap(sourceMapConsumer: SourceMapConsumer): SourceMapGenerator; | ||
addMapping(mapping: Mapping): void; | ||
setSourceContent(sourceFile: string, sourceContent: string): void; | ||
applySourceMap(sourceMapConsumer: SourceMapConsumer, sourceFile?: string, sourceMapPath?: string): void; | ||
toString(): string; | ||
declare module 'source-map-js/lib/source-map-generator' { | ||
import { SourceMapGenerator } from 'source-map-js' | ||
export { SourceMapGenerator } | ||
} | ||
|
||
export interface CodeWithSourceMap { | ||
code: string; | ||
map: SourceMapGenerator; | ||
declare module 'source-map-js/lib/source-map-consumer' { | ||
import { SourceMapConsumer } from 'source-map-js' | ||
export { SourceMapConsumer } | ||
} | ||
|
||
export class SourceNode { | ||
constructor(); | ||
constructor(line: number, column: number, source: string); | ||
constructor(line: number, column: number, source: string, chunk?: string, name?: string); | ||
static fromStringWithSourceMap(code: string, sourceMapConsumer: SourceMapConsumer, relativePath?: string): SourceNode; | ||
add(chunk: string): void; | ||
prepend(chunk: string): void; | ||
setSourceContent(sourceFile: string, sourceContent: string): void; | ||
walk(fn: (chunk: string, mapping: MappedPosition) => void): void; | ||
walkSourceContents(fn: (file: string, content: string) => void): void; | ||
join(sep: string): SourceNode; | ||
replaceRight(pattern: string, replacement: string): SourceNode; | ||
toString(): string; | ||
toStringWithSourceMap(startOfSourceMap?: StartOfSourceMap): CodeWithSourceMap; | ||
declare module 'source-map-js/lib/source-node' { | ||
import { SourceNode } from 'source-map-js' | ||
export { SourceNode } | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
declare module
syntax is only for stubbing third-party modules. To declare modules in the current package, you should just write a separate.d.ts
file for each.js
file. This fixes TS2306 “File…/source-map.d.ts
is not a module” errors.