-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Get packageId for relative import within a package #21130
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//// [tests/cases/compiler/duplicatePackage_relativeImportWithinPackage.ts] //// | ||
|
||
//// [package.json] | ||
{ | ||
"name": "foo", | ||
"version": "1.2.3" | ||
} | ||
|
||
//// [index.d.ts] | ||
export class C { | ||
private x: number; | ||
} | ||
|
||
//// [index.d.ts] | ||
import { C } from "foo"; | ||
export const o: C; | ||
|
||
//// [use.d.ts] | ||
import { C } from "./index"; | ||
export function use(o: C): void; | ||
|
||
//// [index.d.ts] | ||
export class C { | ||
private x: number; | ||
} | ||
|
||
//// [package.json] | ||
{ | ||
"name": "foo", | ||
"version": "1.2.3" | ||
} | ||
|
||
//// [index.ts] | ||
import { use } from "foo/use"; | ||
import { o } from "a"; | ||
|
||
use(o); | ||
|
||
|
||
//// [index.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var use_1 = require("foo/use"); | ||
var a_1 = require("a"); | ||
use_1.use(a_1.o); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
=== /index.ts === | ||
import { use } from "foo/use"; | ||
>use : Symbol(use, Decl(index.ts, 0, 8)) | ||
|
||
import { o } from "a"; | ||
>o : Symbol(o, Decl(index.ts, 1, 8)) | ||
|
||
use(o); | ||
>use : Symbol(use, Decl(index.ts, 0, 8)) | ||
>o : Symbol(o, Decl(index.ts, 1, 8)) | ||
|
||
=== /node_modules/a/node_modules/foo/index.d.ts === | ||
export class C { | ||
>C : Symbol(C, Decl(index.d.ts, 0, 0)) | ||
|
||
private x: number; | ||
>x : Symbol(C.x, Decl(index.d.ts, 0, 16)) | ||
} | ||
|
||
=== /node_modules/a/index.d.ts === | ||
import { C } from "foo"; | ||
>C : Symbol(C, Decl(index.d.ts, 0, 8)) | ||
|
||
export const o: C; | ||
>o : Symbol(o, Decl(index.d.ts, 1, 12)) | ||
>C : Symbol(C, Decl(index.d.ts, 0, 8)) | ||
|
||
=== /node_modules/foo/use.d.ts === | ||
import { C } from "./index"; | ||
>C : Symbol(C, Decl(use.d.ts, 0, 8)) | ||
|
||
export function use(o: C): void; | ||
>use : Symbol(use, Decl(use.d.ts, 0, 28)) | ||
>o : Symbol(o, Decl(use.d.ts, 1, 20)) | ||
>C : Symbol(C, Decl(use.d.ts, 0, 8)) | ||
|
||
=== /node_modules/foo/index.d.ts === | ||
export class C { | ||
>C : Symbol(C, Decl(index.d.ts, 0, 0)) | ||
|
||
private x: number; | ||
>x : Symbol(C.x, Decl(index.d.ts, 0, 16)) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
[ | ||
"======== Resolving module 'foo/use' from '/index.ts'. ========", | ||
"Module resolution kind is not specified, using 'NodeJs'.", | ||
"Loading module 'foo/use' from 'node_modules' folder, target file type 'TypeScript'.", | ||
"Found 'package.json' at '/node_modules/foo/package.json'.", | ||
"File '/node_modules/foo/use.ts' does not exist.", | ||
"File '/node_modules/foo/use.tsx' does not exist.", | ||
"File '/node_modules/foo/use.d.ts' exist - use it as a name resolution result.", | ||
"Resolving real path for '/node_modules/foo/use.d.ts', result '/node_modules/foo/use.d.ts'.", | ||
"======== Module name 'foo/use' was successfully resolved to '/node_modules/foo/use.d.ts'. ========", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not related to this PR, but just a thought that came to me, we are not logging the packageid anywhere. we should probably to make these tests more statically verifiable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
"======== Resolving module 'a' from '/index.ts'. ========", | ||
"Module resolution kind is not specified, using 'NodeJs'.", | ||
"Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.", | ||
"File '/node_modules/a/package.json' does not exist.", | ||
"File '/node_modules/a.ts' does not exist.", | ||
"File '/node_modules/a.tsx' does not exist.", | ||
"File '/node_modules/a.d.ts' does not exist.", | ||
"File '/node_modules/a/index.ts' does not exist.", | ||
"File '/node_modules/a/index.tsx' does not exist.", | ||
"File '/node_modules/a/index.d.ts' exist - use it as a name resolution result.", | ||
"Resolving real path for '/node_modules/a/index.d.ts', result '/node_modules/a/index.d.ts'.", | ||
"======== Module name 'a' was successfully resolved to '/node_modules/a/index.d.ts'. ========", | ||
"======== Resolving module './index' from '/node_modules/foo/use.d.ts'. ========", | ||
"Module resolution kind is not specified, using 'NodeJs'.", | ||
"Loading module as file / folder, candidate module location '/node_modules/foo/index', target file type 'TypeScript'.", | ||
"File '/node_modules/foo/index.ts' does not exist.", | ||
"File '/node_modules/foo/index.tsx' does not exist.", | ||
"File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.", | ||
"Found 'package.json' at '/node_modules/foo/package.json'.", | ||
"======== Module name './index' was successfully resolved to '/node_modules/foo/index.d.ts'. ========", | ||
"======== Resolving module 'foo' from '/node_modules/a/index.d.ts'. ========", | ||
"Module resolution kind is not specified, using 'NodeJs'.", | ||
"Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", | ||
"Found 'package.json' at '/node_modules/a/node_modules/foo/package.json'.", | ||
"File '/node_modules/a/node_modules/foo.ts' does not exist.", | ||
"File '/node_modules/a/node_modules/foo.tsx' does not exist.", | ||
"File '/node_modules/a/node_modules/foo.d.ts' does not exist.", | ||
"'package.json' does not have a 'typings' field.", | ||
"'package.json' does not have a 'types' field.", | ||
"File '/node_modules/a/node_modules/foo/index.ts' does not exist.", | ||
"File '/node_modules/a/node_modules/foo/index.tsx' does not exist.", | ||
"File '/node_modules/a/node_modules/foo/index.d.ts' exist - use it as a name resolution result.", | ||
"Resolving real path for '/node_modules/a/node_modules/foo/index.d.ts', result '/node_modules/a/node_modules/foo/index.d.ts'.", | ||
"======== Module name 'foo' was successfully resolved to '/node_modules/a/node_modules/foo/index.d.ts'. ========" | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
=== /index.ts === | ||
import { use } from "foo/use"; | ||
>use : (o: C) => void | ||
|
||
import { o } from "a"; | ||
>o : C | ||
|
||
use(o); | ||
>use(o) : void | ||
>use : (o: C) => void | ||
>o : C | ||
|
||
=== /node_modules/a/node_modules/foo/index.d.ts === | ||
export class C { | ||
>C : C | ||
|
||
private x: number; | ||
>x : number | ||
} | ||
|
||
=== /node_modules/a/index.d.ts === | ||
import { C } from "foo"; | ||
>C : typeof C | ||
|
||
export const o: C; | ||
>o : C | ||
>C : C | ||
|
||
=== /node_modules/foo/use.d.ts === | ||
import { C } from "./index"; | ||
>C : typeof C | ||
|
||
export function use(o: C): void; | ||
>use : (o: C) => void | ||
>o : C | ||
>C : C | ||
|
||
=== /node_modules/foo/index.d.ts === | ||
export class C { | ||
>C : C | ||
|
||
private x: number; | ||
>x : number | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//// [tests/cases/compiler/duplicatePackage_relativeImportWithinPackage_scoped.ts] //// | ||
|
||
//// [package.json] | ||
{ | ||
"name": "@foo/bar", | ||
"version": "1.2.3" | ||
} | ||
|
||
//// [index.d.ts] | ||
export class C { | ||
private x: number; | ||
} | ||
|
||
//// [index.d.ts] | ||
import { C } from "@foo/bar"; | ||
export const o: C; | ||
|
||
//// [use.d.ts] | ||
import { C } from "./index"; | ||
export function use(o: C): void; | ||
|
||
//// [index.d.ts] | ||
export class C { | ||
private x: number; | ||
} | ||
|
||
//// [package.json] | ||
{ | ||
"name": "@foo/bar", | ||
"version": "1.2.3" | ||
} | ||
|
||
//// [index.ts] | ||
import { use } from "@foo/bar/use"; | ||
import { o } from "a"; | ||
|
||
use(o); | ||
|
||
|
||
//// [index.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var use_1 = require("@foo/bar/use"); | ||
var a_1 = require("a"); | ||
use_1.use(a_1.o); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
=== /index.ts === | ||
import { use } from "@foo/bar/use"; | ||
>use : Symbol(use, Decl(index.ts, 0, 8)) | ||
|
||
import { o } from "a"; | ||
>o : Symbol(o, Decl(index.ts, 1, 8)) | ||
|
||
use(o); | ||
>use : Symbol(use, Decl(index.ts, 0, 8)) | ||
>o : Symbol(o, Decl(index.ts, 1, 8)) | ||
|
||
=== /node_modules/a/node_modules/@foo/bar/index.d.ts === | ||
export class C { | ||
>C : Symbol(C, Decl(index.d.ts, 0, 0)) | ||
|
||
private x: number; | ||
>x : Symbol(C.x, Decl(index.d.ts, 0, 16)) | ||
} | ||
|
||
=== /node_modules/a/index.d.ts === | ||
import { C } from "@foo/bar"; | ||
>C : Symbol(C, Decl(index.d.ts, 0, 8)) | ||
|
||
export const o: C; | ||
>o : Symbol(o, Decl(index.d.ts, 1, 12)) | ||
>C : Symbol(C, Decl(index.d.ts, 0, 8)) | ||
|
||
=== /node_modules/@foo/bar/use.d.ts === | ||
import { C } from "./index"; | ||
>C : Symbol(C, Decl(use.d.ts, 0, 8)) | ||
|
||
export function use(o: C): void; | ||
>use : Symbol(use, Decl(use.d.ts, 0, 28)) | ||
>o : Symbol(o, Decl(use.d.ts, 1, 20)) | ||
>C : Symbol(C, Decl(use.d.ts, 0, 8)) | ||
|
||
=== /node_modules/@foo/bar/index.d.ts === | ||
export class C { | ||
>C : Symbol(C, Decl(index.d.ts, 0, 0)) | ||
|
||
private x: number; | ||
>x : Symbol(C.x, Decl(index.d.ts, 0, 16)) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
[ | ||
"======== Resolving module '@foo/bar/use' from '/index.ts'. ========", | ||
"Module resolution kind is not specified, using 'NodeJs'.", | ||
"Loading module '@foo/bar/use' from 'node_modules' folder, target file type 'TypeScript'.", | ||
"Found 'package.json' at '/node_modules/@foo/bar/package.json'.", | ||
"File '/node_modules/@foo/bar/use.ts' does not exist.", | ||
"File '/node_modules/@foo/bar/use.tsx' does not exist.", | ||
"File '/node_modules/@foo/bar/use.d.ts' exist - use it as a name resolution result.", | ||
"Resolving real path for '/node_modules/@foo/bar/use.d.ts', result '/node_modules/@foo/bar/use.d.ts'.", | ||
"======== Module name '@foo/bar/use' was successfully resolved to '/node_modules/@foo/bar/use.d.ts'. ========", | ||
"======== Resolving module 'a' from '/index.ts'. ========", | ||
"Module resolution kind is not specified, using 'NodeJs'.", | ||
"Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.", | ||
"File '/node_modules/a/package.json' does not exist.", | ||
"File '/node_modules/a.ts' does not exist.", | ||
"File '/node_modules/a.tsx' does not exist.", | ||
"File '/node_modules/a.d.ts' does not exist.", | ||
"File '/node_modules/a/index.ts' does not exist.", | ||
"File '/node_modules/a/index.tsx' does not exist.", | ||
"File '/node_modules/a/index.d.ts' exist - use it as a name resolution result.", | ||
"Resolving real path for '/node_modules/a/index.d.ts', result '/node_modules/a/index.d.ts'.", | ||
"======== Module name 'a' was successfully resolved to '/node_modules/a/index.d.ts'. ========", | ||
"======== Resolving module './index' from '/node_modules/@foo/bar/use.d.ts'. ========", | ||
"Module resolution kind is not specified, using 'NodeJs'.", | ||
"Loading module as file / folder, candidate module location '/node_modules/@foo/bar/index', target file type 'TypeScript'.", | ||
"File '/node_modules/@foo/bar/index.ts' does not exist.", | ||
"File '/node_modules/@foo/bar/index.tsx' does not exist.", | ||
"File '/node_modules/@foo/bar/index.d.ts' exist - use it as a name resolution result.", | ||
"Found 'package.json' at '/node_modules/@foo/bar/package.json'.", | ||
"======== Module name './index' was successfully resolved to '/node_modules/@foo/bar/index.d.ts'. ========", | ||
"======== Resolving module '@foo/bar' from '/node_modules/a/index.d.ts'. ========", | ||
"Module resolution kind is not specified, using 'NodeJs'.", | ||
"Loading module '@foo/bar' from 'node_modules' folder, target file type 'TypeScript'.", | ||
"Found 'package.json' at '/node_modules/a/node_modules/@foo/bar/package.json'.", | ||
"File '/node_modules/a/node_modules/@foo/bar.ts' does not exist.", | ||
"File '/node_modules/a/node_modules/@foo/bar.tsx' does not exist.", | ||
"File '/node_modules/a/node_modules/@foo/bar.d.ts' does not exist.", | ||
"'package.json' does not have a 'typings' field.", | ||
"'package.json' does not have a 'types' field.", | ||
"File '/node_modules/a/node_modules/@foo/bar/index.ts' does not exist.", | ||
"File '/node_modules/a/node_modules/@foo/bar/index.tsx' does not exist.", | ||
"File '/node_modules/a/node_modules/@foo/bar/index.d.ts' exist - use it as a name resolution result.", | ||
"Resolving real path for '/node_modules/a/node_modules/@foo/bar/index.d.ts', result '/node_modules/a/node_modules/@foo/bar/index.d.ts'.", | ||
"======== Module name '@foo/bar' was successfully resolved to '/node_modules/a/node_modules/@foo/bar/index.d.ts'. ========" | ||
] |
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.
can you add a test for scoped packages as well