Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Add opt-in declaration source map generation so editors can resolve go-to-definition from generated typings to the original source file.",
"type": "minor",
"packageName": "@rushstack/heft-localization-typings-plugin"
}
],
"packageName": "@rushstack/heft-localization-typings-plugin",
"email": "mdelgaudio_microsoft@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/heft-sass-plugin",
"comment": "Add an opt-in \"generateDeclarationMaps\" option that emits a \".d.ts.map\" beside each generated typings file, so that \"go to definition\" on a CSS module class resolves to the rule in the stylesheet instead of the generated typings.",
"type": "minor"
}
],
"packageName": "@rushstack/heft-sass-plugin"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Add opt-in declaration source map generation so editors can resolve go-to-definition from generated typings to the original source file.",
"type": "minor",
"packageName": "@rushstack/localization-utilities"
}
],
"packageName": "@rushstack/localization-utilities",
"email": "mdelgaudio_microsoft@users.noreply.github.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/typings-generator",
"comment": "Support multiple sources in \"serializeDeclarationMap\", and add \"decodeMappings\" and \"originalPositionFor\" so that generators which compile their input can translate positions back to the original file.",
"type": "minor"
}
],
"packageName": "@rushstack/typings-generator"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Add opt-in declaration source map generation so editors can resolve go-to-definition from generated typings to the original source file.",
"type": "minor",
"packageName": "@rushstack/typings-generator"
}
],
"packageName": "@rushstack/typings-generator",
"email": "mdelgaudio_microsoft@users.noreply.github.com"
}
13 changes: 8 additions & 5 deletions common/config/subspaces/default/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion common/config/subspaces/default/repo-state.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
{
"pnpmShrinkwrapHash": "288ee1cccceca305122bc3d4b1eb550efbcb2a0b",
"pnpmShrinkwrapHash": "121b6455d44723fc7bdb38b7d038aae935a28bd1",
"preferredVersionsHash": "029c99bd6e65c5e1f25e2848340509811ff9753c"
}
2 changes: 2 additions & 0 deletions common/reviews/api/localization-utilities.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
```ts

import { IExportAsDefaultOptions } from '@rushstack/typings-generator';
import type { ISourcePosition } from '@rushstack/typings-generator';
import type { ITerminal } from '@rushstack/terminal';
import { ITypingsGeneratorBaseOptions } from '@rushstack/typings-generator';
import { NewlineKind } from '@rushstack/node-core-library';
Expand All @@ -31,6 +32,7 @@ export interface ILocalizationFile {
export interface ILocalizedString {
// (undocumented)
comment?: string;
sourcePosition?: ISourcePosition;
// (undocumented)
value: string;
}
Expand Down
55 changes: 52 additions & 3 deletions common/reviews/api/typings-generator.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@

import { ITerminal } from '@rushstack/terminal';

// @public
export function decodeMappings(mappings: string): IDecodedSegment[][];

// @public
export interface IDeclarationMapping {
generatedColumn: number;
generatedLine: number;
sourceIndex?: number;
sourcePosition: ISourcePosition;
}

// @public
export interface IDecodedSegment {
// (undocumented)
generatedColumn: number;
// (undocumented)
sourceColumn?: number;
// (undocumented)
sourceIndex?: number;
// (undocumented)
sourceLine?: number;
}

// @public (undocumented)
export interface IExportAsDefaultOptions {
// @deprecated (undocumented)
Expand All @@ -15,6 +38,20 @@ export interface IExportAsDefaultOptions {
valueDocumentationComment?: string;
}

// @public
export interface IGeneratedTypings {
declarationMappings?: readonly IDeclarationMapping[];
typingsData: string;
}

// @public
export interface ISourcePosition {
// (undocumented)
column: number;
// (undocumented)
line: number;
}

// @public (undocumented)
export interface IStringValuesTypingsGeneratorBaseOptions {
exportAsDefault?: boolean | IExportAsDefaultOptions;
Expand All @@ -36,6 +73,7 @@ export interface IStringValueTyping {
comment?: string;
// (undocumented)
exportName: string;
sourcePosition?: ISourcePosition;
}

// @public (undocumented)
Expand All @@ -47,6 +85,7 @@ export interface IStringValueTypings {

// @public (undocumented)
export interface ITypingsGeneratorBaseOptions {
generateDeclarationMaps?: boolean;
// (undocumented)
generatedTsFolder: string;
// (undocumented)
Expand Down Expand Up @@ -81,9 +120,19 @@ export interface ITypingsGeneratorOptionsWithoutReadFile<TTypingsResult = string
parseAndGenerateTypings: (fileContents: TFileContents, filePath: string, relativePath: string) => TTypingsResult | Promise<TTypingsResult>;
}

// @public
export function originalPositionFor(decoded: readonly IDecodedSegment[][], line: number, column: number): {
sourceIndex: number;
line: number;
column: number;
} | undefined;

// @public (undocumented)
export type ReadFile<TFileContents = string> = (filePath: string, relativePath: string) => Promise<TFileContents> | TFileContents;

// @public
export function serializeDeclarationMap(mappings: readonly IDeclarationMapping[], generatedFileName: string, sources: string | readonly string[], generatedLineOffset: number): string;

// @public
export class StringValuesTypingsGenerator<TFileContents = string> extends TypingsGenerator<TFileContents> {
constructor(options: TFileContents extends string ? IStringValuesTypingsGeneratorOptions<TFileContents> : never);
Expand All @@ -92,15 +141,15 @@ export class StringValuesTypingsGenerator<TFileContents = string> extends Typing

// @public
export class TypingsGenerator<TFileContents = string> {
constructor(options: TFileContents extends string ? ITypingsGeneratorOptions<string | undefined, TFileContents> : never);
constructor(options: ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents>);
constructor(options: TFileContents extends string ? ITypingsGeneratorOptions<string | IGeneratedTypings | undefined, TFileContents> : never);
constructor(options: ITypingsGeneratorOptionsWithCustomReadFile<string | IGeneratedTypings | undefined, TFileContents>);
generateTypingsAsync(relativeFilePaths?: string[]): Promise<void>;
// (undocumented)
getOutputFilePaths(relativePath: string): string[];
readonly ignoredFileGlobs: readonly string[];
readonly inputFileGlob: string;
// (undocumented)
protected readonly _options: ITypingsGeneratorOptionsWithCustomReadFile<string | undefined, TFileContents>;
protected readonly _options: ITypingsGeneratorOptionsWithCustomReadFile<string | IGeneratedTypings | undefined, TFileContents>;
registerDependency(consumer: string, rawDependency: string): void;
// (undocumented)
runWatcherAsync(): Promise<void>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ export interface ILocalizationTypingsPluginOptions {
* An array of string names to ignore when generating typings.
*/
stringNamesToIgnore?: string[];

/**
* If true, a `.d.ts.map` file is emitted next to each generated `.d.ts` file. This allows editors
* to resolve "go to definition" on a localized string to its declaration in the source
* localization file, instead of to the generated typings.
*
* @defaultValue false
*/
generateDeclarationMaps?: boolean;
}

const PLUGIN_NAME: 'localization-typings-plugin' = 'localization-typings-plugin';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@
"items": {
"type": "string"
}
},

"generateDeclarationMaps": {
"type": "boolean",
"description": "If true, a \".d.ts.map\" file is emitted next to each generated \".d.ts\" file, allowing editors to resolve \"go to definition\" to the source localization file instead of the generated typings."
}
}
}
1 change: 1 addition & 0 deletions heft-plugins/heft-sass-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
},
"dependencies": {
"@rushstack/node-core-library": "workspace:*",
"@rushstack/typings-generator": "workspace:*",
"@types/tapable": "1.0.6",
"postcss": "~8.5.10",
"postcss-modules": "~6.0.0",
Expand Down
Loading