Skip to content

feat(server): Definitions for sources compiled with declarationMap #1601

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

Merged
merged 2 commits into from
Jan 26, 2022
Merged
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
22 changes: 22 additions & 0 deletions integration/lsp/ivy_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,28 @@ describe('Angular Ivy language server', () => {
});
});

it('goes to definition of original source when compiled with source maps', async () => {
client.sendNotification(lsp.DidOpenTextDocumentNotification.type, {
textDocument: {
uri: FOO_TEMPLATE_URI,
languageId: 'html',
version: 1,
text: `<lib-post></lib-post>`,
},
});
const languageServiceEnabled = await waitForNgcc(client);
expect(languageServiceEnabled).toBeTrue();
const response = await client.sendRequest(lsp.DefinitionRequest.type, {
textDocument: {
uri: FOO_TEMPLATE_URI,
},
position: {line: 0, character: 1},
}) as lsp.LocationLink[];
expect(Array.isArray(response)).toBe(true);
const {targetUri} = response[0];
expect(targetUri).toContain('libs/post/src/lib/post.component.ts');
});

describe('signature help', () => {
it('should show signature help for an empty call', async () => {
client.sendNotification(lsp.DidOpenTextDocumentNotification.type, {
Expand Down
18 changes: 11 additions & 7 deletions integration/project/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { FooComponent } from './foo.component';
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {PostModule} from 'post';

import {AppComponent} from './app.component';
import {FooComponent} from './foo.component';

@NgModule({
imports: [
imports: [
CommonModule,
PostModule,
],
declarations: [
AppComponent,
FooComponent,
],
bootstrap: [ AppComponent ]
bootstrap: [AppComponent]
})
export class AppModule { }
export class AppModule {
}
3 changes: 2 additions & 1 deletion integration/project/app/foo.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{title | uppercase}}
<span class="subtitle">
subtitle
</span>
</span>
<lib-post></lib-post>
7 changes: 7 additions & 0 deletions integration/project/libs/post/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/post",
"lib": {
"entryFile": "src/index.ts"
}
}
10 changes: 10 additions & 0 deletions integration/project/libs/post/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "post",
"version": "0.0.1",
"peerDependencies": {
"@angular/core": "^13.0.0"
},
"dependencies": {
"tslib": "^2.3.0"
}
}
1 change: 1 addition & 0 deletions integration/project/libs/post/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/post.component';
16 changes: 16 additions & 0 deletions integration/project/libs/post/src/lib/post.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {Component, NgModule} from '@angular/core';

@Component({
selector: 'lib-post',
template: '{{random}}',
})
export class PostComponent {
random = Math.random();
}

@NgModule({
declarations: [PostComponent],
exports: [PostComponent],
})
export class PostModule {
}
16 changes: 16 additions & 0 deletions integration/project/libs/post/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "../../tsconfig.json",
"files": [],
"include": [
"**/*.ts"
],
"compilerOptions": {
"outDir": "../../tsc-dist/post",
"rootDir": ".",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"sourceMap": true,
"types": []
},
}
9 changes: 8 additions & 1 deletion integration/project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@
"@angular/core": "13.0.0-rc.3",
"rxjs": "6.6.7",
"zone.js": "0.11.4"
},
"devDependencies": {
"ng-packagr": "^13.2.0",
"typescript": "~4.4.3"
},
"scripts": {
"build": "ng-packagr -p libs/post/ng-package.json -c libs/post/tsconfig.json"
}
}
}
10 changes: 8 additions & 2 deletions integration/project/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
"strict": true,
"typeRoots": [
"node_modules/@types"
]
],
"baseUrl": ".",
"paths": {
"post": [
"dist/post"
]
}
},
"angularCompilerOptions": {
"strictTemplates": true,
"strictInjectionParameters": true
}
}
}
Loading