fix(build): add declaration maps for better editor navigation#124
Open
Kyzgor wants to merge 1 commit intopermitio:mainfrom
Open
fix(build): add declaration maps for better editor navigation#124Kyzgor wants to merge 1 commit intopermitio:mainfrom
Kyzgor wants to merge 1 commit intopermitio:mainfrom
Conversation
Enable `declarationMap` in tsconfig.json to generate `.d.ts.map` files alongside type declarations. This fixes "Go to Definition" in editors like VS Code, which currently navigates to compiled JS without type information instead of the typed declaration files. Refs permitio#77
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Enable TypeScript declaration maps (
declarationMap: true) to fix "Go to Definition" navigation in editors like VS Code.Problem
As reported in #77, using "Go to Definition" on SDK methods (e.g.,
permit.api.roles.create) navigates to compiled JavaScript without type information, rather than to the typed declaration files. This makes it impossible to inspect parameter types likeRoleCreateor return types likeRoleReadthrough normal editor navigation.Solution
Added
declarationMap: truetotsconfig.json. This generates.d.ts.mapfiles alongside the existing.d.tsdeclarations during thetsc --emitDeclarationOnlybuild step. These map files enable editors to properly resolve "Go to Definition" and "Go to Type Definition" to the typed declarations.Changes
tsconfig.json— AddeddeclarationMap: truecompiler optionTesting
yarn lintpassesyarn build:typesgenerates.d.ts.mapfiles alongside.d.tsfiles (verified:build/index.d.ts.map,build/api/roles.d.ts.map, etc.)buildentry in thefilesfieldBackwards Compatibility
No breaking changes. Declaration maps are additive — they only improve editor DX for SDK consumers. Consumers that don't use TypeScript or don't rely on "Go to Definition" are unaffected.
Note: This PR addresses the declaration map portion of #77. The tsconfig target update (
es2017→ES2022) mentioned in the issue is a separate change that would affect the minimum supported Node version and should be discussed separately.Checklist
yarn lintpassesyarn build:typessucceeds with.d.ts.mapoutputsrc/openapi/(auto-generated)Refs #77